[accelerator] rerefactor bitcoin-payment component
This commit is contained in:
parent
f114a8ca75
commit
35d0e7fae7
@ -355,7 +355,7 @@
|
|||||||
<div class="col-sm text-center d-flex flex-column justify-content-center align-items-center">
|
<div class="col-sm text-center d-flex flex-column justify-content-center align-items-center">
|
||||||
@if (invoice) {
|
@if (invoice) {
|
||||||
<p>Pay <span><small style="font-family: monospace;">{{ cost | number }}</small> <span class="symbol" i18n="shared.sats">sats</span></span></p>
|
<p>Pay <span><small style="font-family: monospace;">{{ cost | number }}</small> <span class="symbol" i18n="shared.sats">sats</span></span></p>
|
||||||
<app-bitcoin-invoice style="width: 100%;" [invoice]="invoice" [invoiceId]="invoice.btcpayInvoiceId" [minimal]="true" (completed)="moveToStep('paid')"></app-bitcoin-invoice>
|
<app-bitcoin-invoice style="width: 100%;" [invoice]="invoice" [invoiceId]="invoice.id" [minimal]="true" (completed)="moveToStep('paid')"></app-bitcoin-invoice>
|
||||||
} @else {
|
} @else {
|
||||||
<p>Loading invoice...</p>
|
<p>Loading invoice...</p>
|
||||||
<div class="d-flex align-items-center justify-content-center" style="width: 100%; height: 292px;">
|
<div class="d-flex align-items-center justify-content-center" style="width: 100%; height: 292px;">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Component, OnInit, OnDestroy, Output, EventEmitter, Input, ChangeDetectorRef, SimpleChanges, HostListener } from '@angular/core';
|
import { Component, OnInit, OnDestroy, Output, EventEmitter, Input, ChangeDetectorRef, SimpleChanges, HostListener } from '@angular/core';
|
||||||
import { Subscription, tap, of, catchError, Observable } from 'rxjs';
|
import { Subscription, tap, of, catchError, Observable, switchMap } from 'rxjs';
|
||||||
import { ServicesApiServices } from '../../services/services-api.service';
|
import { ServicesApiServices } from '../../services/services-api.service';
|
||||||
import { nextRoundNumber } from '../../shared/common.utils';
|
import { nextRoundNumber } from '../../shared/common.utils';
|
||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
@ -443,15 +443,20 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
|
|||||||
* BTCPay
|
* BTCPay
|
||||||
*/
|
*/
|
||||||
async requestBTCPayInvoice() {
|
async requestBTCPayInvoice() {
|
||||||
this.servicesApiService.generateBTCPayAcceleratorInvoice$(this.tx.txid, this.userBid).subscribe({
|
this.servicesApiService.generateBTCPayAcceleratorInvoice$(this.tx.txid, this.userBid).pipe(
|
||||||
next: (response) => {
|
switchMap(response => {
|
||||||
this.invoice = response;
|
return this.servicesApiService.retreiveInvoice$(response.btcpayInvoiceId);
|
||||||
|
}),
|
||||||
|
catchError(error => {
|
||||||
|
console.log(error);
|
||||||
|
return of(null);
|
||||||
|
})
|
||||||
|
).subscribe((invoice) => {
|
||||||
|
this.invoice = invoice;
|
||||||
this.cd.markForCheck();
|
this.cd.markForCheck();
|
||||||
this.scrollToElementWithTimeout('acceleratePreviewAnchor', 'start', 500);
|
if (invoice) {
|
||||||
},
|
this.scrollToElementWithTimeout('acceleratePreviewAnchor', 'start', 500);
|
||||||
error: (response) => {
|
}
|
||||||
console.log(response);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export class BitcoinInvoiceComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
if (this.paymentStatusSubscription) {
|
if (this.paymentStatusSubscription) {
|
||||||
this.paymentStatusSubscription.unsubscribe();
|
this.paymentStatusSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
this.paymentStatusSubscription = ((this.invoice && (this.invoice.btcpayInvoiceId || this.invoice.id) === invoiceId) ? of(this.invoice) : this.apiService.retreiveInvoice$(invoiceId)).pipe(
|
this.paymentStatusSubscription = ((this.invoice && this.invoice.id === invoiceId) ? of(this.invoice) : this.apiService.retreiveInvoice$(invoiceId)).pipe(
|
||||||
tap((invoice: any) => {
|
tap((invoice: any) => {
|
||||||
this.loadedInvoice = invoice;
|
this.loadedInvoice = invoice;
|
||||||
if (this.loadedInvoice.btcDue > 0) {
|
if (this.loadedInvoice.btcDue > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user