[accelerator] avoid premature square setup call
This commit is contained in:
parent
481859bc8f
commit
d3e3650cac
@ -90,7 +90,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
auth: IAuth | null = null;
|
auth: IAuth | null = null;
|
||||||
|
|
||||||
// accelerator stuff
|
// accelerator stuff
|
||||||
square: { appId: string, locationId: string};
|
|
||||||
accelerationUUID: string;
|
accelerationUUID: string;
|
||||||
accelerationSubscription: Subscription;
|
accelerationSubscription: Subscription;
|
||||||
difficultySubscription: Subscription;
|
difficultySubscription: Subscription;
|
||||||
@ -113,7 +112,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
loadingCashapp = false;
|
loadingCashapp = false;
|
||||||
loadingApplePay = false;
|
loadingApplePay = false;
|
||||||
loadingGooglePay = false;
|
loadingGooglePay = false;
|
||||||
cashappError = false;
|
|
||||||
cashappSubmit: any;
|
cashappSubmit: any;
|
||||||
payments: any;
|
payments: any;
|
||||||
cashAppPay: any;
|
cashAppPay: any;
|
||||||
@ -170,13 +168,6 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
this.moveToStep('summary');
|
this.moveToStep('summary');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.servicesApiService.setupSquare$().subscribe(ids => {
|
|
||||||
this.square = {
|
|
||||||
appId: ids.squareAppId,
|
|
||||||
locationId: ids.squareLocationId
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
this.conversionsSubscription = this.stateService.conversions$.subscribe(
|
this.conversionsSubscription = this.stateService.conversions$.subscribe(
|
||||||
async (conversions) => {
|
async (conversions) => {
|
||||||
this.conversions = conversions;
|
this.conversions = conversions;
|
||||||
@ -443,8 +434,10 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
async initSquare(): Promise<void> {
|
async initSquare(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
this.servicesApiService.setupSquare$().subscribe({
|
||||||
|
next: async (ids) => {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
this.payments = window.Square.payments(this.square.appId, this.square.locationId)
|
this.payments = window.Square.payments(ids.squareAppId, ids.squareLocationId)
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
if (this._step === 'cashapp' || urlParams.get('cash_request_id')) {
|
if (this._step === 'cashapp' || urlParams.get('cash_request_id')) {
|
||||||
await this.requestCashAppPayment();
|
await this.requestCashAppPayment();
|
||||||
@ -453,10 +446,15 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
} else if (this._step === 'googlepay') {
|
} else if (this._step === 'googlepay') {
|
||||||
await this.requestGooglePayPayment();
|
await this.requestGooglePayPayment();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: () => {
|
||||||
|
console.debug('Error loading Square Payments');
|
||||||
|
this.accelerateError = 'cannot_setup_square';
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.debug('Error loading Square Payments', e);
|
console.debug('Error loading Square Payments', e);
|
||||||
this.cashappError = true;
|
this.accelerateError = 'cannot_setup_square';
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user