オリジナルCommerce決済モジュール(Offsite)で決済サーバーへのPOST時のエンコードを変更する方法

カテゴリ Commerce コアバージョン 8.6.x 関連モジュール Commerce Payment Gateway

commerce_xxx.module

function commerce_xxx_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if (strpos($form_id,'commerce_checkout_flow_multistep_') === 0) {
    if ($form['#step_id'] == 'payment') { // Checkout stepを特定
      if ($buildInfo = $form_state->getBuildInfo()) {
        if (isset($buildInfo['callback_object'])) {
          $callback_object = clone $buildInfo['callback_object'];
          if (method_exists($callback_object, 'getOrder')) {
            if ($order = $callback_object->getOrder()) {
              if ($payment_gateway = $order->get('payment_gateway')) {
                $name = $payment_gateway->getValue();
                if (isset($name[0]['target_id'])) {
                  if ($name[0]['target_id'] == 'xxxxxxxxxxxxx') { // 決済ゲートウェイを特定
                    $form['#attributes']['accept-charset'] = 'xxxxxxx'; // Shift_JIS など
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

OTHER FAQ

Drupal開発・運用の疑問/質問の答えはここに

無料ユーザー登録すると質問できます。

カテゴリ降順で並び替える Core Ver. 関連モジュール タイトル
コンテンツの管理 7.15 Content Access 簡単に閲覧制限を行うには?
コンテンツの管理 8.5.x Field File コンテンツのフィールドの表示について
コンテンツの管理 8.4x Entity EntityをPropertyで探す(クエリする)方法
コンテンツの管理 7.16 PHP 好きなところにノードを埋め込みたい
コンテンツの管理 7,51 Views Data Export Views Data ExportでCSVデータが欠けてしまう
コンテンツの管理 7.15 Views Bulk Operation 標準のコンテンツ編集/ユーザ一覧ページが物足りません
コンテンツの管理 7.15 Pagenation 一つの長いページをBookなどのように連続して読ませることはできますか?
コンテンツの管理 8.6.x Commerce Commerce orderからすべての商品名を取得する方法
コンテンツの管理 6.x Views Flag Calendar 空き室予約のような仕組みは実現できますか?
コンテンツの管理 8.9.x 写真の変更を行いたい
コンテンツの管理 7.50 Administration menu 標準のユーザー管理ページ
サイトの構築 7.41 Rules Paygent モジュールについて
サイトの構築 7.22 Views Devel Viewsの設定ページが変に?
サイトの構築 7.34 ECK Entityの使い方について
サイトの構築 7.59 Drupal.ajax drupal 7 で Uncaught TypeError: Drupal.ajax is undefined となったときの対応方法
サイトの構築 7.31 Views ブロックViewsの絞り込みが表示されない
サイトの構築 7.27 Context block ページ別、カテゴリ別等でブロックの表示有無を簡単にするには
サイトの構築 7.22 Views フィールドセットの伸縮をノンプログラミングでやりたい
サイトの構築 7.38 deployment 冗長構成におけるアップロードおよび時間指定公開について
サイトの構築 7.50 Module Missing Message Fixer モジュールをアンインストールしたらエラーがでるようになった

ページ