#steven-request-button

1 messages ยท Page 1 of 1 (latest)

formal iron
#

steven-request-button

sinful inlet
#

Hi Makoto, are you here to providing some help ?

formal iron
#

Hi there, please let me take a look.

sinful inlet
#

just invited one of my colleague here as well, he might join here soon as well

#

cool, thanks

#

let me know if you need any info

#

which indicates the issue

daring nebula
#

heya @sinful inlet, i'll be stepping in for makoto. Give me a while to take a look. Are you able to share test login credentials for your test site which I can use?

sinful inlet
#

Hi Alex

#

I will share one, give me a min

daring nebula
#

alrighty, going to delete it from discord since i've saved it

sinful inlet
#

that's ok, any login would be fine

#

once logged in, click "Gift Cards" at the top nav bar.

#

then in gift-cards page, click "Buy now" button, while keep console open.
You will see a log as below

daring nebula
#

okay, got to the payment page, it'll take me a bit of time to look into this, i'll get back to you as soon as possible

sinful inlet
#

sure, thanks.

daring nebula
#

hmmm, can you share the relevant snippet of codes for the payment request button? i.e. mounting/loading it

winter zinc
#

yeah

#

  const stripe = useStripe()
const pr = stripe.paymentRequest(paymentDetails)
          pr.canMakePayment().then(result => {
            if (result && (result.googlePay || result.applePay)) {
              setPaymentRequest(pr)
              if (wallet === APPLE_PAY_PAYMENT_TYPE && result && result.applePay) {
                updateCanPayWithGooglePay(false)
                updateCanPayWithApplePay(true)
                setPaymentType(APPLE_PAY_PAYMENT_TYPE)
              } else if (wallet === GOOGLE_PAY_PAYMENT_TYPE && result && result.googlePay) {
                updateCanPayWithGooglePay(true)
                updateCanPayWithApplePay(false)
                setPaymentType(GOOGLE_PAY_PAYMENT_TYPE)
              }
            } else {
              updateCanPayWithApplePay(false)
              updateCanPayWithGooglePay(false)
            }
          })
#

stripe is initialized with credentials that you can find in the network request

#

GET api/stripe/credentials

#

it has publishable_key and account_id in the response

daring nebula
#

when do you mount/render it?

sinful inlet
#

When click "Buy now" button, the "paymentRequest" function check will be triggered. Based on result, frontend component will be render ed.

winter zinc
#

A component above StripePayment_RelativeContainer is where stripe is initialized. Here's a view from React component Chrome extension

sinful inlet
#

in this case, the result returned from "paymentRequest" function, has been "result: {applePay: false, googlePay: true}".
But we would expect the applePay is "true" as well.

winter zinc
#

Then, PaymentRequestButton is found here

daring nebula
#

sorry, but the screenshot is really teeny tiny ๐Ÿ˜…

#

if you can paste the code here for us? or even share it on Github Gists

winter zinc
#

dang, I don't know how to take screenshots on Windows with high res :/

#

ok

#

do you want the code of the entire tree all the way from when Stripe is initalized? Or just this button:

daring nebula
#

๐Ÿ‘€

#

when loading the page on Safari, although the initial load shows the payment request options = null, when you click on the ApplePay dropdown, it logs {googlePayEnabled: false, applePayEnabled: true}.

The canMakePayment is an asynchronous request, so that may take a while to return a result.

Can you check if the updateCanPayWithApplePay(true) is being called when the result for canMakePayment is returned, and can you share what happens ?

#

You may want to look into your UI rendering logic : if applePayEnabled:true, the ApplePay button should render

sinful inlet
#

let me check

#

thanks

daring nebula
#

@winter zinc @sinful inlet by the way, we noticed

