Hello!
I’ve managed to successful implement payments with SCA, but I’m struggling a lot now.
const verificationDetails = {
amount: '10.00',
currencyCode: 'EUR',
billingContact: {
givenName: currentUser.value?.name,
email: currentUser.value?.email,
phone: currentUser.value?.phone,
},
intent: isCardSave.value && !cardSelected.value ? 'STORE' : 'CHARGE'
}
const verificationResults = await squareElements.verifyBuyer(
verificationDetails,
token,
)
Following documentation, this is my basic code. But upon looking at the SDK’s code, the verifyBuyer actually expects amount and currencyCode to be in total?
var n = {
amount: So.moneyAmountToPaymentRequestAmount(e.total.amount, e.total.currencyCode),
billingContact: e.billingContact,
currencyCode: e.total.currencyCode,
customerInitiated: e.customerInitiated,
intent: e.intent,
sellerKeyedIn: e.sellerKeyedIn
};
Even with fixing this, the verification popin is triggered but verificationResults is always undefined, without further error.
Looking at the API calls, the verification seems to have succeeded, with a token being returned from three-ds-authentication
Where can I find up-to-date documentation on this?
Many thanks
I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:
Additional Documentation
Web Payments SDK Requirements
Strong Customer Authentication
https://developer.squareup.com/docs/sca-overview-web
If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.
Oh damn I found the solution: I was calling verifyBuyer from the cardElement instead of the Square.payments instance.
The verifyBuyer
method in the In-App Payments SDK is used to start the Strong Customer Authentication (SCA) flow for transactions. The verificationDetails
object you’re passing to verifyBuyer
should include the amount
and currencyCode
under a total
property, not directly under verificationDetails
.
Here’s how you should structure it:
const verificationDetails = {
total: {
amount: '10.00',
currencyCode: 'EUR',
},
billingContact: {
givenName: currentUser.value?.name,
email: currentUser.value?.email,
phone: currentUser.value?.phone,
},
intent: isCardSave.value && !cardSelected.value ? 'STORE' : 'CHARGE'
}
The verifyBuyer
method then returns a promise that resolves with a verificationToken
if the SCA challenge is successful. If verificationResults
is undefined, it might mean that the SCA challenge was not completed successfully. Make sure that the SCA flow is being completed correctly by the buyer.
This answer was reviewed by @Bryan-Square.
Glad to hear that you figured it out.