#MikeLE-PR-button-JS

1 messages ยท Page 1 of 1 (latest)

worthy glen
#

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

rose moon
#

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

worthy glen
#

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 ๐Ÿ™‚

fair niche
#

Can I also ask what call you are getting these errors on and what they look like?

rose moon
#

I supplied -1 and 99999999999999999999999999

#

but that's ok. We won't send outrageous numbers like these in prod

worthy glen
#

Discord image compression made the text unreadable ๐Ÿ˜ญ

rose moon
#

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

worthy glen
#

have you tried not passing an amount? ๐Ÿค”

rose moon
#

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

worthy glen
#

ah sorry what I meant was passing pending: in the total field

#

so it'd look something like
{ amount: xxx, label: yyyy, pending: true }

rose moon
#

oh nice!

#

๐Ÿ˜„ We can work with it, thanks!

worthy glen
#

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

rose moon
#

Oh I see

worthy glen
#

for more context

rose moon
#

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?

worthy glen
#

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.

rose moon
#

ah ok, thanks!

worthy glen
#

@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

rose moon
#

Good to know, thanks! ๐Ÿ™‚