useEffect(() => {
    try {
      if (stripe) {
        // Check the availability of the Payment Request API.
       ...
  }, [stripe, amount])

your application is only watching for stripe and amount changes.Would it re-render when canMakePayment returns a result?

winter zinc
#

don't shoot us. We didn't write the code ๐Ÿ˜จ

#

๐Ÿ™‚ ]

#

let me check

daring nebula
#

totally understand, and we're here to help

sinful inlet
#

thanks ๐Ÿ™‚

#

yes, the "applePayEnabled:true" is coming from config (process.env) . The real result is dependent on the "canMakePayment" async data.

winter zinc
#

your application is only watching for stripe and amount changes.Would it re-render when canMakePayment returns a result?
No, I think the idea is synonymous to "componentDidMount" here in a sense that we just want to cause the effect once when all pre-requisites are ready.

#

But there could be bugs, like amount changing from null to 0 I dunno... triggering multiple useEffect

#

If that happens - that's not the intention of the code AFAIK

#

From logs on Chrome (testing Google Pay) this flow seems to trigger only once per page load

StripeWalletWidget::
StripeWalletWidget.tsx:169 StripeWalletWidget:: {paymentRequest: null}
StripeWalletWidget.tsx:172 StripeWalletWidget::result:: {result: {โ€ฆ}}
daring nebula
#

my next question would be when/where do you render the applepay button when canMakePayment returns a value?

winter zinc
#

I think it is being rendered based on multiple conditions:

  1. Redux business logic (a bunch of conditionals based on what our business needs)
  2. stripe.canMakePayment() resolved value. If it resolves null it will not show the button.

Maybe Steven can correct me if I'm wrong somewhere

#

The log StripeWalletWidget.result:: { result: null } is what bothers us ๐Ÿค”

sinful inlet
#

based on the result of "canMakePayment", redux action dispatched, to show/not show buttons.

daring nebula
#

then....was the redux action not dispatched to show those buttons upon result of canMakePayment?

winter zinc
#

well, we are getting null from stripe.canMakePayment()

sinful inlet
#

in chrome , result is
{applePay: false, googlePay: true}

in safari, result is null

daring nebula
#

cause what happened for me too was that yes, upon page load the result was null. But when i clicked on the ApplePay dropdown, the application logged a result i.e. {googlePayEnabled: false, applePayEnabled: true}

sinful inlet
#

ApplePay button was hardcoded to be enabled earlier, now reverted based on stripe.canMakePayment result

#

Sorry, I think you mean the "Buy now" button

daring nebula
#

hmmmmmmmm

#

give me a bit to handle something else urgent first and ill be back

winter zinc
#

๐Ÿ‘

sinful inlet
#

Sure, thanks.
The log of {applePayEnabled: true} is reading from our local configuration.

After that, we make stripe.canMakePayment request to validate it, and setup applePay button show/hide based on the result.

daring nebula
#

@sinful inlet @winter zinc sorry but I'm going to need to step away. My colleague will be here shortly to follow up.

winter zinc
#

๐Ÿ‘

#

๐Ÿ™‚

clear sequoia
#

๐Ÿ‘‹ catching up

winter zinc
#

๐Ÿ‘‹

clear sequoia
#

Sorry, could you provide me credential to test it again?

winter zinc
#

I think you can just register with your email

sinful inlet
clear sequoia
#

Hmm it's working for me!

winter zinc
#

Is there a way to find out (debug , logs, anything) why it is not showing for us? (to specify, why we see stripe.canMakePayment() resolve with null)

#

something like errorReason: XYZ

sinful inlet
clear sequoia
#

Are you using test key? I tried to search pk_test but can't find anything

sinful inlet
#

I am using 14.1.2 , still having the issue .

#

no applePay options

clear sequoia
#

Version 15.0 (16612.1.29.41.4, 16612)

#

Did you setup Wallet on your Mac?

sinful inlet
#

Yes

#

In our current production site

clear sequoia
#

absolutely working for me

winter zinc
#

why is it using pk_live

#

๐Ÿค”

sinful inlet
#

@winter zinc strange, do we have other mac devices to have a test?

#

let me try on my iphone

#

I cannot see applePay icon available on my iphone as well

charred coral
#

I don't have a Safari at the moment :/

#

Had to create a new account on discord

sinful inlet
#

@clear sequoia just wondering if you have an isolated environment (outside of stripe company network), to try it out?

clear sequoia
#

Sure, let me try on iPhone again

sinful inlet
#

cool, thanks

clear sequoia
#

works on my iPhone ๐Ÿค”

#

Is everyone else getting error?

sinful inlet
#

I am on mac 'bigSur' version, may be updated to the latest 'Montery', and see if it makes difference.

clear sequoia
#

Can you put in a test pk? I can try to make a purchase

charred coral
#

That sounds like a very big guess updating OS

clear sequoia
#

and inspect its result

charred coral
#

Does using Pk test allow us to see logs @clear sequoia ? Otherwise we are guessing too much :)

clear sequoia
#

Yes you should be able to see log, if an actual PaymentIntent be made. In live mode I afraid of clicking on authorize bcz I will be charged for real ๐Ÿ™‚

#

Just a suggestion, not sure if it's easy for you to swap the key

charred coral
#

Ah it should be simple. I am not at my PC atm though... I will try it in a few hours unless Steven beats me to it

sinful inlet
#

yes, its simple, but if you cannot see the issue from your end, it's hard to tell

#

let me know what key/account to be used, I can update it

charred coral
#

You want the main LE test key

#

And that throwaway account's account id

#

That I created yesterday

sinful inlet
#

updated & deploying, once done, I will have another try

#

no, still the same error from my end

#

@clear sequoia could you please try again, to see if you can see the applyPay button?

#

thanks

clear sequoia
#

Sure, will try in a couple of mins

sinful inlet
#

thanks

clear sequoia
#

The Apple Pay button is displayed but I can't process. This looks like the Apple Pay setting in Test Mode (it's a different issue)

#

Have you tried Apple Pay in test mode before?

winter zinc
#

Yeah, it never worked on this domain.

#

Not sure about other domains.

clear sequoia
#

For me the ApplePay Button displayed fine, just clicking on it, the Apple Sheet displayed with "Processing" for a while then disappeared with this console warning.

#

So displaying was ok, just some settings is preventing a Payment to be made. I am not sure if only me can make displaying happens, sounds weird

winter zinc
#

๐Ÿ˜•

#

Hm, well, it is past 7pm in Australia, we will try to revisit this next week if it is ok

clear sequoia
#

Sure sure, feel free to come back and my colleague at that time can cover you

#

My advice is that try to make it work on Test Mode first

sinful inlet
#

thanks Orakaro

winter zinc
#

Thanks Orakaro!