#MikeLE-PR-button-JS
1 messages ยท Page 1 of 1 (latest)
Hello ๐
canMakePayment function returns an object if Apple Pay or GPay is available
the object would look something like
{
applePay: true,
googlePay: false,
}
I'm not sure if the amount isn't relevant
let me look into that
Thanks @worthy glen . I found that negative numbers and outrageously big numbers are rejected on Javascript level immediately
but it would be nice to know if some customer would be rejected immediately if our offer was, let's say, $10000 and GPay said "nope, cannot enable GPay for 10k for THIS customer". Some hidden rule like that
Hmm got it.
Let me check if there are any limits for GPay or Apple Pay and if there are, is there a way to go around it ๐
Can I also ask what call you are getting these errors on and what they look like?
I supplied -1 and 99999999999999999999999999
but that's ok. We won't send outrageous numbers like these in prod
Discord image compression made the text unreadable ๐ญ
Ah sorry
const stripe = new Stripe("XXX", { stripeAccount: 'X' })
const paymentDetails = {
country: 'AU',
currency: 'aud',
total: {
label: 'Total',
amount: 99999999999,
},
requestPayerName: true,
requestPayerEmail: true,
};
const pr = stripe.paymentRequest(paymentDetails)
pr.canMakePayment().then(result => {
console.log('result::', result);
}).catch((error) => {
console.error('error::', error);
})
I tested with 99999999999 and -1
The thing with our app, is the final amount is not known until the checkout stage because customers can add addons, etc.
and we'd like to know if we can call canMakePayment() to check GPay or Apple Pay eligibility when we don't know the final cart amount or not
or we need to constantly refresh it whenever cart value changes, for correctness. And thus, show some progress indicator
have you tried not passing an amount? ๐ค
Uncaught IntegrationError: Missing value for paymentRequest(): total should be an object.
Uncaught IntegrationError: Missing value for paymentRequest(): total.amount should be a positive amount in the currency's subunit.
Seems like I cannot remove total field
or total.amount
ah sorry what I meant was passing pending: in the total field
so it'd look something like
{ amount: xxx, label: yyyy, pending: true }
also, the error that you're getting might be from Stripe's minimum and maximum charge amount limit
Minimum charge amount is $0.50 USD
Oh I see
Interesting
But aside from those charge amount limits, can certain amounts make GPay/ApplePay suddenly ineligible? So should we keep calling canMakePayment whenever cart value changes?
As far as my understanding goes about canMakePayment, it checks wether the client supports Apple Pay or Google Pay. I'm not sure if there is indeed a limit on the amount.
ah ok, thanks!
@rose moon just wanted to confirm that the amount should not affect payment request button.
I tested with 9999999999 and apple pay button still showed up hence I'd consider Stripe's maximum charge limit would be valid for apple pay too
Good to know, thanks! ๐