angular-klasha 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,342 +0,0 @@
1
- import { __awaiter } from 'tslib';
2
- import * as i0 from '@angular/core';
3
- import { InjectionToken, Injectable, Inject, EventEmitter, Component, Input, Output, Directive, HostListener, NgModule } from '@angular/core';
4
- import { CommonModule } from '@angular/common';
5
-
6
- const MERCHANT_KEY = new InjectionToken('klasha.merchantKey');
7
- const BUSINESS_ID = new InjectionToken('klasha.businessId');
8
- const IS_TEST_MODE = new InjectionToken('klasha.isTestMode');
9
-
10
- /* eslint-disable @typescript-eslint/naming-convention */
11
- class AngularKlashaService {
12
- constructor(merchantKey, businessId, isTestMode = false) {
13
- this.merchantKey = merchantKey;
14
- this.businessId = businessId;
15
- this.isTestMode = isTestMode;
16
- console.log('here');
17
- const divScript = window.document.createElement('div');
18
- divScript.id = 'ktest';
19
- window.document.body.appendChild(divScript);
20
- const script = window.document.createElement('script');
21
- window.document.head.appendChild(script);
22
- const onLoadFunc = () => {
23
- script.removeEventListener('load', onLoadFunc);
24
- // resolve();
25
- };
26
- script.addEventListener('load', onLoadFunc);
27
- if (this.isTestMode) {
28
- script.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js');
29
- }
30
- else {
31
- script.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js');
32
- }
33
- console.log('loaded');
34
- }
35
- loadScript() {
36
- return new Promise(resolve => {
37
- if (window.KlashaClient && typeof window.KlashaClient.initialize === 'function') {
38
- resolve();
39
- return;
40
- }
41
- const script1 = window.document.createElement('script');
42
- window.document.head.appendChild(script1);
43
- const onLoadFunc1 = () => {
44
- script1.removeEventListener('load', onLoadFunc1);
45
- resolve();
46
- };
47
- script1.addEventListener('load', onLoadFunc1);
48
- if (this.isTestMode) {
49
- script1.setAttribute('src', 'https://klastatic.fra1.digitaloceanspaces.com/test/js/klasha-integration.js');
50
- }
51
- else {
52
- script1.setAttribute('src', 'https://klastatic.fra1.digitaloceanspaces.com/prod/js/klasha-integration.js');
53
- }
54
- console.log('loaded1');
55
- });
56
- }
57
- checkInput(obj) {
58
- if (!obj.merchantKey && !this.merchantKey) {
59
- return 'angular-klasha: Please insert a your merchantKey';
60
- }
61
- if (!obj.businessId) {
62
- return 'angular-klasha: Klasha businessId cannot be empty';
63
- }
64
- if (!obj.email) {
65
- return 'angular-klasha: Klasha email cannot be empty';
66
- }
67
- if (!obj.fullname) {
68
- return 'angular-klasha: Klasha name cannot be empty';
69
- }
70
- if (!obj.phone_number) {
71
- return 'angular-klasha: Klasha phone cannot be empty';
72
- }
73
- if (!obj.amount) {
74
- return 'angular-klasha: Klasha amount cannot be empty';
75
- }
76
- if (!obj.tx_ref) {
77
- return 'angular-klasha: Klasha tx_ref cannot be empty';
78
- }
79
- return '';
80
- }
81
- getKlashaOptions(obj) {
82
- const klashaOptions = {
83
- isTestMode: obj.isTestMode || this.isTestMode,
84
- merchantKey: obj.merchantKey || this.merchantKey,
85
- businessId: obj.businessId || this.businessId,
86
- amount: obj.amount,
87
- tx_ref: obj.tx_ref,
88
- sourceCurrency: obj.sourceCurrency || 'NGN',
89
- destinationCurrency: obj.destinationCurrency || 'NGN',
90
- fullname: obj.fullname || '',
91
- email: obj.email || '',
92
- phone_number: obj.phone_number || '',
93
- paymentDescription: obj.paymentDescription || '',
94
- callbackUrl: obj.callbackUrl || '',
95
- metadata: obj.metadata || {},
96
- kit: {
97
- currency: obj.kit.currency || obj.sourceCurrency || 'NGN',
98
- phone_number: obj.kit.phone_number || obj.phone_number || '',
99
- email: obj.kit.email || obj.email || '',
100
- fullname: obj.kit.fullname || obj.fullname || '',
101
- tx_ref: obj.kit.tx_ref || obj.tx_ref || this.makeId(8),
102
- paymentType: obj.kit.paymentType || '',
103
- // callBack : obj.kit.callBack
104
- }
105
- };
106
- return this.clean(klashaOptions);
107
- }
108
- clean(obj) {
109
- // tslint:disable-next-line:prefer-const
110
- for (const propName in obj) {
111
- if (obj[propName] === null || obj[propName] === undefined) {
112
- delete obj[propName];
113
- }
114
- }
115
- return obj;
116
- }
117
- makeId(length = 8) {
118
- let result = '';
119
- const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
120
- const charactersLength = characters.length;
121
- for (let i = 0; i < length; i++) {
122
- result += characters.charAt(Math.floor(Math.random() * charactersLength));
123
- }
124
- return result;
125
- }
126
- }
127
- AngularKlashaService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AngularKlashaService_Factory() { return new AngularKlashaService(i0.ɵɵinject(MERCHANT_KEY), i0.ɵɵinject(BUSINESS_ID), i0.ɵɵinject(IS_TEST_MODE)); }, token: AngularKlashaService, providedIn: "root" });
128
- AngularKlashaService.decorators = [
129
- { type: Injectable, args: [{
130
- providedIn: 'root',
131
- },] }
132
- ];
133
- AngularKlashaService.ctorParameters = () => [
134
- { type: String, decorators: [{ type: Inject, args: [MERCHANT_KEY,] }] },
135
- { type: String, decorators: [{ type: Inject, args: [BUSINESS_ID,] }] },
136
- { type: Boolean, decorators: [{ type: Inject, args: [IS_TEST_MODE,] }] }
137
- ];
138
-
139
- class AngularKlashaComponent {
140
- constructor(KlashaService) {
141
- this.KlashaService = KlashaService;
142
- this.paymentInit = new EventEmitter();
143
- this.callBack = new EventEmitter(); // tslint:disable-line
144
- this.isPaying = false;
145
- }
146
- pay() {
147
- return __awaiter(this, void 0, void 0, function* () {
148
- let errorText = '';
149
- if (this.klashaOptions && Object.keys(this.klashaOptions).length >= 2) {
150
- errorText = this.validateInput(this.klashaOptions);
151
- this.generateOptions(this.klashaOptions);
152
- }
153
- else {
154
- errorText = this.validateInput(this);
155
- this.generateOptions(this);
156
- }
157
- if (errorText) {
158
- console.error(errorText);
159
- return errorText;
160
- }
161
- yield this.KlashaService.loadScript();
162
- if (this.isPaying) {
163
- return;
164
- }
165
- if (this.paymentInit.observers.length) {
166
- this.paymentInit.emit();
167
- }
168
- // console.log(this._KlashaOptions);
169
- const payment = new window.KlashaClient(this._KlashaOptions.merchantKey, this._KlashaOptions.businessId || 1, this._KlashaOptions.amount, 'ktest', this._KlashaOptions.callbackUrl, this._KlashaOptions.destinationCurrency, this._KlashaOptions.sourceCurrency, this._KlashaOptions.kit);
170
- payment.init();
171
- // const payment = window.KlashaClient.init(this._KlashaOptions);
172
- // payment.loadIframe(this._KlashaOptions);
173
- this.isPaying = true;
174
- });
175
- }
176
- validateInput(obj) {
177
- if (!this.callBack.observers.length) {
178
- return 'angular-klasha: Insert a callBack output like so (callBack)=\'PaymentComplete($event)\' to check payment status';
179
- }
180
- return this.KlashaService.checkInput(obj);
181
- }
182
- generateOptions(obj) {
183
- this._KlashaOptions = this.KlashaService.getKlashaOptions(obj);
184
- this._KlashaOptions.kit.callBack = (...response) => {
185
- this.callBack.emit(...response);
186
- };
187
- this._KlashaOptions.callBack = (...response) => {
188
- this.callBack.emit(...response);
189
- };
190
- }
191
- }
192
- AngularKlashaComponent.decorators = [
193
- { type: Component, args: [{
194
- // tslint:disable-next-line:component-selector
195
- selector: 'angular-klasha',
196
- template: `<button [ngClass]="class" [ngStyle]="style" (click)="pay()"><ng-content></ng-content></button>`
197
- },] }
198
- ];
199
- AngularKlashaComponent.ctorParameters = () => [
200
- { type: AngularKlashaService }
201
- ];
202
- AngularKlashaComponent.propDecorators = {
203
- merchantKey: [{ type: Input }],
204
- isTestMode: [{ type: Input }],
205
- businessId: [{ type: Input }],
206
- amount: [{ type: Input }],
207
- metadata: [{ type: Input }],
208
- tx_ref: [{ type: Input }],
209
- currency: [{ type: Input }],
210
- fullname: [{ type: Input }],
211
- email: [{ type: Input }],
212
- phone_number: [{ type: Input }],
213
- paymentDescription: [{ type: Input }],
214
- redirectUrl: [{ type: Input }],
215
- klashaOptions: [{ type: Input }],
216
- class: [{ type: Input }],
217
- style: [{ type: Input }],
218
- paymentInit: [{ type: Output }],
219
- callBack: [{ type: Output }]
220
- };
221
-
222
- class AngularKlashaDirective {
223
- constructor(KlashaService) {
224
- this.KlashaService = KlashaService;
225
- this.paymentInit = new EventEmitter();
226
- this.callBack = new EventEmitter(); // tslint:disable-line
227
- this.isPaying = false;
228
- }
229
- pay() {
230
- return __awaiter(this, void 0, void 0, function* () {
231
- let errorText = '';
232
- if (this.klashaOptions && Object.keys(this.klashaOptions).length >= 2) {
233
- errorText = this.validateInput(this.klashaOptions);
234
- this.generateOptions(this.klashaOptions);
235
- }
236
- else {
237
- errorText = this.validateInput(this);
238
- this.generateOptions(this);
239
- }
240
- if (errorText) {
241
- console.error(errorText);
242
- return errorText;
243
- }
244
- yield this.KlashaService.loadScript();
245
- // if (this.isPaying) { return; }
246
- if (this.paymentInit.observers.length) {
247
- this.paymentInit.emit();
248
- }
249
- const payment = new window.KlashaClient(this._KlashaOptions.merchantKey, this._KlashaOptions.businessId || 1, this._KlashaOptions.amount, 'ktest', this._KlashaOptions.callbackUrl, this._KlashaOptions.destinationCurrency, this._KlashaOptions.sourceCurrency, this._KlashaOptions.kit);
250
- payment.init();
251
- // this.isPaying = false;
252
- });
253
- }
254
- validateInput(obj) {
255
- if (!this.callBack.observers.length) {
256
- return 'angular-klasha: Insert a callBack output like so (callBack)=\'PaymentComplete($event)\' to check payment status';
257
- }
258
- return this.KlashaService.checkInput(obj);
259
- }
260
- generateOptions(obj) {
261
- this._KlashaOptions = this.KlashaService.getKlashaOptions(obj);
262
- this._KlashaOptions.kit.callBack = (...response) => {
263
- this.callBack.emit(...response);
264
- };
265
- this._KlashaOptions.callBack = (...response) => {
266
- this.callBack.emit(...response);
267
- };
268
- }
269
- buttonClick() {
270
- return __awaiter(this, void 0, void 0, function* () {
271
- this.pay();
272
- });
273
- }
274
- }
275
- AngularKlashaDirective.decorators = [
276
- { type: Directive, args: [{
277
- // tslint:disable-next-line:directive-selector
278
- selector: '[angular-klasha]',
279
- },] }
280
- ];
281
- AngularKlashaDirective.ctorParameters = () => [
282
- { type: AngularKlashaService }
283
- ];
284
- AngularKlashaDirective.propDecorators = {
285
- merchantKey: [{ type: Input }],
286
- isTestMode: [{ type: Input }],
287
- businessId: [{ type: Input }],
288
- amount: [{ type: Input }],
289
- metadata: [{ type: Input }],
290
- tx_ref: [{ type: Input }],
291
- currency: [{ type: Input }],
292
- fullname: [{ type: Input }],
293
- email: [{ type: Input }],
294
- phone_number: [{ type: Input }],
295
- paymentDescription: [{ type: Input }],
296
- redirectUrl: [{ type: Input }],
297
- klashaOptions: [{ type: Input }],
298
- class: [{ type: Input }],
299
- style: [{ type: Input }],
300
- paymentInit: [{ type: Output }],
301
- callBack: [{ type: Output }],
302
- buttonClick: [{ type: HostListener, args: ['click',] }]
303
- };
304
-
305
- class AngularKlashaModule {
306
- static forRoot(merchantKey, businessId, isTestMode = false) {
307
- return {
308
- ngModule: AngularKlashaModule,
309
- providers: [
310
- AngularKlashaService,
311
- { provide: MERCHANT_KEY, useValue: merchantKey },
312
- { provide: IS_TEST_MODE, useValue: isTestMode },
313
- { provide: BUSINESS_ID, useValue: businessId }
314
- ]
315
- };
316
- }
317
- }
318
- AngularKlashaModule.decorators = [
319
- { type: NgModule, args: [{
320
- imports: [CommonModule],
321
- exports: [
322
- AngularKlashaComponent,
323
- AngularKlashaDirective
324
- ],
325
- declarations: [
326
- AngularKlashaComponent,
327
- AngularKlashaDirective
328
- ],
329
- providers: [],
330
- },] }
331
- ];
332
-
333
- /*
334
- * Public API Surface of angular-klasha
335
- */
336
-
337
- /**
338
- * Generated bundle index. Do not edit.
339
- */
340
-
341
- export { AngularKlashaComponent, AngularKlashaDirective, AngularKlashaModule, AngularKlashaService as ɵa, MERCHANT_KEY as ɵb, BUSINESS_ID as ɵc, IS_TEST_MODE as ɵd };
342
- //# sourceMappingURL=angular-klasha.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"angular-klasha.js","sources":["../../../project/angular-klasha/src/lib/klasha-keys.ts","../../../project/angular-klasha/src/lib/angular-klasha.service.ts","../../../project/angular-klasha/src/lib/angular-klasha.component.ts","../../../project/angular-klasha/src/lib/angular-klasha.directive.ts","../../../project/angular-klasha/src/lib/angular-klasha.module.ts","../../../project/angular-klasha/src/public_api.ts","../../../project/angular-klasha/src/angular-klasha.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const MERCHANT_KEY = new InjectionToken<string>('klasha.merchantKey');\nexport const BUSINESS_ID = new InjectionToken<string>('klasha.businessId');\nexport const IS_TEST_MODE = new InjectionToken<string>('klasha.isTestMode');\n","/* eslint-disable @typescript-eslint/naming-convention */\nimport { Injectable, Inject } from '@angular/core';\nimport { MERCHANT_KEY, BUSINESS_ID, IS_TEST_MODE } from './klasha-keys';\nimport { KlashaOptions } from '../model/klasha-options';\n\n\ninterface MyWindow extends Window {\n // KlashaClient: (options: Partial<KlashaOptions>)\n KlashaClient: any;\n}\ndeclare let window: MyWindow;\n\n@Injectable({\n providedIn: 'root',\n})\n\nexport class AngularKlashaService {\n constructor(@Inject(MERCHANT_KEY) private merchantKey: string,\n @Inject(BUSINESS_ID) private businessId: string,\n @Inject(IS_TEST_MODE) private isTestMode: boolean = false) {\n console.log('here');\n\n const divScript = window.document.createElement('div');\n divScript.id = 'ktest';\n window.document.body.appendChild(divScript);\n const script = window.document.createElement('script');\n window.document.head.appendChild(script);\n const onLoadFunc = () => {\n script.removeEventListener('load', onLoadFunc);\n // resolve();\n };\n script.addEventListener('load', onLoadFunc);\n if (this.isTestMode) {\n script.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js');\n } else {\n script.setAttribute('src', 'https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js');\n }\n console.log('loaded');\n }\n\n\n loadScript(): Promise<void> {\n return new Promise(resolve => {\n if (window.KlashaClient && typeof window.KlashaClient.initialize === 'function') {\n resolve();\n return;\n }\n\n const script1 = window.document.createElement('script');\n window.document.head.appendChild(script1);\n const onLoadFunc1 = () => {\n script1.removeEventListener('load', onLoadFunc1);\n resolve();\n };\n script1.addEventListener('load', onLoadFunc1);\n if (this.isTestMode) {\n script1.setAttribute('src', 'https://klastatic.fra1.digitaloceanspaces.com/test/js/klasha-integration.js');\n } else {\n script1.setAttribute('src', 'https://klastatic.fra1.digitaloceanspaces.com/prod/js/klasha-integration.js');\n }\n console.log('loaded1');\n });\n }\n\n checkInput(obj: Partial<KlashaOptions>): string {\n if (!obj.merchantKey && !this.merchantKey) {\n return 'angular-klasha: Please insert a your merchantKey';\n }\n if (!obj.businessId) {\n return 'angular-klasha: Klasha businessId cannot be empty';\n }\n if (!obj.email) {\n return 'angular-klasha: Klasha email cannot be empty';\n }\n if (!obj.fullname) {\n return 'angular-klasha: Klasha name cannot be empty';\n }\n if (!obj.phone_number) {\n return 'angular-klasha: Klasha phone cannot be empty';\n }\n if (!obj.amount) {\n return 'angular-klasha: Klasha amount cannot be empty';\n }\n if (!obj.tx_ref) {\n return 'angular-klasha: Klasha tx_ref cannot be empty';\n }\n return '';\n }\n\n getKlashaOptions(obj: KlashaOptions): KlashaOptions {\n const klashaOptions: KlashaOptions = {\n isTestMode: obj.isTestMode || this.isTestMode,\n merchantKey: obj.merchantKey || this.merchantKey,\n businessId: obj.businessId || this.businessId,\n amount: obj.amount,\n tx_ref: obj.tx_ref,\n sourceCurrency: obj.sourceCurrency || 'NGN',\n destinationCurrency: obj.destinationCurrency || 'NGN',\n fullname: obj.fullname || '',\n email: obj.email || '',\n phone_number: obj.phone_number || '',\n paymentDescription: obj.paymentDescription || '',\n callbackUrl: obj.callbackUrl || '',\n metadata: obj.metadata || {},\n kit: {\n currency: obj.kit.currency || obj.sourceCurrency || 'NGN',\n phone_number: obj.kit.phone_number || obj.phone_number || '',\n email: obj.kit.email || obj.email || '',\n fullname: obj.kit.fullname || obj.fullname || '',\n tx_ref: obj.kit.tx_ref || obj.tx_ref || this.makeId(8),\n paymentType: obj.kit.paymentType || '',\n // callBack : obj.kit.callBack\n }\n };\n return this.clean(klashaOptions);\n }\n\n clean(obj: KlashaOptions) {\n // tslint:disable-next-line:prefer-const\n for (const propName in obj) {\n if (obj[propName] === null || obj[propName] === undefined) {\n delete obj[propName];\n }\n }\n return obj;\n }\n\n makeId(length: number = 8) {\n let result = '';\n const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n const charactersLength = characters.length;\n for (let i = 0; i < length; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n }\n\n\n}\n","/* eslint-disable @angular-eslint/component-selector */\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable no-underscore-dangle */\nimport { Component, Input, Output, EventEmitter } from '@angular/core';\nimport { KlashaOptions, PrivateKlashaOptions } from '../model/klasha-options';\nimport { AngularKlashaService } from './angular-klasha.service';\n\ninterface MyWindow extends Window {\n KlashaClient: any;\n}\ndeclare let window: MyWindow;\n\n@Component({\n // tslint:disable-next-line:component-selector\n selector: 'angular-klasha',\n template: `<button [ngClass]=\"class\" [ngStyle]=\"style\" (click)=\"pay()\"><ng-content></ng-content></button>`,\n})\n\nexport class AngularKlashaComponent {\n @Input() merchantKey: string;\n @Input() isTestMode: boolean;\n @Input() businessId: string;\n @Input() amount: number;\n @Input() metadata: any;\n @Input() tx_ref: string;\n @Input() currency: string;\n @Input() fullname: string;\n @Input() email: string;\n @Input() phone_number: string;\n @Input() paymentDescription: string;\n @Input() redirectUrl: string;\n @Input() klashaOptions: KlashaOptions;\n @Input() class: string;\n @Input() style: any;\n @Output() paymentInit: EventEmitter<any> = new EventEmitter<any>();\n @Output() callBack: EventEmitter<any> = new EventEmitter<any>(); // tslint:disable-line\n public _KlashaOptions: Partial<PrivateKlashaOptions>; // tslint:disable-line\n private isPaying = false;\n constructor(private KlashaService: AngularKlashaService) { }\n\n async pay() {\n let errorText = '';\n if (this.klashaOptions && Object.keys(this.klashaOptions).length >= 2) {\n errorText = this.validateInput(this.klashaOptions);\n this.generateOptions(this.klashaOptions);\n } else {\n errorText = this.validateInput(this);\n this.generateOptions(this);\n }\n if (errorText) {\n console.error(errorText);\n return errorText;\n }\n await this.KlashaService.loadScript();\n if (this.isPaying) { return; }\n if (this.paymentInit.observers.length) {\n this.paymentInit.emit();\n }\n // console.log(this._KlashaOptions);\n const payment = new window.KlashaClient(\n this._KlashaOptions.merchantKey,\n this._KlashaOptions.businessId || 1,\n this._KlashaOptions.amount,\n 'ktest',\n this._KlashaOptions.callbackUrl,\n this._KlashaOptions.destinationCurrency,\n this._KlashaOptions.sourceCurrency,\n this._KlashaOptions.kit);\n payment.init();\n // const payment = window.KlashaClient.init(this._KlashaOptions);\n // payment.loadIframe(this._KlashaOptions);\n this.isPaying = true;\n }\n\n validateInput(obj: any) {\n if (!this.callBack.observers.length) {\n return 'angular-klasha: Insert a callBack output like so (callBack)=\\'PaymentComplete($event)\\' to check payment status';\n }\n return this.KlashaService.checkInput(obj);\n }\n\n generateOptions(obj: any) {\n this._KlashaOptions = this.KlashaService.getKlashaOptions(obj);\n this._KlashaOptions.kit.callBack = (...response: any) => {\n this.callBack.emit(...response);\n };\n this._KlashaOptions.callBack = (...response: any) => {\n this.callBack.emit(...response);\n };\n }\n\n}\n","/* eslint-disable @typescript-eslint/member-ordering */\n/* eslint-disable no-underscore-dangle */\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { Directive, Input, Output, EventEmitter, HostListener } from '@angular/core';\nimport { KlashaOptions, PrivateKlashaOptions } from '../model/klasha-options';\nimport { AngularKlashaService } from './angular-klasha.service';\n\ninterface MyWindow extends Window {\n KlashaClient: any;\n}\ndeclare let window: MyWindow;\n\n@Directive({\n // tslint:disable-next-line:directive-selector\n selector: '[angular-klasha]',\n})\nexport class AngularKlashaDirective {\n @Input() merchantKey: string;\n @Input() isTestMode: boolean;\n @Input() businessId: string;\n @Input() amount: number;\n @Input() metadata: any;\n @Input() tx_ref: string;\n @Input() currency: string;\n @Input() fullname: string;\n @Input() email: string;\n @Input() phone_number: string;\n @Input() paymentDescription: string;\n @Input() redirectUrl: string;\n @Input() klashaOptions: KlashaOptions;\n @Input() class: string;\n @Input() style: any;\n @Output() paymentInit: EventEmitter<any> = new EventEmitter<any>();\n @Output() callBack: EventEmitter<any> = new EventEmitter<any>(); // tslint:disable-line\n private _KlashaOptions: Partial<PrivateKlashaOptions>; // tslint:disable-line\n private isPaying = false;\n\n constructor(private KlashaService: AngularKlashaService) { }\n\n async pay() {\n let errorText = '';\n if (this.klashaOptions && Object.keys(this.klashaOptions).length >= 2) {\n errorText = this.validateInput(this.klashaOptions);\n this.generateOptions(this.klashaOptions);\n } else {\n errorText = this.validateInput(this);\n this.generateOptions(this);\n }\n if (errorText) {\n console.error(errorText);\n return errorText;\n }\n await this.KlashaService.loadScript();\n // if (this.isPaying) { return; }\n if (this.paymentInit.observers.length) {\n this.paymentInit.emit();\n }\n\n const payment = new window.KlashaClient(\n this._KlashaOptions.merchantKey,\n this._KlashaOptions.businessId || 1,\n this._KlashaOptions.amount,\n 'ktest',\n this._KlashaOptions.callbackUrl,\n this._KlashaOptions.destinationCurrency,\n this._KlashaOptions.sourceCurrency,\n this._KlashaOptions.kit);\n payment.init();\n // this.isPaying = false;\n }\n\n validateInput(obj: any) {\n if (!this.callBack.observers.length) {\n return 'angular-klasha: Insert a callBack output like so (callBack)=\\'PaymentComplete($event)\\' to check payment status';\n }\n return this.KlashaService.checkInput(obj);\n }\n\n generateOptions(obj: any) {\n this._KlashaOptions = this.KlashaService.getKlashaOptions(obj);\n this._KlashaOptions.kit.callBack = (...response) => {\n this.callBack.emit(...response);\n };\n this._KlashaOptions.callBack = (...response) => {\n this.callBack.emit(...response);\n };\n }\n\n @HostListener('click')\n async buttonClick() {\n this.pay();\n }\n}\n","import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { AngularKlashaComponent } from './angular-klasha.component';\nimport { AngularKlashaDirective } from './angular-klasha.directive';\nimport { AngularKlashaService } from './angular-klasha.service';\nimport { MERCHANT_KEY, IS_TEST_MODE, BUSINESS_ID } from './klasha-keys';\n\n@NgModule({\n imports: [CommonModule],\n exports: [\n AngularKlashaComponent,\n AngularKlashaDirective\n ],\n declarations: [\n AngularKlashaComponent,\n AngularKlashaDirective\n ],\n providers: [],\n})\nexport class AngularKlashaModule {\n static forRoot(merchantKey: string, businessId: string, isTestMode: boolean = false): ModuleWithProviders<AngularKlashaModule> {\n return {\n ngModule: AngularKlashaModule,\n providers: [\n AngularKlashaService,\n { provide: MERCHANT_KEY, useValue: merchantKey },\n { provide: IS_TEST_MODE, useValue: isTestMode },\n { provide: BUSINESS_ID, useValue: businessId }\n ]\n };\n }\n}\n","/*\n * Public API Surface of angular-klasha\n */\n\nexport * from './lib/angular-klasha.component';\nexport * from './lib/angular-klasha.directive';\nexport * from './lib/angular-klasha.module';\nexport { KlashaOptions } from './model/klasha-options';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n\nexport {AngularKlashaService as ɵa} from './lib/angular-klasha.service';\nexport {BUSINESS_ID as ɵc,IS_TEST_MODE as ɵd,MERCHANT_KEY as ɵb} from './lib/klasha-keys';"],"names":[],"mappings":";;;;;MAEa,YAAY,GAAG,IAAI,cAAc,CAAS,oBAAoB,EAAE;MAChE,WAAW,GAAG,IAAI,cAAc,CAAS,mBAAmB,EAAE;MAC9D,YAAY,GAAG,IAAI,cAAc,CAAS,mBAAmB;;ACJ1E;MAgBa,oBAAoB;IAC/B,YAA0C,WAAmB,EAC9B,UAAkB,EACjB,aAAsB,KAAK;QAFjB,gBAAW,GAAX,WAAW,CAAQ;QAC9B,eAAU,GAAV,UAAU,CAAQ;QACjB,eAAU,GAAV,UAAU,CAAiB;QACvD,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEtB,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACvD,SAAS,CAAC,EAAE,GAAG,OAAO,CAAC;QACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,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KAAK;0BACL,MAAM;uBACN,MAAM;0BAuDN,YAAY,SAAC,OAAO;;;MCrEV,mBAAmB;IAC9B,OAAO,OAAO,CAAC,WAAmB,EAAE,UAAkB,EAAE,aAAsB,KAAK;QACjF,OAAO;YACL,QAAQ,EAAE,mBAAmB;YAC7B,SAAS,EAAE;gBACT,oBAAoB;gBACpB,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE;gBAChD,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE;gBAC/C,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE;aAC/C;SACF,CAAC;KACH;;;YAvBF,QAAQ,SAAC;gBACR,OAAO,EAAE,CAAC,YAAY,CAAC;gBACvB,OAAO,EAAE;oBACP,sBAAsB;oBACtB,sBAAsB;iBACvB;gBACD,YAAY,EAAE;oBACZ,sBAAsB;oBACtB,sBAAsB;iBACvB;gBACD,SAAS,EAAE,EAAE;aACd;;;AClBD;;;;ACAA;;;;;;"}
@@ -1,29 +0,0 @@
1
- import { EventEmitter } from '@angular/core';
2
- import { KlashaOptions, PrivateKlashaOptions } from '../model/klasha-options';
3
- import { AngularKlashaService } from './angular-klasha.service';
4
- export declare class AngularKlashaComponent {
5
- private KlashaService;
6
- merchantKey: string;
7
- isTestMode: boolean;
8
- businessId: string;
9
- amount: number;
10
- metadata: any;
11
- tx_ref: string;
12
- currency: string;
13
- fullname: string;
14
- email: string;
15
- phone_number: string;
16
- paymentDescription: string;
17
- redirectUrl: string;
18
- klashaOptions: KlashaOptions;
19
- class: string;
20
- style: any;
21
- paymentInit: EventEmitter<any>;
22
- callBack: EventEmitter<any>;
23
- _KlashaOptions: Partial<PrivateKlashaOptions>;
24
- private isPaying;
25
- constructor(KlashaService: AngularKlashaService);
26
- pay(): Promise<string>;
27
- validateInput(obj: any): string;
28
- generateOptions(obj: any): void;
29
- }
@@ -1,30 +0,0 @@
1
- import { EventEmitter } from '@angular/core';
2
- import { KlashaOptions } from '../model/klasha-options';
3
- import { AngularKlashaService } from './angular-klasha.service';
4
- export declare class AngularKlashaDirective {
5
- private KlashaService;
6
- merchantKey: string;
7
- isTestMode: boolean;
8
- businessId: string;
9
- amount: number;
10
- metadata: any;
11
- tx_ref: string;
12
- currency: string;
13
- fullname: string;
14
- email: string;
15
- phone_number: string;
16
- paymentDescription: string;
17
- redirectUrl: string;
18
- klashaOptions: KlashaOptions;
19
- class: string;
20
- style: any;
21
- paymentInit: EventEmitter<any>;
22
- callBack: EventEmitter<any>;
23
- private _KlashaOptions;
24
- private isPaying;
25
- constructor(KlashaService: AngularKlashaService);
26
- pay(): Promise<string>;
27
- validateInput(obj: any): string;
28
- generateOptions(obj: any): void;
29
- buttonClick(): Promise<void>;
30
- }
@@ -1,4 +0,0 @@
1
- import { ModuleWithProviders } from '@angular/core';
2
- export declare class AngularKlashaModule {
3
- static forRoot(merchantKey: string, businessId: string, isTestMode?: boolean): ModuleWithProviders<AngularKlashaModule>;
4
- }
@@ -1,12 +0,0 @@
1
- import { KlashaOptions } from '../model/klasha-options';
2
- export declare class AngularKlashaService {
3
- private merchantKey;
4
- private businessId;
5
- private isTestMode;
6
- constructor(merchantKey: string, businessId: string, isTestMode?: boolean);
7
- loadScript(): Promise<void>;
8
- checkInput(obj: Partial<KlashaOptions>): string;
9
- getKlashaOptions(obj: KlashaOptions): KlashaOptions;
10
- clean(obj: KlashaOptions): KlashaOptions;
11
- makeId(length?: number): string;
12
- }
@@ -1,4 +0,0 @@
1
- import { InjectionToken } from '@angular/core';
2
- export declare const MERCHANT_KEY: InjectionToken<string>;
3
- export declare const BUSINESS_ID: InjectionToken<string>;
4
- export declare const IS_TEST_MODE: InjectionToken<string>;
@@ -1,121 +0,0 @@
1
- import { EventEmitter } from '@angular/core';
2
- export interface KlashaOptions {
3
- /**
4
- * development status | Should be set to true when using the sandbox and false when on production
5
- */
6
- isTestMode?: true | false;
7
- /**
8
- * Merchant's API Key (Can be found on the Klasha dashboard)
9
- */
10
- merchantKey: string;
11
- /**
12
- * Merchant's contract code (Can be found on the Klasha dashboard)
13
- */
14
- businessId: string;
15
- /**
16
- * The amount to be paid by the customer
17
- */
18
- amount: number;
19
- /**
20
- * The currency of the transaction being paid. `NGN`
21
- */
22
- destinationCurrency: string;
23
- /**
24
- * The currency of the transaction being initialized. `NGN`
25
- */
26
- sourceCurrency: string;
27
- /**
28
- * Merchant's Unique tx_ref for every transaction.
29
- * (The SDK already has a code snippet that generates this for you, but you can always replace it)
30
- */
31
- tx_ref: string;
32
- /**
33
- * Full name of the customer
34
- */
35
- fullname: string;
36
- /**
37
- * Email address of the customer
38
- */
39
- email: string;
40
- /**
41
- * Phone number of the customer.
42
- */
43
- phone_number: string;
44
- /**
45
- * callbackUrl
46
- */
47
- callbackUrl?: string;
48
- /**
49
- * When you need to pass extra data to the API.
50
- */
51
- metadata?: any;
52
- /**
53
- * When you need to pass extra data to the API.
54
- */
55
- kit: KlashaKitOptions;
56
- /**
57
- * paymentDescription
58
- */
59
- paymentDescription: string;
60
- }
61
- export interface KlashaKitOptions {
62
- /**
63
- * The unique tx_ref for the sub account that should receive the split.
64
- */
65
- currency: string;
66
- /**
67
- * the phone_number
68
- */
69
- phone_number?: string;
70
- /**
71
- * The email
72
- */
73
- email?: string;
74
- /**
75
- * The fullname
76
- */
77
- fullname?: string;
78
- /**
79
- * The tx_ref.
80
- */
81
- tx_ref?: string;
82
- /**
83
- * The percentage of the amount paid to be split into the sub account.
84
- */
85
- paymentType?: string;
86
- /**
87
- * The callBack function.
88
- */
89
- callBack?: any;
90
- }
91
- export interface PrivateKlashaOptions extends KlashaOptions {
92
- /**
93
- * A function to be called on successful card charge. User’s can always be redirected to a successful or
94
- * failed page supplied by the merchant here based on response
95
- * @param response?: The server response
96
- */
97
- callBack: (response?: any) => void;
98
- /**
99
- * A function to be called when the pay modal is closed.
100
- */
101
- onClose: (response?: any) => void;
102
- /**
103
- * A function to be called when payment is about to begin
104
- */
105
- init: () => void;
106
- }
107
- export interface PrivateKlashaOptionsWithEmitters extends KlashaOptions {
108
- /**
109
- * A function to be called on successful card charge. User’s can always be redirected to a successful or
110
- * failed page supplied by the merchant here based on response
111
- */
112
- callBack: EventEmitter<any>;
113
- /**
114
- * A function to be called when the pay modal is closed.
115
- */
116
- onClose: EventEmitter<any>;
117
- /**
118
- * A function to be called when payment is about to begin
119
- */
120
- init: EventEmitter<void>;
121
- }
package/public_api.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './lib/angular-klasha.component';
2
- export * from './lib/angular-klasha.directive';
3
- export * from './lib/angular-klasha.module';
4
- export { KlashaOptions } from './model/klasha-options';