#techsheepdog-intents
1 messages ยท Page 1 of 1 (latest)
Hello, very sorry to hear that our docs are giving your screen reader trouble. Yes, saving payment methods with our modern API involves either a Payment Intent or a Setup Intent. If you create a paid subscription, it will generate invoice objects that themselves generate payment intents. For subscriptions without an immediate payment, we will generate a setup intent that you can confirm to save the payment method. If reading just one doc section is feasible for you, this step in this doc outlines how to use the payment intent that a subscription generates to collect payment details from a user with Stripe Elements https://docs.stripe.com/billing/subscriptions/build-subscriptions?ui=elements#collect-payment
What is the purpose of this intent?
I'm trying to create apple-like functionality where somebody can simply store a payment method and we can charge them as needed for services. I want to be able to create subscriptions that will be repeating but I also need the ability to do one time payments when they want to download premium content or purchase physical items. This seems harder than it needs to be and the amount of custom code needed seems excessive. Is all this custom code needed?
I'm also trying to make it so that I can support multiple types of subscriptions based on the different content.
I dont understand stripe elements and it seems to be a third party solution?
We are already using stripe dot JS but it's not working
Stripe Elements is first party, we develop it directly.
Intents are state machines to track potentially multiple attempts to make a payment or set up a card. Otherwise you would need to build your own logic to track those attempts yourself
It gives us back a credit card payment method token that we can't attach to the client customer because of this intent stuff
Unfortunately understanding thsi would take reading those verbose docs. It may make more sense for you to use a lower code solution like Stripe Checkout
The error message says to create an intent but we're trying to just store a payment method so we can bill it later there is no intent to purchase something at the moment
The intent will attach the payment method to the customer automatically once it is confirmed
I think the bigger issue here is the fact that DJ-stripe isn't getting any maintenence so we have to roll our own
That does not sound like a Stripe error, can you send me the ID of a request that you got that error from? (req_123)
That was yesterday and the screen that loaded is long gone
it was a stripe error though
we got it from trying to add a payment method to a customer
using the token we got back from stripe,js using a public key to try to add a billing payment method
the error mentioned intents and led us down this rabbit hole
failing code was
if customer:
customer.add_payment_method(payment_method_token)
where customer is a stripe customer object
๐ Stepping in for my teammate. Just caught up on the message history
Do you happen to have the customer ID you used when this error was returned? I can try to work from that to find the failed request.
techsheepdog-intents
I'm sstill waiting on mfa to access my stripe account its not being sent
the code is not being sent, why?
it says it sent me a code but no code was sent. The last one I was sent is on 1/24. I'm not able to get into my account to check. This is dumb.
I see. We can't help with login issues here
Here's what I recommend:
- Check in with our support team for help with logging in to your account. They may ask you for more details before they can reset any MFA settings. Since you can't log in, I recommend filling out this form to get in touch with them: https://support.stripe.com/contact/email
- If you have any sort of object ID (a customer, a payment intent) that you've logged somewhere from your previous attempts, please share it here.
ok, just got all of them at once
If you don't have an object ID logged somewhere at this time, I recommend working with support first and then returning to #dev-help for help
Ooh, gotcha!
I'm logged into my striped dashboard and I can't even find the errors page because it's not very blind friendly
but I only have the one customer in it atm
its a dev account
cus_Pd5CxeacjX6Jzq
That was from the creation of the error in question I think
the flow created the customer and tried to add a billing method and we got a token back but then when the token was used to attempt to add it to the customer that call raised an exception and failed
ok found it
"invalid_request_error - payment_method
A token may not be passed in as a PaymentMethod. Instead, create a PaymentMethod or convert your token to a PaymentMethod by setting the card[token] parameter to to <token>"
I found intents trying to look that error up
looks like you have the full request/response log here
its just hard to get to
Another issue is we are using dj-stripe but its not an easy solution to work with
the docs are not the greatest but thy re easier to access than the stripe docs
I wish I knew the minimal solution that did what I needed. I just want to be like Apple and store billing methods in a secure way so peoople can use them for billing easily and we can make the flow as frictionless as possible. Our goal is one button and a confirmation they agree to stripe terms etc to start a subscription after billing data is set up. It would be better to do it the first time as low friction as possible, and we are worried about having to write the code for cancels, updating the billing method used by a subscription if it expires in the middle, etc.
but the stripe.js ui isnt accessable and doesnt respect our WCAG requirments either so thats an issue
When making your own custom webpage, saving a payment method typically works like this
1 Your backend creates the payment intent or setup intent
2 The intent's client secret is passed to the client side
3 Your custom page uses Stripe.js's payment element to confirm the intent's client secret.
so using stripe elements would mean less accessibility is my understanding
We make sure Stripe.js is accessible. If you are having specific issues with your screenreader you can reach out to https://support.stripe.com/?contact=true
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.
its not just screenreaders its dark mode verses light mode
and all attempts to contact stripe about this in the past have resulted in no resolution
just "we will take this as feedback"
and no tickets or follow up
To keep Stripe.js secure, we do have to manually control how tab indexes work. So many automated accessibility checkers fail us but it should work as expected for most screenreaders
You can request a followup ticket like that if you want. We do try to make our docs and products accessible and test them across multiple screen readers, but I cannot speak to how well it actually works for most users and obviously you have more experience with this than I do
I have tried they refuse, support hears I'm blind, sighs because they dont want to deal, and they become disengaged and try to pass me on
or at least thats how it has historically been
I've been writing code for over 25 years, the features for our app while difficult for some are easy, working with stripe and the API is the hardest part
its just a giant dark empty hole with no context and everything I know is from third parties or cached google pages
or old tutorials that generally no longer work
I've worked at Microsoft research and Amazon and other big name tech companies so I'm not an idiot (I hope) but the lack of data on the stripe API makes it one of the more complicated solutions I've ever used for billing and I remember the old school stuff that banks used to require.
Where can I find a succinct example of how to add a new billing method to a customer so I can bill it later for physical goods, digital products, and monthly subscriptions ?
Is there a process flow map on all of this somewhere?
I really wish I could just understand the entire process flow and had a directed acrylic graph of operations that I could map to figure out what I need to do to do what I want to do
I'll see what docs we have that are more succinct but unfortunately these are fairly complex APIs, so even our simpler docs have a good amount of relevant context
This doc is a high level overview of payment intents https://docs.stripe.com/payments/paymentintents/lifecycle
That's my point the APIs seem overly complicated for what they do. It feels like stripe is trying to compete with everybody who uses them, even link is its own website and that creates friction and harms our ability to make things seamless like apple
I'm confused by that intents page
Unfortunately I can't speak to our design philosphy and how that may conflict with yours. We try to make them simple and understandable, but as you have experienced on both, that effort does not necessarily mean they are easy and understandable
I dont have a product or know an amount to charge when I want them to set up billing the first time. I just want to collect a cc and add it to the account so I can validate they have a billing method on file we can use. I expect to charge them later for different things when they opt into it but until they click the button I wont have that data.
In that case, you will want to use a SetupIntent without a subscription. I do think we have some relatively straightforward docs for that
The flow we have is -> register on website -> validate email -> add billing method -> use website -> opt into subscriptions or buy digital goods
but the idea is that once they have a billing method they are a customer and we should be able to bill at any time, we want to go for single click Amazon/Apple like functionality
This doc outlines how to use a SetupIntent and Elements to save a payment method to a customer https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
And here is the simple overview of how SetupIntents work
https://docs.stripe.com/payments/setupintents/lifecycle
are any of these resources available to screenreaders without lots of iframes and other accessability issues?
Those are the only versions of those docs that I am aware of unfortunately.
The iframes should only be for the Stripe.js demo as far as I am aware, though I am not sure how the tabs + iframes work in that context. Are there other iframes on that page that throw your reader off?
I will raise this to the docs team as well
Is this available without the bright white background that creates migraines? dark mode is an accessability issue but I cant find it on your website and even though my system is set t dark mode so I can use my one single eye to its full potential, I'm getting a headache just looking at the pages and so I'm forced to use my reader but its having trouble with the iframes etc
its so bright its painful
this is why dark mode support for payments is so important for us
and why the stripe ui elements stuff doesnt fit our needs
its painful to use
And out of respect I want to be clear here that when I say "painful to use" I don't mean "annoying" or "complicated" or "more effort than I like", I'm Speaking of pure physical pain that damages me physically.
We have an appearance API that lets you change the color and appearance of our Elements components https://docs.stripe.com/elements/appearance-api
Thank you that's new but it doesn't seem to natively support bootstrap themes so it's going to be more work on top of everything else
Unfortunately it does not look like we have anything built in for our docs at docs.stripe.com
For some reason we do have light and dark mode for our API reference, but not our main docs. I will put in feedback for this.
For now, there are plugins for most browsers that can do dark mode for sites that don't officially support it, though I am not sure how well those would play with screen readers.
they dont play nice
most work by injecting css in different orders but that often removez z ordering etc
so sr-only tags can be broken
in general, iframes are evil
as well
please remove all iframes from the docs
every single iframe is a defect in terms of accessability tbh
Unfortunately I am not finding another format for those docs that supports dark mode. I am happy to walk through as much as I can of the process of how to save a payment method and create a subscription, but unfortunately I don't think we have docs of a kind that you have not run in to yet.
I will flag that iframe piece to our docs team as well.
thank you, I just wish sighted people cared more about this stuff
Do I have to create the product in advance in stripe? We wanted to have our own product catalog and having to manage multiple copies of that using the stripe api is extra work that makes it that much harder to use stripe, not to mention a lot of extra cost
Me as well, I am very sorry for how your experience with our docs has been.
Also I am not sure how helpful these may be to you but we do have sample integration projects on GitHub. They are usually pretty straightforward in how they demonstrate. https://github.com/stripe-samples
we use django in python and the dj-stripe project looks abandoned
its creating a lot of worry
and its really hard to get started, hence why I am here
Products are required for subscriptions. So you will need a product object for each product that you want to charge for with a subscription
there are forces at the company who are trying to get us to use braintree or another provider instead due to these issues
We would rather manage these in the typical product catalog, are you saying we need to copy that bulk into stripe? Thats a lot of extra work and cost. And what is the privacy of that? People are saying that stripe collects all this extra over and beyond information because they sell it to people for competitive intelligence/advertising, and that's an issue for us if that's true. Is it?
Stripe subscriptions require the ID of a Stripe product object. Products can be made and managed via our API, so that may make it easier for your to handle which of your products map to a product ID in Stripe.
But if I'm doing digital products for example, does that mean I need to create a separate product for every possible thing, or can I just be like "this is a generic digital product that happens to be a rental" here's your price calculated at checkout, done?
because digital products are never sold, they are licensed
Unfortunately I am not familiar with what data, if any, is collected in that scenario. We have a doc that outlines our privacy policy here (warning: no night mode). You can reach out to our support team for more specific information on what information we collect in your scenario
https://stripe.com/legal/privacy-center
https://support.stripe.com/?contact=true
In Stripe, products are used to represent each unique thing that you sell. You would only need to create one product per type of subscription
I think my biggest issue with this is that it's really hard for me to learn about this because of the lack of accessibility and so because of that I find myself more scared because I'm more ignorant
It also seems like this is a very complicated process for something that should be really simple. And all the out of date stuff online doesn't help because I feel like I'm looking at different versions of the same thing and what's different from the thing that I tried that did not work isn't clear
That is understandable, especially if our standard docs.stripe.com docs are inaccessible for you. I also feel you on the complication in some ways but I can only advise on the API that we have right now
Do you have further questions about how to use our APIs here?
the docs you have directed me to are so bright, I'm sitting here crying. I cant read them. Will this thread stay open so I can collect links?
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements isnt clear about how to get this client site secret, is it the stripe publishable key? or something else? the example makes it seem far more global than a per customer or per payment method secret and the examples are non-functional
We typically close out threads after ~20 mins of inactivity but the info in the thread will stay here and we can always open a new thread if you post in the main channel.
the docs are a lot of "this is what you would do" but it has such huge gaps they are not useful
for example:
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/secret')
def secret():
intent = # ... Create or retrieve the SetupIntent
return jsonify(client_secret=intent.client_secret)
This code is useless. How do I set up the intent? The important part iis missing
it also directs me as a dev to consider this a global scope secret
due to the endpoint having no params
A client secret is part of a payment intent or setup intent. They are separate from your public key, basically you create an intent, get the client intent string from their client_intent property, and send that to your client side code.
What doc is that code from?
the single page app tab
python code
section Retrieve the client secret
but all of them are like this
its a common problem with the docs
they are like a ceo, they are verbose and say a lot but often have nothing of importance to developers to say
and the bit I want is often missing
๐ That's fair, unfortunately it's hard to have docs that perfectly caters to everyone's own preference of help. We're happy to help if you have clear and specific questions about what you are trying to do though.
Where I don't understand this why I can't find a working example of what I want to do given that the use case I have is from my perspective the most common and useful one
I admit I might be biased ๐
but this seems like a common scenario
yeah I think that's mostly it. Like it's reasonable to want to get your exact perfect example all ready and built just for you. But there are dozens of ways to integrate our products and APIs. We have pretty good docs and examples but they aren't perfect.
So let's ignore the perfection for now and focus on exact clear questions you have so taht we can help you!
Well in a nutshell what I'm trying to do is I'm simply trying to get to a point where every user in the system is a customer in stripe, and every customer can freely manage their billing methods, set one as default, or list their billing information to see what we have, when it was added, while at the same time highlightin about to expire cards, warning of expiring cards in advance, and dealing with payment for subscriptions that might have a card attached to them expire while respecting that that they want to continue that subscription at the current rate without creating a new subscription (just using the new card they replaced tthe expired card with in that scenerio) while also respecting their ability to freely unsubscribe from the subscription at anytime with a click of a button.
I want the amazon/apple experience
One thing I've noticed is that with Amazon and apple if I have a subscription and the card I'm using for that subscriiption expires, they allow me to remove the bad card and have the subscription be active for the billing term and then on the next billing cycle use the new billing method that I add to the account when I add a new card that isn't expired, and I'm able to continue the subscription without having to create it again but I can't find anything about that in the stripe docs at all
I'm sorry a lot of this is super high level and meta unfortunately. Can you try and pause on the meta parts and solely focus on one exact and clear question that you are stuck on, with the exact code you already have and what is blocking you?
It's really important to focus on real questions and not "I want to be like Amazon" for now
Ok first one. In simple terms:
1.A) How do I attach a new billing method to a customer that will allow me to use a "setup intent?" to allow that card to be used for any future invoices? For subscriptions or one time payments?
1.B) . When I set my first payment method on a customer, how do I set that as the default payment method for all future customer billing (subscriptions or one time purchses) with the expectation that they are free to add other payment methods or manage payment methods as they like, but by default, it will be the one used for billing?
Okay so the first question doesn't really make sense at all with our current vocabulary. A SetupIntent is explicitly used to specifically collect new payment method details for future payments. So it doesn't make sense to "attach a payment method to then use with SetupIntents
OK so in non stripe vocabulary I just want to add a credit card to somebody's account to bill it later, but I dont know yet what for or how much it will cost because validating billing information is required to activate the account
Cool so you want https://docs.stripe.com/payments/save-and-reuse
the idea is they need a valid billing method on thier account to continue
wait now you said something slightly different that might change everything!
what does "continue" mean? Like the next UI screen you charge them?
No. They won't get to the opportunity to buy anything or get into a subscription until later when they access the digital market on th website, but simply having that information on their account will enable free services that people without it wont have access to. I might want to charge a fee later to do identity validation, sure, but I figure once they buy something if the name on the card matches the other name data they gave me in my account signup, I can validate them as at least claiming to have a name that matches the name used on a billing method they used, right? The bulk of the service will be membership based and that will require different subscriptions and one time purchases but those will change over time. Think Uber or Instacart in that the service doesn't really work unless they have a valid billing method.
But I still want them to be able to get a "free" account and login, contact support about billing, etc
My general goal with the service is that people will strongly validate their identity as much as possible, and from a business perspective I want to mitigate the risk of alt and throwaway accounts by requiring billing data and other strong validations of identity to qualify for access to some features, both to meet regulatory requirements but also be more customer focused.
The big one for me is the membership subscription, but its not an immediate thing
And they might decide to only pay for a month in advance as a single time payment
So I can't make assumptions about how the billing payment method will be used
Okay so overall you want that doc I shared (also there's no "verify a card name")
If I limit a payment method to only credit cards and look at the API is there a way for me to get the name on a card so I can validate that the first and last name on the card matches the registered user's account first and last in an automated way by doing a simple string comparison? The idea would be that I'd be able to track this in an automated way so I could have an automated system tell me that an account has for example had three months of successful payments with the name matching the billing information.
I wish I had an identity validation API but I can't find one
We don't collect card name ourselves. If you want the name you'd collect it yourself. If you do, you have it, can store it in your own database and do the comparison you want.
It will prove nothing honestly so I am not sure what value you would gain from verifying this value
I guess in simple terms I'm trying to follow "know your customer" rules as much as possible
yeah there's isn't any of this for people paying you
To be honest I don't want the risk of collecting credit card data if I can help it I would rather send that request to your server and get back a token that I can somehow attach to the customer so that later on they can simply list this payment method as one on their account and manage it appropriately
yeah sorry you are staying really "meta" and high level and not getting in the weeds of a real integration. It's really hard to help with theory
The problem is that seems to be a really difficult task as managing payment system information with stripe has taken a month of my time so far and we still have no working solution
It is extremely simple to do this honestly. I help a lot of people do this in like an hour at most and be all done
What am I missing? Besides sight?
The easiest approach: Use Checkout which is our hosted payment form. Let us collect all card details for you end to end automatically. You can configure Checkout to work for one-time payments, recurring payments, or just collecting card details upfront for future payments (that last bit is what you want)
I think what you are missing right now is you got lost in our docs and haven't understood where to start. Which is totally reasonable, it can be overwhelming. I work at Stripe so I know our products inside out myself so it's easy for me.
Really to start I would do Checkout like I just said above. Have you seen Checkout before?
Wait how does checkout relate to elements and the API is it a separate solution? There seems to be so many different things and to be honest that's causing a lot of confusion
yeah that's the problem right now
Checkout: easy prebuilt hosted payment form to handle everything for you off your website.
Elements: UI library of various components to build your entire payment form yourself (and more) on your own website.
I would highly recommend Checkout, at the very least to get a prototype running in an hour! You can always move to Elements after (which is extremely easy too once you know where to start)
If I understand what we have so far correctly we actually might be using a checked out thing
99% sure you aren't since you mentioned Elements, SetupIntent and client_secret
checkout_session = stripe.checkout.Session.create(
client_reference_id=user_id,
success_url=full_success_url,
cancel_url=base_cancel_url_endpoint,
payment_method_types=["card"],
mode="payment",
currency="usd",
line_items=[
{
"name": "T-shirt",
"quantity": 1,
"currency": "usd",
"amount": "2000",
}
],
)
๐ so you are, so then what the heck lol
as an example of the api usage
Well this is Checkout for accepting a $20 USD payment for a t-shirt. I thought you wanted no payment upfront?
cool then all you change is
- remove
line_items - change
modetosetup
we cant get working due t lacking billing payment methods so we wanted to tackle that first
wait
so this sigle api is used for multiple things? Its overloaded?
other people in the chat said to use elements
and that created accessability issues
I don't know what you mean by "overloaded". Usually that can be a negative term.
Checkout is a product, that product lets you do multiple different things. One of those things is to collect payment method details for future payments yes
so we went back to basics and tried to make a payment method management system of a few pages, one to list customer payment methods attached to the account, one to add a new one to the customers account, one to delete a single one from the customers account, but we are stuck on adding ...
Sure but right now we spent a while together and are still in the "meta problems" and nothing really clear or spcific. I can help you but I need you to take a step back or two from the frustration and all you tried and ask a clear actionable question at this point.
Really Checkout is the recommended way. That's what I would use if I were in front of your computer.
so https://docs.stripe.com/payments/save-and-reuse is not checkout?
That's a URL. That URL links to many different ways to integrate the feature of "collect payment method details for future payments".
At the top of that page there are "selectors" that can be used to choose which approach to take based on criteria such as whether you are building a web app or an iOS app for example and then which product to use (Checkout, Elements, something else, etc.)
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=checkout this URL will pre-select "website" and "Checkout" and have exact instructions on how to use Checkout for this
But really in Python it's as simple as
1/ Create a Checkout Session for mode: 'setup'
mode="setup",
currency="usd",
customer="cus_123456",
success_url="https://example.com/success?session_id={CHECKOUT_SESSION_ID}",
)```
2/ Redirect the customer to the URL of Checkout via `checkout_session.url`
But checkout is asking for things like email etc?
at least in the demo
I'm not initiating a setup yet but the docs have a demo link
Yes Checkout asks for email. You can prefill said email which you are likely collecting anyways
Really, don't overthink it. Use Checkout, integrate it in 20 minutes, be happy!
yes the thinking was prefill from user account data since at this stage its a validated email
oh dont overthink? Ouch. Thts my problem.
I'm confused and have been thinking hard on this.
I understand. But sadly you are wasting a lot of your time and energy over something that likely won't matter that much compared to everything else your business/website offers.
So again if you want to collect card details fast, Checkout is the way. There are many things you can change later. But right now you are completely stuck in place trying to do the easiest thing possible. So do the easiest thing, make it work, feel some momentum and once that works you can start thinking about some improvements (because there are a lot of viable alternatives we offer).
But that won't work until you at the very list do the first step to unblock yourself
So really take my advice, don't look at "demos" or "docs" and try to find the perfect answer.
Use the product in Test mode. Really using Checkout if you have some experience coding will take you 20 minutes at most end to end
I have a lot of experience coding. My issue is I keep tryng to read the docs, get a migrain from the brightness, have to stop, then need to stay productive so I end up using my screen reader to do something else
Sure so trust me here. Ignore the docs
I can get you there in 12 minutes if you work with me. Are you willing to do that now?
yes
Cool.
Step 1: Create a Checkout Session with the code I shared earlier.
Share the exact id cs_test_123 afterwards so I double check. Let me know once this is done and do only this step nothing else
@weary pewter do you have that id?
I'm trying to use that code you sent, I need to do some plumbing
You shouldn't need some plumbing in theory. I only asked to create a Checkout Session, nothing else, not even plumb it in your website. You should be able to write a one-off Python script that loads Stripe and only does this and nothing else
{"sessionId": "cs_test_c1wrv0faMQykI2JBdAswJoAAQeaEcbpzX71LKeOC5w6hqy23CfQWFBYTKp"}
looking
Okay perfect! so you are Getting that Checkout Session id and it worked
Note: You forced only card payments. Is this on purpose? It wasn't in my code example at least so making sure before the next step
checkout_session = stripe.checkout.Session.create(
client_reference_id=user_id,
customer=customer,
success_url=full_success_url,
cancel_url=base_cancel_url_endpoint,
payment_method_types=["card"],
mode="setup",
currency="usd",
)
removing that payment-methods_types
okay
So the next step: that Checkout Session has lots of properties, all documented on https://docs.stripe.com/api/checkout/sessions/object
One of them is the url property that contains the exact URL to send your end customer to
So now you need to change your code to redirect the customer to that URL. How to do this depends a lot on how you wrote the client-side code to trigger the Checkout Session
{"sessionId": "cs_test_c1daeAUGFHwfj1hFCFlUHArSvH4jMHsLVFRlDAc7JYRLD5a1jsnFaoGl9v"}
yep that one removed payment_method_types so it's great. Let's move to step 2
one bit of feedback; the checkout_session api page overrides control-f so it disables a screenreaders search
yeah let's ignore that for now. I hear you and I'd recommend a support ticket with all the "bugs" you found. But I'd like to get you to a working app right now
We recently added "types" to our stripe-python SDK so you can technically look in the SDK in VS Code or whatever IDE you use instead of the API Reference
wow ok was redirected
let me get you a session id can I get it from the url?
cs_test_c1piijXOF7zfI5iSRWHiuUyfW9WkG5MdXtZofk159fFx7xAL9kXOHTc790 - I think
okay so now you are on Checkout, and you should have an email field to enter and them some extra things like card details and such
yup
Step 3: complete the Checkout page entirely and get redirected back to your sucess_url
Let me know once you are back to that URL and share the exact URL
no that's the Checkout URL
I am asking the URL you are on after you are fully done filling out the whole page
"id": "cs_test_c1RBgOWqONr7ysjyfv0tXsctYPBFt4nxwWfauLBauYqki9qgJDqto4Wgoj"
oh ok
I set a success url, should I have not done so?
I can give yo the full checkout dictionary if you need it
Okay so this is the URL that the end customer goes back to after they are done filling it out Checkout.
So now, you write code that handles that redirect URL. That code would look at the Session and for example extract the Customer id, the card details, etc.
yeah our version says "paymnt successful" but in this case that makes no sense
import stripe
from django.conf import settings
from django.urls import reverse
from django.http.response import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import redirect
@csrf_exempt
def create_setup_session(request):
# Ensure the necessary data is present in the request
if not request.user.is_authenticated:
return JsonResponse({"error": "User is not authenticated."})
user_id = request.user.id
if not user_id:
return JsonResponse({"error": "User ID is not available."})
base_cancel_url_endpoint = request.build_absolute_uri(
reverse("payments_v0_cancelled")
)
base_success_url_endpoint = request.build_absolute_uri(
reverse("payments_v0_success")
)
full_success_url = (
f"{base_success_url_endpoint}" + "?session_id={CHECKOUT_SESSION_ID}"
)
if request.method == "GET":
stripe.api_key = settings.STRIPE_SECRET_KEY
try:
checkout_session = stripe.checkout.Session.create(
client_reference_id=user_id,
success_url=full_success_url,
cancel_url=base_cancel_url_endpoint,
mode="setup",
currency="usd",
)
print(checkout_session)
return redirect(checkout_session.url)
except Exception as e:
return JsonResponse({"error": str(e)})
I whipped this up to get this
yeah so fix that part of the code
its clearly not perfect but its a start
yeah now on that success url look at the Checkout Session and extract the information you want
Does that make sense overall? Because once you've done that step you're all set
ok success url looks required
yes since that's where we send the end customer back
ok so if I set the customer= manually to a customer id I pull from the stripe dashboard it shows my email filled in etc thanks
sure
I have a migraine and my eyes are watering like crazy but this is progress, thank you
does the payment method I add in this flow when I set a stripe customer get attached to the customer or do I need to do that seperately?
It gets attached to a Customer if you have created one upfront and attached it
And you will get the pm_12345 on the SetupIntent associated with that Checkout Session
yes in this case I manually set it to a param set from one in the stripe dashboard
cool so to me it looks like you're all set at this point ๐
You can rest a bit and try tomorrow and ask further questions (really specific if possible) and we can help further!
thank you