#Adaman
1 messages · Page 1 of 1 (latest)
checkout_session = stripe.checkout.Session.create(
customer_email=email,
line_items=[{'price_data': {'unit_amount': 1000, 'currency': 'gbp', 'product_data': {'name': 'Listing Fee - 1988 Herrera, Vasquez and Fitzpatrick high'}}, 'quantity': 1}, {'price_data': {'unit_amount': 100, 'currency': 'gbp', 'product_data': {'name': 'Search Boost Upgrade'}}, 'quantity': 1}],
metadata={
'payment_id': payment.id,
},
mode='payment',
payment_intent_data={
'metadata': {
'payment_id': payment.id
}
},
success_url=get_full_url(request, reverse('confirm_payment_successful_view', args=[car.id, payment.id])),
cancel_url=get_full_url(request, reverse('delete-car-return-to-listing-view', args=[car.id]))
)
Hi @civic barn Long story short this is an example of how I'm generating a checkout session (the line items are generated dynamically so these are just examples). When I get to the checkout page itself however, only one of the line items counts towards the total, the other is set to 0.
can you provide an example Checkout Session ID or a request ID?
Each Checkout Session is assigned an ID. If you're in live mode, it'll look like cs_live...; if you're in test mode, it'll look like cs_test...
cs_test_b1yMPNxGH152VlJPypxm9sIGDfXttbNhCWQjbT3e61oW4u08DNxTHNfxzT could this be it?
should have the same line items as the screenshot I sent you
Okay, I see we received a unit_amount of 0 for "Listing Fee - 1989 Anziel 39" 🤔
Ok I am an idiot
I just checked and apparently I kept my edit code that always passes a 0 for that the same as my code that I'm meant to be using for this 🤦♂️
Sorry about that
All good, no worries!
Amazing what a second pair of eyes does for you
Glad you found the culprit
Thanks mate, while I've got you quick can I ask another quick question?
sure!
Promise this one doesn't involve my own gremlins
Is there an easy way of closing a checkout session from the API?
You can expire a Session, yep: https://stripe.com/docs/api/checkout/sessions/expire
If a customer has already paid and the Checkout Session has transitioned to succeeded, it's not possible to expire the session
Ahh so I'm guessing in that case it would just return an error?
that's right
you too!
thanks