Dj-stripe: Documentation request: Stripe Checkout example usage

Created on 27 Feb 2020  路  4Comments  路  Source: dj-stripe/dj-stripe

Can we get an example in the docs showing how to use Stripe Checkout with djstripe?

djstripe claims Stripe Checkout support but it's not intuitive to integrate. Trying to figure it out without docs, I'm getting new djstripe.models.Customers instances created via webhook at every transaction, none of which are associated with the django.contrib.auth.models.User that initiated the transaction.

stripe.checkout.Session offers an optional client_reference_id field which looks like a good option for mapping Customers to Users, but it doesn't appear to be djstripe's recommended approach.

Looked into djstripe.models.checkout.Session instead of stripe.checkout.Session: the only documentation I could find regarding djstripe.models.checkout.Session suggests not directly creating it at all (ref: issue #1043 ), instead recommending stripe.checkout.Session followed by djstripe's Session.sync_from_stripe_data(stripe_sess) -- though it's unclear why that's necessary, and whether it should be called on a checkout_success page or as part of a custom checkout.session.completed webhook.

Overall, there not enough documented to feel comfortable with djstripe's Checkout support without diving into all the code.

Semi-related: appreciate the great work on djstripe overall. Checkout's currently a bumpy experience, but the project overall is impressive and I'm grateful to everyone supporting it.

Edit: Got Checkout working successfully following an approach similar to the one recommended in #1043: get_or_creating a Customer instance and passing the customer.id to a stripe.checkout.Session. Everything else fell into place beautifully after that. Not sure I'm the best person to be contributing recommended usage examples to the docs yet, but this approach does appear stable and to work well.

documentation

Most helpful comment

+1 on this. Subscriptions created using Stripe Checkout are syncing to dj-stripe via webhooks, but not clear on how to sync single checkout sessions to a dj stripe model (e.g containing line_items and payment_intent_data)

All 4 comments

+1 on this. Subscriptions created using Stripe Checkout are syncing to dj-stripe via webhooks, but not clear on how to sync single checkout sessions to a dj stripe model (e.g containing line_items and payment_intent_data)

@anuzis Could you post a full example on how you got it working? A flowchart with the HTTP flow between Django and Stripe would be useful. What objects are created in the DB during a checkout session?

@danihodovic I ended up switching away from Stripe Checkout to reduce the purchase funnel by 1 click while having more control over the pre-purchase UX. It was a good learning experience getting Stripe Checkout working with djstripe, but I don't have a great example of the code anymore. Your best bet is probably the workaround from #1043 -- good luck.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mbaragiola picture mbaragiola  路  4Comments

lskillen picture lskillen  路  4Comments

Copser picture Copser  路  6Comments

allthetime picture allthetime  路  7Comments

therefromhere picture therefromhere  路  4Comments