#mardo-PRB

1 messages · Page 1 of 1 (latest)

minor lantern
#

Hi there! PaymentRequestButton is only for web. Are you creating a native mobile app?

covert pier
#

I am sorry its a mobile web app

minor lantern
#

Gotcha

#

I would not recommend relying just on PRB

#

Have you taken a look at Payment Element?

covert pier
#

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

minor lantern
#

Why do you want to have customers pay with Wallets instead of giving them the option?

covert pier
#

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

minor lantern
#

Yeah I mean that's fair, but you could also just mount PRB above your Card Element

#

And offer both

covert pier
#

Ok, that's fine

minor lantern
#

Up to you really

covert pier
#

Fair enough

minor lantern
#

If you want to "fall back" to Card Element that works

covert pier
#

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.
}
}
});
});

minor lantern
#

Oh

covert pier
#

Is there a way to finish the transaction on the server or does apple pay callback to this script and actually process the payment?

minor lantern
#

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

covert pier
#

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

minor lantern
#

Yep. You would generally show a success page after processing on the client.

covert pier
#

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

minor lantern
#

Are you referring to other data like Customer data that you are collecting ahead of payment?

covert pier
#

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

minor lantern
#

Yeah you can wait to mount your Element until the proper data is filled out.

covert pier
#

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?

minor lantern
#

Well let's back up a second. What Customer data are you looking to collect?

covert pier
#

just a phone number

covert pier
#

Oh nice! So that comes from their phone and is their cell phone number?

#

Works on both Apple and Google>?

minor lantern
#

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

covert pier
#

I'll give it a go, you have been very helpful. Thank you!

minor lantern
#

Happy to help!

covert pier
#

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?

minor lantern
#

That is only what shows in the modal

covert pier
#

or does the client secret from the server have to match up

minor lantern
#

The PaymentIntent is what dictates the amount actually charged

covert pier
#

Ok, are those optional fields>?

minor lantern
#

Which?

covert pier
#

total : / label, amount

minor lantern
#

Total is not optional

covert pier
#

Seems kind of weird setting the amount on the server and then in the client

minor lantern
#

The Wallet is really just collecting the PaymentMethod

#

It is separate from the actual charge.

covert pier
#

Okay

minor lantern
covert pier
#

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

minor lantern
#

It should be on the PaymentMethod unless I'm forgetting

#

Can you share an example?

covert pier
#

stripe.confirmCardPayment(
'@Model.Value.Stripe_ClientSecret',
{payment_method: ev.paymentMethod.id},
{handleActions: false}
).then(function(confirmResult) {

              console.log(confirmResult)
#

confirmResult doesnt have the data

minor lantern
#

The PaymentIntent

#

Yeah you won't see that data client-side

covert pier
#

On the server side?

minor lantern
#

You would need to retrieve the PaymentIntent and it should be within the PaymentMethod's billing details

#

Yep server side

covert pier
#

Ok so I have to call strype and get it after the trx takes place