Merge pull request #5682 from mempool/nymkappa/googlepaysca
[accelerator] add sca for googlepay payments
This commit is contained in:
commit
01df22ef86
@ -612,10 +612,18 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
this.processing = false;
|
this.processing = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const verificationToken = await this.$verifyBuyer(this.payments, tokenResult.token, tokenResult.details, costUSD.toFixed(2));
|
||||||
|
if (!verificationToken) {
|
||||||
|
console.error(`SCA verification failed`);
|
||||||
|
this.accelerateError = 'SCA Verification Failed. Payment Declined.';
|
||||||
|
this.processing = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
const cardTag = md5(`${card.brand}${card.expMonth}${card.expYear}${card.last4}`.toLowerCase());
|
const cardTag = md5(`${card.brand}${card.expMonth}${card.expYear}${card.last4}`.toLowerCase());
|
||||||
this.servicesApiService.accelerateWithGooglePay$(
|
this.servicesApiService.accelerateWithGooglePay$(
|
||||||
this.tx.txid,
|
this.tx.txid,
|
||||||
tokenResult.token,
|
tokenResult.token,
|
||||||
|
verificationToken,
|
||||||
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
|
||||||
@ -743,6 +751,32 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Required in SCA Mandated Regions: Learn more at https://developer.squareup.com/docs/sca-overview
|
||||||
|
*/
|
||||||
|
async $verifyBuyer(payments, token, details, amount) {
|
||||||
|
const verificationDetails = {
|
||||||
|
amount: amount,
|
||||||
|
currencyCode: 'USD',
|
||||||
|
intent: 'CHARGE',
|
||||||
|
billingContact: {
|
||||||
|
givenName: details.card?.billing?.givenName,
|
||||||
|
familyName: details.card?.billing?.familyName,
|
||||||
|
phone: details.card?.billing?.phone,
|
||||||
|
addressLines: details.card?.billing?.addressLines,
|
||||||
|
city: details.card?.billing?.city,
|
||||||
|
state: details.card?.billing?.state,
|
||||||
|
countryCode: details.card?.billing?.countryCode,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const verificationResults = await payments.verifyBuyer(
|
||||||
|
token,
|
||||||
|
verificationDetails,
|
||||||
|
);
|
||||||
|
return verificationResults.token;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BTCPay
|
* BTCPay
|
||||||
*/
|
*/
|
||||||
|
@ -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, cardTag: string, referenceId: string, userApprovedUSD: number) {
|
accelerateWithGooglePay$(txInput: string, token: string, verificationToken: string, cardTag: string, referenceId: string, userApprovedUSD: number) {
|
||||||
return this.httpClient.post<any>(`${this.stateService.env.SERVICES_API}/accelerator/accelerate/googlePay`, { txInput: txInput, cardTag: cardTag, token: token, 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 });
|
||||||
}
|
}
|
||||||
|
|
||||||
getAccelerations$(): Observable<Acceleration[]> {
|
getAccelerations$(): Observable<Acceleration[]> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user