UNPKG

ngx-loovpay

Version:

ngx-loovpay is a solution that can be integrated into Angular applications, giving developers the possibility of integrating them into merchant applications for the purpose of collecting payments.

139 lines (132 loc) 5.59 kB
import * as i0 from '@angular/core'; import { Injectable, Inject, Component, NgModule } from '@angular/core'; import * as i1 from '@angular/common/http'; class NgxLoovService { constructor(config, httpclient) { this.config = config; this.httpclient = httpclient; this.configData = { merchant_key: '', app_key: '', loov_url: '' }; this.configData = config; } initPayment(payload) { const payment_payload = { amount: payload.amount, customer: { name: payload.customer.name, phoneNumber: payload.customer.phoneNumber, email: payload.customer.email }, callback: payload.callback_url, description: payload.description, }; if (payload.payment_mode === 'CARD') { Object.assign(payment_payload, { payment_mode: 'CARD', return_url: payload.return_url, cancel_url: payload.cancel_url, currency: payload.currency, }); } else { Object.assign(payment_payload, { payment_mode: 'MOBILE_MONEY', operator: payload.operator, phoneNumber: payload.phoneNumber, currency: 'XAF', }); } return this.httpclient.post(this.configData.loov_url.concat(payload.payment_mode == 'MOBILE_MONEY' ? '/payment/payin/mobile' : '/payment/init'), payment_payload, { headers: { 'Content-Type': 'application/json', 'app-key': this.config.app_key, 'merchant-key': this.config.merchant_key, // Replace with your merchant key } }); } checkStatus(reference) { return this.httpclient.get(this.configData.loov_url.concat(`/payment/status/${reference}`), { headers: { 'Content-Type': 'application/json', 'app-key': this.config.app_key, 'merchant-key': this.config.merchant_key, // Replace with your merchant key } }); } payOut(payload) { return this.httpclient.post(this.configData.loov_url.concat('/payment/payout/mobile'), payload, { headers: { 'Content-Type': 'application/json', 'app-key': this.config.app_key, 'merchant-key': this.config.merchant_key, // Replace with your merchant key } }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovService, deps: [{ token: 'config' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovService, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovService, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: Inject, args: ['config'] }] }, { type: i1.HttpClient }]; } }); class NgxLoovComponent { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.10", type: NgxLoovComponent, selector: "ngx-loov", ngImport: i0, template: ` <p> Welcome to LoovPay librairies </p> `, isInline: true }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovComponent, decorators: [{ type: Component, args: [{ selector: 'ngx-loov', template: ` <p> Welcome to LoovPay librairies </p> ` }] }] }); class NgxLoovModule { static forRoot(config) { return { ngModule: NgxLoovModule, providers: [ { provide: 'config', useValue: config }, NgxLoovService ] }; } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovModule, declarations: [NgxLoovComponent], exports: [NgxLoovComponent] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovModule }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.10", ngImport: i0, type: NgxLoovModule, decorators: [{ type: NgModule, args: [{ declarations: [ NgxLoovComponent ], imports: [], exports: [ NgxLoovComponent ] }] }] }); /* * Public API Surface of ngx-loov */ /** * Generated bundle index. Do not edit. */ export { NgxLoovComponent, NgxLoovModule, NgxLoovService }; //# sourceMappingURL=ngx-loov.mjs.map