Skip to content

Commit fa9f90d

Browse files
committed
adding channels support
1 parent c549a6d commit fa9f90d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+48
-39
lines changed

β€Ž.editorconfig

100644100755
File mode changed.

β€Ž.gitignore

100644100755
File mode changed.

β€Ž.travis.yml

100644100755
File mode changed.

β€ŽCHANGELOG.md

100644100755
File mode changed.

β€ŽLICENSE.md

100644100755
File mode changed.

β€ŽREADME.md

100644100755
File mode changed.

β€Žangular.json

100644100755
File mode changed.

β€Ždocs/3rdpartylicenses.txt

100644100755
File mode changed.

β€Ždocs/favicon.ico

100644100755
File mode changed.

β€Ždocs/index.html

100644100755
File mode changed.

β€Ždocs/main.1e81450b255d4585d2ca.js

100644100755
File mode changed.

β€Ždocs/polyfills.2903ad11212d7d797800.js

100644100755
File mode changed.

β€Ždocs/runtime.0bca31ab9d289f7c5861.js

100644100755
File mode changed.

β€Ždocs/styles.34c57ab7888ec1573f9c.css

100644100755
File mode changed.

β€Že2e/protractor.conf.js

100644100755
File mode changed.

β€Že2e/src/app.e2e-spec.ts

100644100755
File mode changed.

β€Že2e/src/app.po.ts

100644100755
File mode changed.

β€Že2e/tsconfig.e2e.json

100644100755
File mode changed.

β€Žpackage-lock.json

100644100755
File mode changed.

β€Žpackage.json

100644100755
File mode changed.

β€Žprojects/angular4-paystack/CHANGELOG.md

100644100755
File mode changed.

β€Žprojects/angular4-paystack/LICENSE.md

100644100755
File mode changed.

β€Žprojects/angular4-paystack/README.md

100644100755
File mode changed.

β€Žprojects/angular4-paystack/karma.conf.js

100644100755
File mode changed.

β€Žprojects/angular4-paystack/ng-package.json

100644100755
File mode changed.

β€Žprojects/angular4-paystack/ng-package.prod.json

100644100755
File mode changed.

β€Žprojects/angular4-paystack/package.json

100644100755
File mode changed.
Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
2-
import { PaystackOptions } from "./paystack-options";
2+
import { PaystackOptions } from './paystack-options';
33

44
interface myWindow extends Window {
5-
PaystackPop: any
5+
PaystackPop: any;
66
}
7-
declare var window: Partial<myWindow>
7+
declare var window: Partial<myWindow>;
88

99
@Component({
1010
selector: 'angular4-paystack-embed',
@@ -13,61 +13,69 @@ declare var window: Partial<myWindow>
1313
})
1414

