#salim_paymentelement-save
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1289274229786677268
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- salim-bt_docs, 3 hours ago, 12 messages
- salim-bt_key-secret-confusion, 23 hours ago, 30 messages
- salim-bt_docs, 1 day ago, 34 messages
- salim-bt_docs, 3 days ago, 22 messages
- salim-bt_docs, 6 days ago, 86 messages
Hi ๐
How are you creating the Subscriptions?
Both we have subscriptions and onetime
Sorry but that is not an answer to my question
What is the exact API call you are making to create a Subscription?
Can you share the code?
hello
i am trying to use payment element.
paymentElement.value = elements2.value.create('payment')
paymentElement.value.mount('#payment-element')
Q, is it possible get credit card details? What i want to do: get credit card details to attach credit card to user
Okay that is an entirely different question.
Can you explain in clear steps, what the user flow is? Are you charging the user as part of this action? Are you just collecting the payment method information?
Only collecting the payment method information
before payment element I was trying to use express checkout to create sub. Flow with express checkout was like that:
- insert stripe script, initializing stripe instance using publish key
- render express checkout
- creating payment method, getting pm id to pass it to backend and attach payment card
- creating sub
but to create payment method manually, need set paymentMethodCreation: 'manual' where amazon pay not works
support said, there is a way to not create payment method manually, and to not attach payment method before subscription creation. But this way not suits for us for now.
so i am trying use payment element, to create payment method and attach pm id to user
one moment i will record video
Let's stop right here
There is a simple and straightforward way to save a payment method to a Customer using the Payment Element
We have a step by step guide with example code you can review here:
https://docs.stripe.com/payments/save-and-reuse
salim_paymentelement-save
what if CUSTOMER_ID not exists yet?
the easiest is create the Customer upfront in that case. But otherwise you can remove that parameter and later attach the PaymentMethod
this way will work correcly with google pay and amazon pay and with subscriptions?
If you are doing Subscriptions, you should follow a guide focused on Subscriptions instead
this solution involves using a separated window - checkout, right?
That guide has multiple tabs that shows various options.
There are dozens of ways to integrate our products and APIs. The first step is to pick what product(s) you want to use and then pick the right type of integration for it
unfortunately checkout as separated page or window doesn't suit us
Step 1: what product do you want to use
=> you are now saying you want Subscriptions. That changes the entire integration path. So is that correct?
we are using subscriptions
we used payment request button component before
now because, suggested migrate from payment request button component, we are trying migrate to express checkout
but we faced problem with it, so now i trying use payment element
What problem did you face with it? ExpressCheckoutElement works totally fine with Subscriptions
No sorry
first issues with express checkout are:
- not found way how get selected credit card data from express checkout
i need get selected credit card to check, if this card was already attached to user or not.
- If card has been attached, i need just run request to backend to set this card as default
- If card has NOT been attached, i need get card data from express checkout, pass it to backend, to create and attach this card. But i have not found way how to get selected credit card data from express checkout. So i creating payment method from frontend using stripe.createPaymentMethod(). Then i am getting pm id and passing it to backend, so backend attach this card.
You should be able to summarize the problem in a couple sentences.
Overall using PaymentElement is fine too. But right now I don't get where you are confused
Gotcha, that's a good summary. It's really uncommon to show ExpressCheckoutElement to get a PaymentMEthod and then check if it's the same as before
Sorry it does look like you went down multiple rabbit holes and are trying to force your integration to something else
we need to pass the card data from express checkout to the backend to create and attach the card.
Since I couldnโt retrieve the card data from express checkout, Iโm currently creating the payment method on the frontend using stripe.createPaymentMethod(). After obtaining the payment method ID, I pass it to the backend to attach the card.
Stripe Payment Method Creation Issue: Unfortunately, I encountered a second issue: stripe.createPaymentMethod() does not work unless the paymentMethodCreation: 'manual' setting is applied. However, when this setting is enabled, the Amazon Pay button fails to render.
we found out, that with paymentMethodCreation: 'manual' amazon pay not works
Since I couldnโt retrieve the card data from express checkout, Iโm currently creating the payment method on the frontend
that's not a "hack" though. That is exactly what you are supposed/expected to do.
However, when this setting is enabled, the Amazon Pay button fails to render.
Correct, AmazonPay doesn't support this
because of that, i am tring payment element
Gotcha, so what isn't working with PaymentElement?
main goal is to attach payment method to user, before subscription creation
Yeah that is not a good flow, that's a really bad idea/approach. That's what I am trying to explain.
Why do you absolutely want to attach the PaymentMethod first? Is it a misunderstanding of our API? Or is it a hard requirement of your integration? Or something else?
it a hard requirement of backend logic, because most of logic located at backend. From frontend i only attaches payment method, and run subscription creation request to backend
Okay, so even though it is a really poor integration approach you absolutely want to use it?
we found out that there is a way to create sub without attaching pm before sub creation
but seems like we can't create subscription without attached payment method
or we need change backend logic and create subscription without attached payment method?
yes if you can change your backend logic it'd be much better
That lets you do this
- Collect PaymentMethod client-side
- Go to your server, create the Customer and then create the Subscription with that PaymentMethod
- If needed, handle any next action such as 3D Secure, client-side
can you describe please, why our approach is not good?
i mean creating sub without attached payment method
Try to follow my doc end to end
so in this step we need create subscription only with payment_behavior: 'default_incomplete' parameter, right?
yes!
it means payment method will be attached to customer automically, right?
can you answer please, i need convince lead developer
as i understood, he wants to reduce the number of requests
Auto-confirm the Payment Intent in a single request?
Sorry that's still super cryptic. The PaymentIntent has to come from somewhere, which means you already created the Subscription in the first place right?
This is quite subtle and there are literally 20+ ways of integrating Subscriptions and PaymentElement. Can I ask you to be as clear and crisp as possible about the exact sequence of API requests?
Really what I shared is the right canonical way to do this, it's the best one
Yeah that flow is if you do not use Subscriptions though. I asked earlier and you said you absolutely use them.
we use them both subscriptions and onetime
.
payment intent for onetime only
Okay, and we were talking about Subscriptions. But you then talked about "auto-confirmation" and then creating a PaymentIntent and now say it's for one-time payment only
So if we focus on recurring payments and you use Subscriptions, then what I said above is the right flow
ok what about onetime?
One-time works completely differently though the idea is similar. But we can't really talk about every single part all at once while you;re confused. We should solely focus on one specific flow first.
ok thanks got it
I can definitely explain both as we go. But I want to make sure we do one at a time as you're two people in the thread and asking different questions
@swift gulch you can write.
The official flow is what I wrote earlier
- Collect PaymentMethod client-side
- Go to your server, create the Customer and then create the Subscription with that PaymentMethod
- If needed, handle any next action such as 3D Secure, client-side
if we go to suggested way of using subscriptions, we need also take care about onetime purchase. Sorry, i didn't mentioned onetime before.
It's fine, and it all will work. But it's tricky as you ask questions and then you ask them to Salim I think.
I can't really answer every questions all at once. There are dozens of ways to integrate. And some of the things you do definitely seem completely wrong right now. But I barely understand your expected flow. Can one of you clearly outline the sequence of exact API Requests you do in one clear message?
we are both with Salim trying figure out what approach we need use to not break current subscriptions and onetime, to convince lead developer change backend logic, if it is wrong
thats can do only backend developer. At frontend i just attaching payment method to customer
Sorry, you're giving me half answers each time
It's really hard to help you with vague answers unfortunately ๐ฆ
Can the lead developer just come and ask their questions instead? ๐
good idea
ok then another time
thank you for your support
๐
To be clear though the right flow is https://docs.stripe.com/payments/accept-a-payment-deferred and it works fine for both one-time payment and recurring payments
so, in both cases we don't need attach payment method before subscription creation, right?
correct.
This flow is newer (launched last year) and much better and definitely what I would recommend.
In both cases you end up with a PaymentIntent. Either one you created (one-time) or one Stripe created (through a Subscription) and then you confirm it with the PaymentMethod id pm_123 and if the payment succeeds it can attach the PaymentMethod to the Customer for future use
got it, thank you very much!
sure thing!
ah, another Q
we definetly need use payment elements, instead of express checkout?
If you want AmazonPay then I'd say yes.
amazon pay will not work with express checkout?
We already went through this earlier and you're the one who said it doesn't work specifically when you pass paymentMethodCreation
What way should we use, if we want use express checkout, but without manual payment method creation?
It doesn't appear that flow is supported for amazon pay
However, it looks like you're using createPaymentMethod -- its possible that this requires using createConfirmationToken. Have you tried that?
we used createPaymentMethod to get pm id and attach payment method, before subscription creation
Yea, you can't do that, you need to use confirmation tokens to carry the confirmation intent forward
but @carmine slate suggested to no attach pm before subscription creation
Right, you can either do that (simpler, but no ability to inspect payment details before confirmation) or you can switch to confirmation tokens to keep that interim step if required, and use the confirmation token to confirm the payment (one time or on the subscription).
If you don't explicitly need that in between step, i woul recommend eliminating it and confirming from the client directly, using the deferred patterns shared
in general the best way for us is:
- don't attach pm before subscription creation
- use express checkout without manuall payment creation using confirmation tokens
in this way, we will have working gpay, apple pay, amazon pay, am i right?
That is my understanding, yes, but you should try it out and let us know what works or doesnt!
Do you explicitly require the interim step to inspect the PM details?
If not, i would reocmmend option 1
using express checkout flow, payment method will be attached to user automatically?
If you use it to start a subscription, or your payment intent uses setup_future_usage yes
(customer, specifically, i assume you mean user=customer)
what better to use, payment elements with suggested @koopajah way, or using express checkout
I expect both should work, so its really up to your preference.