🖥

Stripe::InvalidRequestError: Some of the parameters you provided (paym

2020/03/28に公開

require 'stripe'

Stripe.api_key = ENV['STRIPE_SECRET_KEY']

checkout_session = Stripe::Checkout::Session.create(
  payment_method_types: ['card'],
  mode: 'setup',
  success_url: 'http://example.com',
  cancel_url: 'http://example.com'
)

payment_method = Stripe::PaymentMethod.create(
  type: 'card',
  card: { number: '4242424242424242', exp_year: 2030, exp_month: 01}
)

# Stripe::InvalidRequestError:
# Some of the parameters you provided (payment_method) cannot be used when modifying a SetupIntent that was created by Checkout.
# You can try again without those parameters.

Stripe::SetupIntent.update(
  checkout_session.setup_intent,
  {payment_method: payment_method.id},
)

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/3049

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2020-03-28

Discussion