import { Injectable } from '@angular/core' ; import { SendWyreConfig } from './sendwyre.interface' ; import { SendWyreReservationResponse } from './wallet-order-reservation.interface' ; import { Client } from '../../../services/api' ; import { FormToastService } from '../../../common/services/form-toast.service' ; author Ben Hayward
  @ Injectable ( ) export class SendWyreService { public amountUsd : string = '40' ; constructor ( private client , private toaster ) { } param { SendWyreConfig } sendWyreConfig returns private async getRedirectUrl ( sendWyreConfig ) { try { const response = await this . client . post ( 'api/v2/sendwyre' , sendWyreConfig ) ; return response . url ; } catch ( e ) { console . error ( e ) ; this . toaster . error ( 'An error has occurred whilst communicating with SendWyre' ) ; } } param { SendWyreConfig } sendWyreConfig public async redirect ( sendWyreConfig ) { try { const redirectUrl = await this . getRedirectUrl ( sendWyreConfig ) ; window . open ( redirectUrl , '_blank' ) || window . location . replace ( redirectUrl ) ; } catch ( e ) { console . error ( e ) ; this . toaster . error ( 'SendWyre baseUrl not configured' ) ; } } }