オリジナル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.44 Password Policy 無効なユーザーを整理したい
ユーザ 7.23 PHP user_load_multiple()の復帰値
ユーザ 7.38 user form 新規ユーザー登録時、パスワード再設定時のパスワード入力抜けを防ぎたい
ユーザ 7.44 Quickbar 会員の種別(役割)別にメニューを設けたい
ユーザの管理 7.50 Paypal continued billing drupal7のPaypal継続課金モジュールについて
ユーザの管理 7.59 user pass drupal 7 で 管理者(uid=1)パスワードがわからなくなったとき 新しいパスワードを設定する方法
ユーザの管理 7.27 PHP 新規ユーザーの追加ができない
ユーザの管理 8.9.x user pass drupal 8 で 管理者(uid=1)パスワードがわからなくなったとき 新しいパスワードを設定する方法
ユーザの管理 7.15 Devel 簡単に指定ユーザにログインしなおす方法
リバースプロキシ 8.9.x mod_proxy mod_proxy_http mod_ssl Apache2.4 から httpsサーバーへリバースプロキシする方法
ログイン 8.7.x System ユーザー アカウントロックの範囲設定
拡張機能 8.3x Contribute modules drupal8-寄贈モジュールの動向
排他 7.26 lock Viewsモジュールの設定ページのような排他機能
権限 7.50 Cron Basic認証時のCron(wget)実行方法
権限 7.15 Path_Access Content_Access 特定のページ(パス)をアクセス制限したい
表示 7.34 Views Infinite Scroll Facebookページのようにスクロールするとコンテンツが追加されるようなコントロール
表示 7.26 Views ページ内に2つ目Viewsブロックを設置するときPagerが連動してしまう
見栄え 7.15 js Injector 簡単にJavascriptを追加する方法は?
言語 7.15 Entity Translation 各フィールドのラベルの多言語切り替え漏れ(フィールド・ラベル)
言語 7.15 Entity Translation nodeのEntity Translation

ページ