#Mike-7189-cors

1 messages ยท Page 1 of 1 (latest)

muted plover
viral beacon
#

Hi ๐Ÿ™‚

muted plover
#

@viral beacon could you share the exact code you're using to create the CheckoutSession and redirect to it?

viral beacon
#

one moment

#

Backend

#

Frontend (if it even matters)

#

currently trying to do with dummy data

muted plover
#

yeah you can't redirect from an XHR like that

#

you need to either :

  • change the frontend to be a simple <form action="create_checkout_session that does a full page redirect (then the backend code works as-is)

  • change the backend to return for example a 200 status instead with e.g JSON object that contains the URL, and then on the frontend, set window.location = url to redirect that way

viral beacon
#

alright, lemme try

#

yay it worked!

#

where do you I place product_id?

#

and which of these?

muted plover
#

instead of price_data you'd put price:"price_xxx",

#

you don't need the product ID itself ,just the Price

viral beacon
#

Missing required param: line_items[0][currency].

muted plover
#

you shouldn't get that error(my guess is you passed a variable for the price ID and it's null)

#

can you share the code?

viral beacon
#

yeah, variable is undefined

#

Alright, sorted it out ๐Ÿ™‚

#

Now some more questions:
How do I set more payment methods?
Like in docs they have google pay, apple pay and maybe some other stuff, but my checkout shows only card as an available payment method

#

like here: offers some different methods

#

and mine is just card

#

or if I have other questions, shall I ask in #dev-help channel so the new thread will be created? Or can we carry on in this one?

muted plover
#

here is fine

#

Apple/Google Pay should just appear, if you're in a browser that supports them and that has active cards available, like you're logged into Chrome with your Google account and have Google Pay cards in your account

#

other payment methods are controlled by what you pass to payment_method_types when creating the Session object, basically

muted plover
#

though that's rare

viral beacon
#

I also need to limit list of countries for shipping, collect shipping addresses and let customers to choose the quantity (can't be higher than exists in my database)

viral beacon
muted plover
viral beacon
#
shipping_rates: ['shr_123456789'],
    shipping_address_collection: {
      allowed_countries: ['US', 'CA'],
    },

what's this shipping_rates and where can I find the list of allowed_countries? so I don't mess with acronyms

#

oh sorry, I found it ๐Ÿ˜„

muted plover
#

yep, should be covered in that link

viral beacon
#

can I get some extra shipping details? Such as phone number

muted plover
#

it gets saved to the Customer though, not the shipping address itself