#akshay-applepay-registration
1 messages · Page 1 of 1 (latest)
Also while testing Apple Pay on MacOS I'm getting an error You cannot update Payment Request options while the payment sheet is showing. does this mean we cannot update the price or shipping options after the user taps the button?
sorry pressed return too quickly. If you use Connect + Standard accounts then you are going to use Direct Charges for the flow of funds: https://stripe.com/docs/connect/direct-charges which means you need the domain registered on each connected account. But it's just code, so it doesn't matter that you have to do that
OK so question 1 isn't an option, we have to do the registration each time then
What about the second question?
I still cannot connect the same account in both live and testmode and the documentation does not help
I don't understand why you are trying to do that though
if you are connected in Live mode you're all set
Like I said in the previous thread, I want the same account to work for both Google and Apple Pay
There is a bug where Google Pay doesn't support live mode Stripe Connect accounts
And Apple Pay only supports live mode Stripe Connect accounts
So to workaround this, I need to connect a single Stripe Connect account in live and test mode simultaneously
A previous support dev sent that documentation but it doesn't work
correct it won't work, we don't really support this flow anymore officially
you'll have to work around it
What is the alternative flow then? How else would one test that Google and Apple pay both work?
And what is the workaround? I cannot connect my live Stripe Connect account in test mode using Oauth
The workaround would be to simply have separate accounts for testing
Ok I guess we can go with that then
When testing the Apple Pay integration though, I got an error that we can't update Payment Request options while the sheet is showing
how are you updating the options?
How can I update price/shipping options if that's the case?
onClick={() => {
// call backend to update payment intent with latest price
updatePaymentIntent(paymentUpdateRequest)
.then((response) => {
paymentRequest?.update({
total: {
amount: response.data.amount,
label: 'Total',
},
})
paymentRequest?.show()
})
.catch((error) => {
console.error(error)
})
}}
Do I need to move the update/show outside of the then block?
👋 Sorry my earlier suggestion of using oauth didn't work out (I totally forgot we had made some recent changes that wouldn't allow this to work)
When is the above code triggered?
on click of what? When it's clicked is the payment interface already displayed?
on click of the Google Pay button
and no
On click of the button, that displays the interface
We just need to update the payment request amount to the subtotal of whatever item & quantity is currently selected before displaying the interface
Can you show me a little bit more of your code?
From just the code you sent over, I don't see any reason why that would't allow you to update the payment request since you're calling paymentRequest?.show() after the update
I'm wondering if there's something I'm missing from how you've set up the payment request flow overall that may give a better idea of what's going on
To get the above errors did you try clicking the button multiple times? I also want to check - what happens when you remove the paymentRequest?.show() line. Does the update succeed then?
it's hard to test because i can't use Apple Pay with my ngrok link
on first click, we got the show has to happen in event handler
On second click, we got the cannot update while payment sheet is shown
Gotcha! That helps a lot, and I think you're right - calling paymentRequest.update() within the then block is likely the issue. From some digging, it looks like promises don't propagate user gestures, so we believe that it's not being called in the correct place
Ok that's good to know. Do you know of a good solution that doesn't use promises/then? I call my backend code via axios
Instead of using then, you could just use await updatePaymentIntent(paymentUpdateRequest) , which will not continue to the next line until updatePaymentIntent(paymentUpdateRequest) is complete, so then you can continue with updating and showing the payment request
Unfortunately await requires being in an async method
And it doesn't work as an async method
I mean that I tried making the onClick method an async one but that results in the same error, even when moving it out of the then block
So I think async methods have the same issue
Yeah I see what you mean now... let me think about possible solutions
Is there a reason you wait to do the update in the onClick? I know paymentRequest.show needs to happen in the click handler, but update does not.
We don't want to call the update API too many times
Imagine if the customer changes the quantity a ton of times
That's what most people do though - they want the Payment Intent to accurately reflect what the customer would want to pay for, and it gets around the issue you're currently seeing (where you have an async function that you need to call from your click handler))