#elijahworkz
1 messages ยท Page 1 of 1 (latest)
Card Element with individual inputs (card, expire, cvv)
Gotcha
For your Subscriptions, are you using Charge Automatically?
As the payment_behavior
yes - the only thing we're doing is setting an offset for trial payments sometimes
everything else is default
here's our current flow in more detail... On client - we're getting PaymentMethod and send it to server along with an email that we ask for...
There we create a customer with that email, attach payment method and then create subscription...
what I'm not sure is where/how is to plugin the payment request button payment
I set requestPayerName: true, requestPayerEmail: true,
on paymentRequest
Hi ๐ I'm stepping in as @inland patio needs to go.
So you want to use the Payment Request Button in place of the Card Element to speed up the buying process?
not 'IN PLACE' but 'IN ADDITION TO' ๐
Alright
it came as business requirement and I'm trying to determine if it's possible without asking them for email first (what we currently do)
note: email is still required if they choose to use card elements
What is the functionality you are trying to get out of the request button?
from what I understand they don't want them to fill out the email (kind of a 'one click' solution)
we create a subscription and then fill out account information in the onboarding process
BUT we do need their email to send welcome message (which I was hoping to get by some api request for customer details) and we do need customer to create a subscription...
so the problem (question) is when/how to create a customer from PR button
Okay well when you create the button you are setting the correct request parameters so these details should be present on the Charge object (related to the Payment Intent) in the payment_method_details: https://stripe.com/docs/api/charges/object#charge_object-payment_method_details
Have you tested/investigated this?
You don't need to use the Charge object
In fact we don't recommend it. We recommend using the Payment Intent
But when you attempt to collect payment with a Payment Intent it generates a related Charge object.
You can access the latest_charge ID directly from the Payment Intent: https://stripe.com/docs/api/payment_intents/object#payment_intent_object-latest_charge
I don't generate PaymentIntent... We get paymentMethod.id from the client and use that to attach it to the customer
then we call subscription endpoint to create subscriptioin
I'm not sure if payment intent is generated automatically because we are looking for it in case of failed payment to send back to client
I'm a little confused about this flow
How are you generating a Subscription if you don't have a Customer yet?
in our current setup we do... on the client they fill out the form and it results in paymentMethod (we get it from stripe in client)
then we pass that to the server (along with email)
and the server creates customer, attaches payment method and tries to create subscription
the code we have was largely copied from and a demo subscription flow stripe had a couple of years back...
it's been on a backburner for all this time and now they want to revive the project with new additions
it works as expected in test environments - with failed cards, 3D secure scenarios etc...
What works in test environment? The PRB?
no.. the current setup without PRB
I'm just not sure how to plugin the PRB into what we already have ๐
If we change the flow to start the subscription process with a PaymentIntent (generate it on server on the first request) - will that simplify things?
Right, I'm not sure it will work with the flow you have.
Since you need a Payment Intent to create/mount the Payment Request Button
Well...wait you could use a Setup Intent
it actually mounts as it is now
What is "as it is"?
the buttons show up on the form
I'm passing the same paymentRequest as before
Just to clarify again - this is what I have on client now...
- I create a stripe.paymentRequest({})
- I use paymentRequest to create PRB
- I have
paymentRequest.on('paymentmethod'
that initiates subscription
Okay so you are just using the PRB to generate the Payment Method from a digital wallet?
I attached some of the code... I omitted the part where PRB buttons are generated as it's pretty much copied from the docs
Okay so what are you attempting to do that is not working as you expect?
when the click on PRB - I don't collect their email and it is not sent to the server
so all the flow I have on the server (create customer, attach PM, create subscription) is in question
how can I create/retrieve the customer if they clicked on PRB and I don't have an email to use
Just to give an example... this form also has PayPal button and I have a different flow for that
When you receive the Payment Method are you logging the object?
I'm only getting the ID from that object currently
I'm not sure how to test it with PRB
In your event handler, examine the Payment method
It should be the full Payment Method object: https://stripe.com/docs/api/payment_methods/object
Including the billing_details
Right, because the demo is focused on Payment Intents and is relatively simple
But your process is rather complex so we need to do a few extra steps
So in this case I don't need to change anything in my flow - I can get info I need from PM object
and the rest is the same, correct?
So the first thing I would do in your situation is to log the full pamyneMethod object in your else condition :
paymentRequest.on('paymentmethod', function(result) {
console.log('payment method result', result)
if (result.error) {
displayStripeFeedback(result.error.message, 'error');
} else {
console.log(paymentMethod)
createSubscription(result.paymentMethod.id)
and examine the object in the console to be 100% sure where the values are
OK...
How can I test that with PRB? Currently it shows Link button
If I click on that to pay (but I'm connected to test Stripe) - will it charge me?
or if can get Apple Pay to show?
You need to test it with a browser that is set up for Google/Apple pay
And you can disable link to avoid seeing that https://stripe.com/docs/js/payment_request/create#stripe_payment_request-options-disableWallets
OK... I can use Safari for Apple... I am setup to see Google but it doesn't show (only Link does)
in any case - I should be ok clicking those as long as I'm in testing mode?
Wonderful!!! thank you so much!
But you can also check which wallets are enabled by logging the result of canMakePamyne() https://stripe.com/docs/js/payment_request/can_make_payment
You should get something like this:
{
applePay: true,
googlePay: false,
link: false,
}
With whichever wallet is enabled in the browser set to true
hmm... it shows that Google pay is not enabled... I in any case - I'll figure it out and I know that I can get ApplePay to show in Safari
Thanks again!
Happy to help ๐