#steven-request-button
1 messages ยท Page 1 of 1 (latest)
Hi Makoto, are you here to providing some help ?
Hi there, please let me take a look.
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
from the following page, when click "Buy now" button, it starts to call stripe api.
Then from console, you would see the logs
https://test-www-new-white-label.herokuapp.com/au/gift-cards
which indicates the issue
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?
alrighty, going to delete it from discord since i've saved it
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
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
sure, thanks.
hmmm, can you share the relevant snippet of codes for the payment request button? i.e. mounting/loading it
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
when do you mount/render it?
When click "Buy now" button, the "paymentRequest" function check will be triggered. Based on result, frontend component will be render ed.
A component above StripePayment_RelativeContainer is where stripe is initialized. Here's a view from React component Chrome extension
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.
Then, PaymentRequestButton is found here
sorry, but the screenshot is really teeny tiny ๐
if you can paste the code here for us? or even share it on Github Gists
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:
๐
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
@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?
totally understand, and we're here to help
thanks ๐
yes, the "applePayEnabled:true" is coming from config (process.env) . The real result is dependent on the "canMakePayment" async data.
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: {โฆ}}
my next question would be when/where do you render the applepay button when canMakePayment returns a value?
I think it is being rendered based on multiple conditions:
- Redux business logic (a bunch of conditionals based on what our business needs)
- stripe.canMakePayment() resolved value. If it resolves
nullit 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 ๐ค
based on the result of "canMakePayment", redux action dispatched, to show/not show buttons.
then....was the redux action not dispatched to show those buttons upon result of canMakePayment?
well, we are getting null from stripe.canMakePayment()
in chrome , result is
{applePay: false, googlePay: true}
in safari, result is null
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}
ApplePay button was hardcoded to be enabled earlier, now reverted based on stripe.canMakePayment result
Sorry, I think you mean the "Buy now" button
๐
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.
@sinful inlet @winter zinc sorry but I'm going to need to step away. My colleague will be here shortly to follow up.
๐ catching up
๐
Sorry, could you provide me credential to test it again?
I think you can just register with your email
Hmm it's working for me!
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
are you trying on
https://test-www-new-white-label.herokuapp.com/au
also what browser & version you are using ?
Are you using test key? I tried to search pk_test but can't find anything
Yes I clicked on gift card: https://test-www-new-white-label.herokuapp.com/au/gift-cards, using Safari on Mac
absolutely working for me
@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
@clear sequoia just wondering if you have an isolated environment (outside of stripe company network), to try it out?
Sure, let me try on iPhone again
cool, thanks
I am on mac 'bigSur' version, may be updated to the latest 'Montery', and see if it makes difference.
Can you put in a test pk? I can try to make a purchase
That sounds like a very big guess updating OS
and inspect its result
Does using Pk test allow us to see logs @clear sequoia ? Otherwise we are guessing too much :)
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
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
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
You want the main LE test key
And that throwaway account's account id
That I created yesterday
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
Sure, will try in a couple of mins
thanks
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?
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
๐
Hm, well, it is past 7pm in Australia, we will try to revisit this next week if it is ok
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
thanks Orakaro
Thanks Orakaro!