cecileRx
cecileRx

Reputation: 135

STRIPE checkout SESSION unknown parameters

I am trying to pass some parameters in a checkout session of stripe with this code:

@session = Stripe::Checkout::Session.create(
  payment_method_types: ['card'],
  shipping: {
    adress: {
       city: 'Paris',
       country: 'France',
       line1: 'hello',
       line2: 'hello again',
       postal_code: '0000',
       state: 'whatever'
      },
    name: 'yeahman'
  },

  shipping_address_collection: {
    allowed_countries: ['US', 'CA', 'FR', 'PT', 'ES']
  },
  customer_email: current_user.email,

  line_items: line_items_order,

  success_url: new_order_message_url(@order),
  cancel_url: order_url(@order)
)

All the attributes are listed in the stripe API doc, but I get this error:

Stripe::InvalidRequestError (Received unknown parameter: shipping)

Has anyone an idea about the reason why?

Upvotes: 0

Views: 720

Answers (1)

ttmarek
ttmarek

Reputation: 3260

It's not possible to pre-fill the shipping address in Stripe Checkout. You simply provide a list of allowed countries to the shipping_address_collection parameter and Stripe will display input fields for your customer's to enter their shipping details into. Note that shipping isn't listed as a possible parameter when creating a Checkout Session:

https://stripe.com/docs/api/checkout/sessions/create?lang=ruby

Upvotes: 1

Related Questions