Merge pull request #6029 from mempool/nymkappa/accelerator-checkout-fix

[accelerator] we don't need to start a new price subscription at checkout
This commit is contained in:
nymkappa
2025-09-09 14:55:05 +02:00
committed by GitHub

View File

@@ -474,19 +474,14 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
if (this.processing) { if (this.processing) {
return; return;
} }
if (this.conversionsSubscription) {
this.conversionsSubscription.unsubscribe();
}
this.processing = true; this.processing = true;
this.conversionsSubscription = this.stateService.conversions$.subscribe(
async (conversions) => {
this.conversions = conversions;
if (this.applePay) { if (this.applePay) {
this.applePay.destroy(); this.applePay.destroy();
} }
const costUSD = this.cost / 100_000_000 * conversions.USD; const costUSD = this.cost / 100_000_000 * this.conversions.USD;
const paymentRequest = this.payments.paymentRequest({ const paymentRequest = this.payments.paymentRequest({
countryCode: 'US', countryCode: 'US',
currencyCode: 'USD', currencyCode: 'USD',
@@ -586,8 +581,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
console.error(e); console.error(e);
} }
} }
);
}
/** /**
* GOOGLE PAY * GOOGLE PAY
@@ -596,19 +589,14 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
if (this.processing) { if (this.processing) {
return; return;
} }
if (this.conversionsSubscription) {
this.conversionsSubscription.unsubscribe();
}
this.processing = true; this.processing = true;
this.conversionsSubscription = this.stateService.conversions$.subscribe(
async (conversions) => {
this.conversions = conversions;
if (this.googlePay) { if (this.googlePay) {
this.googlePay.destroy(); this.googlePay.destroy();
} }
const costUSD = this.cost / 100_000_000 * conversions.USD; const costUSD = this.cost / 100_000_000 * this.conversions.USD;
const paymentRequest = this.payments.paymentRequest({ const paymentRequest = this.payments.paymentRequest({
countryCode: 'US', countryCode: 'US',
currencyCode: 'USD', currencyCode: 'USD',
@@ -711,8 +699,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
} }
}); });
} }
);
}
/** /**
* Card On File * Card On File
@@ -721,16 +707,10 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
if (this.processing) { if (this.processing) {
return; return;
} }
if (this.conversionsSubscription) {
this.conversionsSubscription.unsubscribe();
}
this.processing = true; this.processing = true;
this.conversionsSubscription = this.stateService.conversions$.subscribe(
async (conversions) => {
this.conversions = conversions;
const costUSD = this.cost / 100_000_000 * conversions.USD; const costUSD = this.cost / 100_000_000 * this.conversions.USD;
if (this.isCheckoutLocked > 0) { if (this.isCheckoutLocked > 0) {
return; return;
} }
@@ -816,8 +796,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
this.isTokenizing--; this.isTokenizing--;
} }
} }
);
}
/** /**
* CASHAPP * CASHAPP
@@ -826,20 +804,15 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
if (this.processing) { if (this.processing) {
return; return;
} }
if (this.conversionsSubscription) {
this.conversionsSubscription.unsubscribe();
}
this.processing = true; this.processing = true;
this.conversionsSubscription = this.stateService.conversions$.subscribe(
async (conversions) => {
this.conversions = conversions;
if (this.cashAppPay) { if (this.cashAppPay) {
this.cashAppPay.destroy(); this.cashAppPay.destroy();
} }
const redirectHostname = document.location.hostname === 'localhost' ? `http://localhost:4200`: `https://${document.location.hostname}`; const redirectHostname = document.location.hostname === 'localhost' ? `http://localhost:4200`: `https://${document.location.hostname}`;
const costUSD = this.cost / 100_000_000 * conversions.USD; const costUSD = this.cost / 100_000_000 * this.conversions.USD;
const paymentRequest = this.payments.paymentRequest({ const paymentRequest = this.payments.paymentRequest({
countryCode: 'US', countryCode: 'US',
currencyCode: 'USD', currencyCode: 'USD',
@@ -903,8 +876,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
} }
}); });
} }
);
}
/** /**
* https://developer.squareup.com/docs/sca-overview * https://developer.squareup.com/docs/sca-overview