オリジナル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.22 Realname ユーザーIDではなくニックネーム等を表示したい
ユーザ 7.44 Quickbar 会員の種別(役割)別にメニューを設けたい
SSH 7.50 ProxyCommand SSH IP制限を1コマンドで通過する
Proxy 7.59 Proxy Apache settings.php リバースプロキシ(Apache)+バックグランドWeb(Drupal 7 )でログインセッションを維持する方法
サイトの構築 7.19 Plesk Pleskでdrupal7(プライベートファイルシステム)を使う場合の注意点
コンテンツの作成 8.4x PhpSpreadsheet Excelを読み書きする方法
チューニング 7.26 PHP DrupalはNginxで動く?
コンテンツの管理 7.16 PHP 好きなところにノードを埋め込みたい
アップデート 8.9.x PHP CentosでPHPのバージョンアップ(例:5.3->5.6)を行う方法
Database 7.34 PHP データベースクエリ(SELECT)時のSQL関数
JavaScript 8.5.x PHP Commerce決済モジュール設定をJavaScriptにデータに渡す方法
コンテンツの作成 7.26 PHP ノード内の一部(フィールド)を変更する
PHP 8.3x PHP drupa8でhook_init()する方法
ユーザの管理 7.27 PHP 新規ユーザーの追加ができない
PHP 7.22 PHP ノードに付いたコメントを好きな場所に表示する
PHP-FPM 8.9.x PHP PHP-FPM 環境で .htaccess に php_value を 書いてもダメ
JavaScript 7.34 PHP PHPからJavaScriptに変数値を渡したい
ユーザ 7.23 PHP user_load_multiple()の復帰値
PHP 8.9.x PHP YamlをPHP配列にする方法
ユーザの管理 7.50 Paypal continued billing drupal7のPaypal継続課金モジュールについて

ページ