#zach_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1278989626614349824
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
What are those errors?
StripeInvalidRequestError: Invalid array at StripeError.generate (file:///home/zach/projects/domain.com.au/node_modules/.pnpm/stripe@16.1.0/node_modules/stripe/esm/Error.js:7:20)
StripeInvalidRequestError: Received unknown parameter: shipping_address_collection[0]
at StripeError.generate (file:///home/zach/projects/domain.com.au/node_modules/.pnpm/stripe@16.1.0/node_modules/stripe/esm/Error.js:7:20)
commented out each issue to remove the error and they just keep popping up, it's like nothing I pass to it works
I've tried removing various objects on the stripe checkout session to remove each subsequent error
but it seems that each one just gives a new error
I'm trying to buy various line items from price IDs but only within Australia, with $10 shipping, AUD currency etc.
shipping_address_collection needs to contain an allowed_countries property: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-shipping_address_collection
shipping_options needs to be an array: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-shipping_options
What are other errors you're getting?
ah I'm just a noob at understanding documentation, apologies
I'll go fix those and get back to you
No worries. Sure.
const session = await stripe.checkout.sessions.create({
line_items: lineItems,
mode: 'payment',
currency: "aud",
success_url: '/success',
cancel_url: '/cancel',
shipping_address_collection: {
allowed_countries: ['AU']
},
total_details: {
amount_shipping: 1000
}
});
Now I'm getting StripeInvalidRequestError: Received unknown parameter: total_details
What is total_details?
in that code snippet it has the amount shipping object
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This is not a parameter you can use in the Create Session method.
Use shipping_options: [{ shipping_rate: <shipping_rate_id> }] for this. You can create shipping rates in your Dashboard: https://dashboard.stripe.com/test/shipping-rates
Or you can create a shipping rate on the fly with shipping_options: [{ shipping_rate_data: { ... } }]: https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-shipping_options-shipping_rate_data
Alright I just tried that and got this error:
StripeInvalidRequestError: Not a valid URL
const session = await stripe.checkout.sessions.create({
line_items: lineItems,
mode: 'payment',
currency: "aud",
success_url: '/success',
cancel_url: '/cancel',
shipping_address_collection: {
allowed_countries: ['AU']
},
shipping_options: [
{ shipping_rate: "shr_1PtQCq2KWVGERRoayuGXnXEP" }
]
});
oh it's because I changed my success and cancel URLs to be relative
Yes
StripeInvalidRequestError: No valid payment method types for this Checkout Session. Please ensure that you have activated payment methods compatible with your chosen currency in your dashboard (https://dashboard.stripe.com/settings/payment_methods) or specify
payment_method_types.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Didn't have to do this before and had it working
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
req_9qPpHazRoWhpGS
The amount is too large, you need to create a Price with a smaller amount.
ah
it was a test amount lol
working!
finally
I was strugllign with this for ages ty
Happy to help.