(event)
| 805 | } |
| 806 | |
| 807 | async purchaseAttempt(event) { |
| 808 | const { invoiceId } = event.data.params; |
| 809 | |
| 810 | this.logger.debug('Incoming-data: Handling bitpay invoice'); |
| 811 | try { |
| 812 | const details = await this.payproProvider.getPayProOptions( |
| 813 | `${this.BITPAY_API_URL}/i/${invoiceId}` |
| 814 | ); |
| 815 | |
| 816 | let hasWallets = {}; |
| 817 | let availableWallets = []; |
| 818 | for (const option of details.paymentOptions) { |
| 819 | const fundedWallets = this.profileProvider.getWallets({ |
| 820 | coin: option.currency.toLowerCase(), |
| 821 | network: option.network, |
| 822 | minAmount: option.estimatedAmount |
| 823 | }); |
| 824 | if (fundedWallets.length === 0) { |
| 825 | option.disabled = true; |
| 826 | } else { |
| 827 | hasWallets[option.currency.toLowerCase()] = fundedWallets.length; |
| 828 | availableWallets.push(option); |
| 829 | } |
| 830 | } |
| 831 | |
| 832 | const stateParams = { |
| 833 | payProOptions: details, |
| 834 | walletCardRedir: true, |
| 835 | hasWallets |
| 836 | }; |
| 837 | |
| 838 | let nextView = { |
| 839 | name: 'SelectInvoicePage', |
| 840 | params: stateParams |
| 841 | }; |
| 842 | this.events.publish('IncomingDataRedir', nextView); |
| 843 | } catch (err) { |
| 844 | this.events.publish('incomingDataError', err); |
| 845 | this.logger.error(err); |
| 846 | } |
| 847 | |
| 848 | this.hide(); |
| 849 | } |
| 850 | |
| 851 | async toggleShow(event) { |
| 852 | this.events.publish('showHideUpdate', 'inProgress'); |
no test coverage detected