1515
export class Angular4PaystackEmbed implements OnInit {
16-
@Input() text: string
17-
@Input() key: string
18-
@Input() email: string
19-
@Input() amount: number
20-
@Input() metadata: {}
21-
@Input() ref: string
22-
@Input() currency: string
23-
@Input() plan: string
24-
@Input() quantity: string
25-
@Input() subaccount: string
26-
@Input() transaction_charge: number
27-
@Input() bearer: string
28-
@Output() close: EventEmitter<string> = new EventEmitter<string>()
29-
@Output() callback: EventEmitter<string> = new EventEmitter<string>()
16+
@Input() text: string;
17+
@Input() key: string;
18+
@Input() email: string;
19+
@Input() amount: number;
20+
@Input() metadata: {};
21+
@Input() channels: string | string[];
22+
@Input() ref: string;
23+
@Input() currency: string;
24+
@Input() plan: string;
25+
@Input() quantity: string;
26+
@Input() subaccount: string;
27+
@Input() transaction_charge: number;
28+
@Input() bearer: string;
29+
@Output() paymentInit: EventEmitter<string> = new EventEmitter<string>();
30+
@Output() close: EventEmitter<string> = new EventEmitter<string>();
31+
@Output() callback: EventEmitter<string> = new EventEmitter<string>();
3032
private paystackOptions: Partial<PaystackOptions>;
3133
constructor() { }
3234

3335
pay() {
34-
this.setUp()
35-
console.log("OK payment will begin")
36-
if (!this.checkInput()) return
37-
window.PaystackPop.setup(this.paystackOptions)
36+
if (!this.checkInput()) { return; }
37+
this.setUp();
38+
if (this.paymentInit.observers.length) {
39+
this.paymentInit.emit();
40+
}
41+
window.PaystackPop.setup(this.paystackOptions);
3842
}
3943
checkInput() {
40-
if (!this.key) return console.error("Paystack key cannot be empty")
41-
if (!this.email) return console.error("Paystack email cannot be empty")
42-
if (!this.amount) return console.error("Paystack amount cannot be empty")
43-
if (!this.ref) return console.error("Paystack ref cannot be empty")
44-
if (!this.callback.observers.length) return console.error(`Insert a callback output like so (callback)='PaymentComplete($event)' to check payment status`)
45-
return true
44+
if (!this.key) { return console.error('Paystack key cannot be empty'); }
45+
if (!this.email) { return console.error('Paystack email cannot be empty'); }
46+
if (!this.amount) { return console.error('Paystack amount cannot be empty'); }
47+
if (!this.ref) { return console.error('Paystack ref cannot be empty'); }
48+
if (!this.callback.observers.length) {
49+
return console.error(`Insert a callback output like so (callback)='PaymentComplete($event)' to check payment status`);
50+
}
51+
return true;
4652
}
4753

4854
setUp() {
4955
this.paystackOptions = {
50-
container: "paystackEmbedContainer",
56+
container: 'paystackEmbedContainer',
5157
key: this.key,
5258
email: this.email,
5359
amount: this.amount,
5460
ref: this.ref,
5561
metadata: this.metadata || {},
56-
currency: this.currency || "NGN",
57-
plan: this.plan || "",
58-
quantity: this.quantity || "",
59-
subaccount: this.subaccount || "",
62+
currency: this.currency || 'NGN',
63+
plan: this.plan || '',
64+
quantity: this.quantity || '',
65+
subaccount: this.subaccount || '',
6066
transaction_charge: this.transaction_charge || 0,
61-
bearer: this.bearer || "",
67+
bearer: this.bearer || '',
6268
callback: (res) => this.callback.emit(res),
63-
onClose: () => this.close.emit(),
64-
}
69+
onClose: () => this.close && this.close.emit(),
70+
};
6571
}
6672
ngOnInit() {
6773
if (this.text) {
68-
console.error("Paystack Text input is deprecated. Add text into textnode like so <angular4-paystack>Pay With Paystack</angular4-paystack>")
74+
console.error(
75+
'Paystack Text input is deprecated. Add text into textnode like so <angular4-paystack>Pay With Paystack</angular4-paystack>'
76+
);
6977
}
70-
this.pay()
78+
this.pay();
7179
}
7280

7381
}

β€Žprojects/angular4-paystack/src/lib/angular4-paystack.component.spec.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/src/lib/angular4-paystack.component.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/src/lib/angular4-paystack.directive.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/src/lib/angular4-paystack.module.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/src/lib/paystack-options.ts

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ export interface PaystackOptions {
1212
bearer: string;
1313
callback: (reference: string) => void ;
1414
onClose: () => void;
15-
container?: string
16-
}
15+
container?: string;
16+
channels?: 'card' | 'bank' | ['card', 'bank'];
17+
}

β€Žprojects/angular4-paystack/src/public_api.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/src/test.ts

100644100755
File mode changed.

β€Žprojects/angular4-paystack/tsconfig.lib.json

100644100755
File mode changed.

β€Žprojects/angular4-paystack/tsconfig.spec.json

100644100755
File mode changed.

β€Žprojects/angular4-paystack/tslint.json

100644100755
File mode changed.

β€Žscripts/copy-artifacts.js

100644100755
File mode changed.

β€Žscripts/restore-package-json.js

100644100755
File mode changed.

β€Žsrc/app/app.component.css

100644100755
File mode changed.

β€Žsrc/app/app.component.html

100644100755
File mode changed.

β€Žsrc/app/app.component.spec.ts

100644100755
File mode changed.

β€Žsrc/app/app.component.ts

100644100755
File mode changed.

β€Žsrc/app/app.module.ts

100644100755
File mode changed.

β€Žsrc/assets/.gitkeep

100644100755
File mode changed.

β€Žsrc/browserslist

100644100755
File mode changed.

β€Žsrc/environments/environment.prod.ts

100644100755
File mode changed.

β€Žsrc/environments/environment.ts

100644100755
File mode changed.

β€Žsrc/favicon.ico

100644100755
File mode changed.

β€Žsrc/index.html

100644100755
File mode changed.

β€Žsrc/karma.conf.js

100644100755
File mode changed.

β€Žsrc/main.ts

100644100755
File mode changed.

β€Žsrc/polyfills.ts

100644100755
File mode changed.

β€Žsrc/styles.css

100644100755
File mode changed.

β€Žsrc/test.ts

100644100755
File mode changed.

β€Žsrc/tsconfig.app.json

100644100755
File mode changed.

β€Žsrc/tsconfig.json

100644100755
File mode changed.

β€Žsrc/tsconfig.spec.json

100644100755
File mode changed.

β€Žsrc/tslint.json

100644100755
File mode changed.

β€Žtsconfig.json

100644100755
File mode changed.

β€Žtslint.json

100644100755
File mode changed.

β€Žwebpack.config.js

100644100755
File mode changed.

0 commit comments

Comments
Β (0)