#Dan Judge
1 messages · Page 1 of 1 (latest)
You just want to calculate what the amount would be after fees?
Yeah, is there not a solid total in the checkout session response which has the total paid minus fees?
No not in the checkout session response. Do you need the fees before the payment is completed? There's a way to retrieve the fees after a payment has been completed. If you need the fees prior to payment, you'll need to attempt to calculate them yourself.
After the payment is completed, is fine, how do I get that total amount from a checkout session please?
So there will be a payment intent on the checkout session: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_intent. You'll need to retrieve that: https://stripe.com/docs/api/payment_intents/retrieve and expand latest_charge: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-latest_charge. Within that charge object, you'll have a balance transaction: https://stripe.com/docs/api/charges/object#charge_object-balance_transaction. If you retrieve that: https://stripe.com/docs/api/balance_transactions/retrieve then you can calculate amount - fee since the balance transaction object has the fee details: https://stripe.com/docs/api/balance_transactions/object#balance_transaction_object-fee
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The patment_intent always seems to be null, I tried going down that route, any idea why it would be null?
Was the checkout session completed and paid?
Ah it's in subscription mode
So in that case you'll need to go to the subscription object -> latest_invoice -> payment_intent
Recommend using expansion as much as possible to reduce num of api requests; https://stripe.com/docs/expand
Got you, okay that's brilliant, thanks very much for your help
No problem
Can I use expansion on the invoice for the payment intent and also the balance transaction?
To get it all in one request
You can go 4 levels in 1 request: https://stripe.com/docs/expand#multiple-levels
Expansions have a maximum depth of four levels. Meaning that an expand string can contain no more than four properties: property1.property2.property3.property4.
Okay thank you
No problem