#manic-pixie-dream-bananarchist_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/1222712471375184025
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- manic-pixie-dream-bananarchist_api, 5 hours ago, 48 messages
- manic-pixie-dream-bananarchist_api, 20 hours ago, 19 messages
Hi there, once the checkout session is complete, you should expand its payment_intent, so that you can get the payment_method through checkout_session->payment_intent->payment_method
Ah i see, I didn't realize a payment intent was created as part of the checkout
thank you!
It depends on the checkout session's mode. If the mode is payment, then the checkout session will create a payment_intent.
our mode is subscription
Ah I see. then you should expand subscription.latest_invoice and get the payment method from checkout_session->subscription->latest_invoice->payment_intent->payment_method
do i need to specify these parameters via the expand key
const checkoutSession = await stripe.checkout.sessions.retrieve(sessionId);
is what i'm doing right now
Put subscription.latest_invoice.payment_intent in the expand array when retrieving the checkout session https://docs.stripe.com/expand
ah i didn't realize expand allowed nested objects
so that implicitly expands every object in the chain?
Yes, you can expand up to 4 levels
No overload matches this call.
Overload 1 of 2, '(id: string, params?: SessionRetrieveParams | undefined, options?: RequestOptions | undefined): Promise<Response<Session>>', gave the following error.
Type 'string' is not assignable to type 'string[]'.
Overload 2 of 2, '(id: string, options?: RequestOptions | undefined): Promise<Response<Session>>', gave the following error.
Argument of type '{ expand: string; }' is not assignable to parameter of type 'RequestOptions'.
Object literal may only specify known properties, and 'expand' does not exist in type 'RequestOptions'
Show me your code
expand is defined as a parameter though
interface SessionRetrieveParams {
/**
* Specifies which fields in the response should be expanded.
*/
expand?: Array<string>;
}
oh it's an array
side note
why doesn't the typescript library type the response based on the expand key
const checkoutSession = await stripe.checkout.sessions.retrieve(sessionId, {
expand: ['subscription.latest_invoice.payment_intent'],
});
// (property) Stripe.Checkout.Session.subscription: string | Stripe.Subscription | null
const sub = checkoutSession.subscription
since i'm expanding subscription it should know that it's not a string
@calm veldt
expansion does not work
const checkoutSession = await stripe.checkout.sessions.retrieve(sessionId, {
expand: ['subscription.latest_invoice.payment_intent'],
});
const paymentMethod = checkoutSession.subscription.latest_invoice.payment_intent.payment_method as string;
Unable to process stripe customer hold: Cannot read properties of null (reading 'payment_method')
it's not expanding payment_intent
Hi! Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
or rather there is no payment_intent
probably bc we create the subscription with a trial
i have the sessionId cs_test_a1XlAOVGx0RrOpfDJwSkmK70J1obf5yT3u93Xik6MghvFjiHJiHuZiNcKd
Yes you are right,
And actually you can get the payment_method collected by checkout from the subscription's default_payment_method
ah so it's just session.subscription.default_payment_method ?
only need to expand subscription
Yes
running into another problem
should i start a new thread
it's not rly related
@calm veldt
It's OK, we can continue here
ok great ty
i'm testing a flow where we accept a payment method, but create a hold on that payment method
my understanding was creating that hold would fail in the same way that charging a payment intent would
i'm testing with the stripe card id that allows creating a payment method but will fail any charges 4000000000000341
however my payment intent creation with capture_mode manual succeeded
What's the paymentIntent ID?
pi_3Oz96gPMRkxSx21J0VAsNGhq
I see
just for me to confirm, a hold is different than a charge that is refunded correct?
as in if I create a hold and let it expire, i do not incurr any processing fees
Yes you are right, but you can only hold up to 7 days
perfect
we're creating the hold to ensure that the customer isn't starting a trial with a source that can't complete a payment
to navigate issues with different bank accounts selectively enforcing cvc / zip / address verification
and to prevent a customer from starting a trial with a card that is already maxed out