import { Injectable } from '@angular/core' ; import { Client } from '../../services/api/client' ; @ Injectable ( ) export class OffchainPaymentService { constructor ( protected client ) { } async create ( type , amount ) { let response = await this . client . post ( `api/v1/blockchain/transactions/spend` , { type , amount } ) ; if ( ! response . txHash ) { throw new Error ( 'Error processing payment' ) ; } return response . txHash ; } static _ ( client ) { return new OffchainPaymentService ( client ) ; } }