自己解決できました。
フォームにテキストフィールドあるいはhiddenフィールドに、選択肢の結果をjQueryで値を入力後、以下コードにより値を反映させることができました。
質問内のサイトを参考にカスタマイズしてます。
例)
- CF7内に”stripe-amount” フィールドを作成し、セレクタやラジオの選択結果の値をjQueryをつかって入力させる。
- 同じく[stripe]タグを設置し、functions.phpに以下コードを設置
※[stripe]タグのオプションは入力可能です。
add_filter('wpcf7_stripe_payment_intent_parameters',
function( $params ){
// Get the WPCF7_Submission object
$submission = WPCF7_Submission::get_instance();
// Put your currency here in uppercase
//「通貨」のフィールド値から通貨を取得します(今回不使用)
$currency = (array) $submission->get_posted_data( 'your-currency' );
$currency = (string) array_shift( $currency );
$params['currency'] = strtolower( $currency );
// get value from input name=stripe-amount
// "stripe-amount" フィールド値から値を取得します
$amount = (array) $submission->get_posted_data( 'stripe-amount' );
$amount = (string) array_shift( $amount );
$params['amount'] = $amount;
// Retrieve the buyer's email from the 'your-email' field value
// "your-email"フィールド値から購入者のメールを取得します(今回不使用)
$receipt_email = $submission->get_posted_data( 'your-email' );
if ( is_email( $receipt_email ) ) {
$params['receipt_email'] = $receipt_email;
}
// See https://stripe.com/docs/api/payment_intents/create
// for the full list of available parameters
return $params;
},
10,1);