#2clutch - checkout session

1 messages ยท Page 1 of 1 (latest)

robust prawn
#

or event ID

boreal crag
#

cs_test_a1IT7ANxUoqj8eg8XNltEVdcj07ZwQYcim5vfluRm6f4TRDh7cqocajLzT

#
{
  "id": "cs_test_a1IT7ANxUoqj8eg8XNltEVdcj07ZwQYcim5vfluRm6f4TRDh7cqocajLzT",
  "object": "checkout.session",
  "after_expiration": null,
  "allow_promotion_codes": null,
  "amount_subtotal": 5000,
  "amount_total": 5000,
  "automatic_tax": {
    "enabled": false,
    "status": null
  },
#

but as you can above, amount in the request response reads 5000 when it should be reading 50

robust prawn
#

Stripe's amount units are in the smallest unit for the currency, so in USD that is in cents, not dollars

#

in USD that means $50.00

burnt frostBOT
#

This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact

sharp forge
#

๐Ÿ‘‹ What's the question you still need answered?

boreal crag
#

customer is empty and my understanding is that it's supposed to have the customer_id

#

what am i misunderstanding about the flow?

#
"billing_address_collection": null,
  "cancel_url": "https://www.google.com/",
  "client_reference_id": null,
  "consent": null,
  "consent_collection": null,
  "currency": "usd",
  "customer": null,
  "customer_creation": "always",
  "customer_details": {
    "email": "test@vitelhealth.com",
    "phone": null,
    "tax_exempt": null,
    "tax_ids": null
  },
#

to give you context of what i'm talking about

sharp forge
#

Where are you getting back the null customer? Right after creating the Checkout Session? Or after retrieving the Customer Session after it's been compelted?

boreal crag
#

this is right after creating the session

sharp forge
#

Are you passing in a customer when you create the Checkout Session? If not, then getting a null customer right after creation is expected. The customer won't be created until they've actually completed the checkout flow

boreal crag
#

what would be the most efficient way to retrieve the customer_id right after the checkout flow has been successfully completed?

sharp forge
#

If you're listening for the checkout.session.completed event, customer should be populated on the Checkout Session returned there. If you're relying on being redirected to the success URL you'd simply retrieve the Checkout Session after being redirected and get it from there

boreal crag
#

do you mind rephrasing the second option?

#

sounds like the first option would be to setup a webhook?

sharp forge
#

After a Checkout Session is successfully completed the customer will be redirected to the success URL you passed in during creation. This should be a page on your site, and you can build something into your integration so that when a user hits that success page you retrieve the Checkout Session (we go into detail about that here https://stripe.com/docs/payments/checkout/custom-success-page)

boreal crag
#
session = stripe.checkout.Session.create(
  success_url="http://yoursite.com/order/success",
  success_url="http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",
  # other options...,
)
#

for the snippet above, why do i need to pass 2 urls?

sharp forge
#

You should only be passing one - the doc I sent over had one highlighted in red, and the other in green to indicate you delete the first line and replace it with the second

boreal crag
#

i see

#

i'm confused about the transition from step 1 to step 2

#

step 2 being the success page.

#

since the transaction is being handled by stripe, how do i pickup that the transaction has been succesful?

#

conceptually

sharp forge
#

You'd only be redirected t your success page if the transaction is succesful, and from there you can re-retrieve the Checkout Session to double check it has a successful status

boreal crag
#

okay.

#

can you please this open the weekend? i'll run some tests and if i have follow up questions, i'll add them and you can get back to me on Monday.

#

would that work?

sharp forge
#

I'm going to be locking this thread when I leave for the day, but you're welcome to come back Monday and ask us to reopen - we don't leave threads open here if there's no one online on our end to actively be helping

boreal crag
#

sounds like a plan.

#

thank you!