Merge pull request #5708 from mempool/nymkappa/sca-notification

[accelerator] print sca status for google payment
This commit is contained in:
wiz 2025-01-07 15:56:35 +09:00 committed by GitHub
commit 25133d8505
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 8 deletions

View File

@ -613,7 +613,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
return; return;
} }
const verificationToken = await this.$verifyBuyer(this.payments, tokenResult.token, tokenResult.details, costUSD.toFixed(2)); const verificationToken = await this.$verifyBuyer(this.payments, tokenResult.token, tokenResult.details, costUSD.toFixed(2));
if (!verificationToken) { if (!verificationToken || !verificationToken.token) {
console.error(`SCA verification failed`); console.error(`SCA verification failed`);
this.accelerateError = 'SCA Verification Failed. Payment Declined.'; this.accelerateError = 'SCA Verification Failed. Payment Declined.';
this.processing = false; this.processing = false;
@ -623,10 +623,11 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
this.servicesApiService.accelerateWithGooglePay$( this.servicesApiService.accelerateWithGooglePay$(
this.tx.txid, this.tx.txid,
tokenResult.token, tokenResult.token,
verificationToken, verificationToken.token,
cardTag, cardTag,
`accelerator-${this.tx.txid.substring(0, 15)}-${Math.round(new Date().getTime() / 1000)}`, `accelerator-${this.tx.txid.substring(0, 15)}-${Math.round(new Date().getTime() / 1000)}`,
costUSD costUSD,
verificationToken.userChallenged
).subscribe({ ).subscribe({
next: () => { next: () => {
this.processing = false; this.processing = false;
@ -752,9 +753,9 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
} }
/** /**
* Required in SCA Mandated Regions: Learn more at https://developer.squareup.com/docs/sca-overview * https://developer.squareup.com/docs/sca-overview
*/ */
async $verifyBuyer(payments, token, details, amount) { async $verifyBuyer(payments, token, details, amount): Promise<{token: string, userChallenged: boolean}> {
const verificationDetails = { const verificationDetails = {
amount: amount, amount: amount,
currencyCode: 'USD', currencyCode: 'USD',
@ -774,7 +775,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
token, token,
verificationDetails, verificationDetails,
); );
return verificationResults.token; return verificationResults;
} }
/** /**

View File

@ -143,8 +143,8 @@ export class ServicesApiServices {
return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/applePay`, { txInput: txInput, cardTag: cardTag, token: token, referenceId: referenceId, userApprovedUSD: userApprovedUSD }); return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/applePay`, { txInput: txInput, cardTag: cardTag, token: token, referenceId: referenceId, userApprovedUSD: userApprovedUSD });
} }
accelerateWithGooglePay$(txInput: string, token: string, verificationToken: string, cardTag: string, referenceId: string, userApprovedUSD: number) { accelerateWithGooglePay$(txInput: string, token: string, verificationToken: string, cardTag: string, referenceId: string, userApprovedUSD: number, userChallenged: boolean) {
return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/googlePay`, { txInput: txInput, cardTag: cardTag, token: token, verificationToken: verificationToken, referenceId: referenceId, userApprovedUSD: userApprovedUSD }); return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/googlePay`, { txInput: txInput, cardTag: cardTag, token: token, verificationToken: verificationToken, referenceId: referenceId, userApprovedUSD: userApprovedUSD, userChallenged: userChallenged });
} }
getAccelerations$(): Observable<Acceleration[]> { getAccelerations$(): Observable<Acceleration[]> {