#mardo-PRB
1 messages · Page 1 of 1 (latest)
Hi there! PaymentRequestButton is only for web. Are you creating a native mobile app?
I am sorry its a mobile web app
Gotcha
I would not recommend relying just on PRB
Have you taken a look at Payment Element?
Yes I have that working now
so you suggest falling back to that or provide a link if they are having issues
paymentRequest.canMakePayment().then(function(result) {
if (result) {
prButton.mount('#payment-request-button');
} else {
alert("coludnt do it")
document.getElementById('payment-request-button').style.display = 'none';
}
});
could do it .. fall back
couldnt do it .. fall back
Why do you want to have customers pay with Wallets instead of giving them the option?
Thats better than entering an entire number, am I missing something?
This is what I was doing..
//const result = await stripe.createPaymentMethod({
// type: 'card',
// card: cardElement,
// billing_details: {},
// });
//if (result.error)
// errors.push(result.error.message)
This would give me the card entry
I want to make it easy for them to pay from the wallet
instead of having to enter the card details
Yeah I mean that's fair, but you could also just mount PRB above your Card Element
And offer both
Ok, that's fine
Up to you really
Fair enough
If you want to "fall back" to Card Element that works
so my second question is when they use say apple pay it says processing payment
is the workflow to actually process the payment during the apple pay handshake or just get an intent id that i can pass to my server
I have this
stripe.confirmCardPayment(
clientSecret,
{payment_method: ev.paymentMethod.id},
{handleActions: false}
).then(function(confirmResult) {
if (confirmResult.error) {
// Report to the browser that the payment failed, prompting it to
// re-show the payment interface, or show an error message and close
// the payment interface.
ev.complete('fail');
} else {
// Report to the browser that the confirmation was successful, prompting
// it to close the browser payment method collection interface.
ev.complete('success');
// Check if the PaymentIntent requires any actions and if so let Stripe.js
// handle the flow. If using an API version older than "2019-02-11"
// instead check for: paymentIntent.status === "requires_source_action".
if (confirmResult.paymentIntent.status === "requires_action") {
// Let Stripe.js handle the rest of the payment flow.
stripe.confirmCardPayment(clientSecret).then(function(result) {
if (result.error) {
// The payment failed -- ask your customer for a new payment method.
} else {
alert(JSON.stringify(result))
paymentResult = result;
}
});
} else {
alert(JSON.stringify(confirmResult))
// The payment has succeeded.
}
}
});
});
You can call confirmPayment() client-side using the PaymentMethod from Apple Pay. See: https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=html#html-js-complete-payment
Oh
Is there a way to finish the transaction on the server or does apple pay callback to this script and actually process the payment?
You are already doing that
Ah I see
You want to use manual confirmation.
No don't believe that is possible, because I think Apple Pay relies on confirmPayment to close the modal.
But let me check
Well... it is definitely possible if you use a SetupIntent
Okay but normally you process the transaction on the client then I call some server code then redirect them, is that the use case?
usually
Yep. You would generally show a success page after processing on the client.
How would you suggest I make sure the other data on the form is sanitized?
Is there an event I can hook into on the apple pay button,,, to cancel it if somethings not filled out
Are you referring to other data like Customer data that you are collecting ahead of payment?
Yes, I get a phone number for example
i want to make sure that is good before I process the payment
Really dont want to do 2 sceens
..pages
I dont have any control on cancelling that button that I am aware of
Yeah you can wait to mount your Element until the proper data is filled out.
So show nothing, and then when they fill it out correctly, it will it appear?
That could work no hooks I can get into on that button though huh?
Well let's back up a second. What Customer data are you looking to collect?
just a phone number
Oh nice! So that comes from their phone and is their cell phone number?
Works on both Apple and Google>?
Yep works on both. And it should prompt for phone number... don't think it auto inputs their cell phone.
But not 100% on that for a web app
I'll give it a go, you have been very helpful. Thank you!
Happy to help!
One last question
var paymentRequest = stripe.paymentRequest({
country: 'US',
currency: 'usd',
total: {
label: 'Parking for ',
amount: @Model.Value.,
},
requestPayerName: true,
requestPayerPhone : true,
requestPayerEmail: true
});
Couldnt they change the amount on the client and that we are requesting payment for?
That is only what shows in the modal
or does the client secret from the server have to match up
The PaymentIntent is what dictates the amount actually charged
Ok, are those optional fields>?
Which?
total : / label, amount
Total is not optional
Seems kind of weird setting the amount on the server and then in the client
The Wallet is really just collecting the PaymentMethod
It is separate from the actual charge.
Okay
You can also play with using pending: true (https://stripe.com/docs/js/appendix/payment_item_object#payment_item_object-pending) if the amount is going to change.
Ok, I like capturing the customer info in the wallet
however the payment intent object that is returned in the result
does not contain any of the data
stripe.confirmCardPayment(
'@Model.Value.Stripe_ClientSecret',
{payment_method: ev.paymentMethod.id},
{handleActions: false}
).then(function(confirmResult) {
console.log(confirmResult)
confirmResult doesnt have the data
On the server side?
You would need to retrieve the PaymentIntent and it should be within the PaymentMethod's billing details
Yep server side
Ok so I have to call strype and get it after the trx takes place