#dux_applepay-verification
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1291442548367163432
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
dux_applepay-verification
Sure but it's likely something is configured wrong! Can you please give me a clear summary, all in one message (not multiple short messages one after the other) of how you integrate.
Please explain the exact integration (PaymentElement, ExpressCheckoutElement, other), what your code look like, explain if Connect is or isn't involved, confirm if anything is done in an iframe or not and what exact URL you are on.
i'm on staging3.beginlearning.com
using PaymentElement
code looks like this (not exactly because there is other business logic):
<Elements
key={clientSecret}
options={options}
stripe={stripePromise}
>
<PaymentElement
id="payment-element"
options={{
layout: {
type: 'accordion',
},
}}
onChange={e => {
if (e.complete) onComplete?.();
else onIncomplete?.();
}}
/>
</Elements>
i'm not sure if there is an iframe, we're using the react stripe elements.
i dont think connect is on
using a client secret for setupIntent
Okay, can you share a URL where I can see this live?
I looked at our logs and in the past 24 hours that exact domain has been attempted 5 times in Test mode and each time it was found in our systems at least
- go here: https://staging3.beginlearning.com/?featureId=stripeDropinForm
- then click 'take the quiz' in the top right hand corner
- select 'my child' -> next
- add any nickname -> next
- select any month, for year, select 2020
- select 'critical thinking'
- select 'playing independently'
- select any option
- you'll see a page that says 'Our Recommended Stage', scroll down a little until you see 'what we recommend', then click 'choose plan'
- select 12 month plan
- fill out account creation form and click continue to shipping
- fill out shipping form (you need a real state + zip code, try Connecticut + 06512), click continue to payment
- on this page, the stripe form appears, and you can select apple pay, then click 'confirm subscription'
and you'll see the error
It's all staging, can you fix it so that I get straight to the payment page without the 15 steps? ๐
what do you mean by 'its all staging'?
the prod version is also the same 15 steps
hold on let me see if another page has less steps
ok go here: https://staging3.beginlearning.com/settings-user?featureId=stripeDropinForm
you will get redirected to a login screen, use this account:
abdul+9424-125@beginlearning.com / Testing123
scroll down to where you see the payment method. there will be an edit button to the right side, click it and the stripe form should load
it fails after you try to use it
what does "use it" mean? Sorry but that domain error is usually only ever fired before we show ApplePay as an option, not way later.
I think we need a clearer step by step explanation of what is going on and what is or isn't working.
Unfortunately we can't test for real otherwise you would get our real identity
i'll send you a video then
because i'm getting that error after i use the apply pay option
not sure how good the video quality is because i had to compress it
Hi ๐
I'm stepping in as my colleague needed to go
ok
Hmmm the Apple Pay modal is showing an invalid billing address error
is that the source of the error?
i can fix that and check
but my colleague tried the same thing and got the same error, not sure if she had an invalid billing error
also thats a test apple card
Okay but I'm telling you what I saw in the video. I think you should eliminate all clear errors to ensure we aren't chasing our tails.
fixed the billing issue but still seeing same error
I have another question about your integration:
Is your code doing anything before attempting to confirm the payment when the user clicks a button?
let me check
as far as i remember, we just confirm the setup intent
which happens after talking with stripe
Sorry that isn't clear to me.
What is the exact code that is responding to the click event?
const handleSubmit = React.useCallback(async () => {
try {
if (!stripe || !elements) {
return {};
}
const response = await stripe.retrieveSetupIntent(clientSecret);
if (clientSecret) {
// - if there's already a payment method on the setupIntent,
// that means it was already confirmed
if (response?.setupIntent?.payment_method) {
return {
paymentMethodId: response?.setupIntent?.payment_method || '',
};
}
}
const res = await stripe.confirmSetup({
elements: elements,
redirect: 'if_required',
}, {
expand: ['customer'],
});
const paymentMethodId = res?.setupIntent?.payment_method || '';
return { paymentMethodId };
} catch (e) {
return {};
}
}, [clientSecret, stripe, elements]);```
Why are you retrieving the Setup Intent at this point?
Shouldn't you already have it?
no i dont have it. we supply the setup intent client secret from a backend service thats shared with other teams
and the setup intent resource is not sent along with that
does that cause a problem with apple pay?
Yes
The time it takes for that response is enough to Apple Pay to consider the session invalid
how does that work exactly?
If you need the payment method information, you should supply that from your back-end
so its a timing issue?
Apple Pay has strict requirements about how a session is generated
It must have a direct relationship to the button click event by the customer
event a very short (100ms) delay can cause Apple Pay to consider a session as unlinked to the button press
gotcha, ok
They don't publish any firm timing because they don't want people to be able to game the system
Yeah, pretty much. So if you returned a response from your backend that had both the Setup Intent client secret and a value to indicate if a payment method already exists, you could use that instead of pinging Stripe again.
E.g. ```
response = {
client_secret: XXXXXX
hasPaymentMethod: true|false
}
Then you could just check the `response.hasPaymentMethod` property to handle your logic
great, thanks
Happy to shed what ๐ก I can ๐
could this be added to the docs. i didnt see any references to timing constraints
I will raise that internally
awesome. thanks again for the help
Sure thing! It's why we're here
actually, let me test this first before i let you go
Okay, sounds good. You can hard code some values to skip the lookup logic
well. that might take like 20 minutes because i have to deploy
if 20 minutes is fine with you, then i'll do that now
Sure thing
ok. i'll have to look further into this because its still not working.
i just realized that the button that we click + the click handler has a few layers of code in between so i'll need to sort those out
i'll reach out again if anything else comes up, thanks