import { Injectable } from "@angular/core"; import { HttpClient } from '@angular/common/http'; import { Api } from "./api"; import { Observable} from "rxjs"; import { IRslt, Invoice, PaymentRequest, PaymentCheckResult, CardRequest, Payment } from "../../public-api"; // import { Soap } from "./soap"; // import { PaymentCheck } from "../../tff-models/src/models/dtos/payment.check"; // import { PaymentCheckResult } from "../../tff-models/dist/entry"; @Injectable({ providedIn: 'root' }) export class PaymentService { // url: string = 'https://api.ach.com/webservice/V1/gateway.asmx' key = '4719ee5d-de3e-4f9f-be11-2019d54655e0' // get route() { // return this.api.base + 'payment' // } get route() { return this.api.base + 'payment' } constructor(private api: Api, private http: HttpClient) { } storeCard(payment: CardRequest): Observable> { return this.api.post(this.api.base + 'square/card', payment) } checkBank(body:{xml:string}):Observable>{ return this.api.post(this.route + '/bank/check',body) } // squarePayment(dto:PaymentRequest): Observable>{ // return this.api.post(this.route + '/payment/square/charge',dto) // } // checkBank(args: PaymentCheck) { // var request = ` // // // // KEY // NACHA // ROUTE // ACCOUNT // AMOUNT // // // ` // request = request.replace('KEY', this.key) // request = request.replace('NACHA', args.nachaid) // request = request.replace('ROUTE', args.accountnumber) // request = request.replace('ACCOUNT', args.routingnumber) // request = request.replace('AMOUNT', args.amount) // // const params = new HttpParams(); // // params.set('token',this.key) // // params.set('nachaid',args.nachaid) // // params.set('accountnumber',args.accountnumber) // // params.set('routingnumber',args.routingnumber) // // params.set('amount',args.amount) // const headers = new HttpHeaders({ // 'Content-Type': 'text/xml', // 'SOAPAction': 'http://api.ach.com/Verify' // }); // return this.http.post(this.url + '?op=Verify', request, { headers: headers, responseType: 'text' }) // // return this.xmlStringToJson(rslt) // // return this.http.get(this.url + '?op=Verify', {headers:headers,responseType: 'text'}) // // .pipe( // // map((xmlString: string)=>{ // // const asJson = this.xmlStringToJson(xmlString); // // return asJson; // // }), // // catchError((err)=> { // // console.warn('INT ERR:', err); // // return err; // // }) // // ); // // args.routingnumber = this.key; // // const client = await this.soap.getClient(); // // client["Verify"](args, function(err:any, result:any) { // // if (err) { // // // console.error('Error making SOAP request:', err); // // err('Error making SOAP request: ' + err) // // return; // // } // // done(result) // // }); // } }