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',
@@ -585,8 +580,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
this.processing = false; this.processing = false;
console.error(e); console.error(e);
} }
}
);
} }
/** /**
@@ -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',
@@ -710,8 +698,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
this.isCheckoutLocked--; this.isCheckoutLocked--;
} }
}); });
}
);
} }
/** /**
@@ -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;
} }
@@ -815,8 +795,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
this.isCheckoutLocked--; this.isCheckoutLocked--;
this.isTokenizing--; this.isTokenizing--;
} }
}
);
} }
/** /**
@@ -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',
@@ -902,8 +875,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
}); });
} }
}); });
}
);
} }
/** /**