Skip to content

Commit a74a184

Browse files
committed
example design ups
1 parent 1339e12 commit a74a184

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

projects/angular4-paystack/src/lib/angular4-paystack-embed.component.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, Input, Output,EventEmitter, ChangeDetectionStrategy } from '@angular/core';
1+
import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
22
import { PaystackOptions } from "./paystack-options";
33

44
interface myWindow extends Window {
@@ -8,7 +8,7 @@ declare var window: Partial<myWindow>
88

99
@Component({
1010
selector: 'angular4-paystack-embed',
11-
changeDetection: ChangeDetectionStrategy.OnPush,
11+
changeDetection: ChangeDetectionStrategy.OnPush,
1212
template: `<div id="paystackEmbedContainer"></div>`
1313
})
1414

@@ -28,44 +28,44 @@ export class Angular4PaystackEmbed implements OnInit {
2828
@Output() close: EventEmitter<string> = new EventEmitter<string>()
2929
@Output() callback: EventEmitter<string> = new EventEmitter<string>()
3030
private paystackOptions: Partial<PaystackOptions>;
31-
constructor() {}
31+
constructor() { }
3232

3333
pay() {
3434
this.setUp()
3535
console.log("OK payment will begin")
36-
if(!this.checkInput()) return
36+
if (!this.checkInput()) return
3737
window.PaystackPop.setup(this.paystackOptions)
3838
}
39-
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")
39+
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")
4444
if (!this.callback.observers.length) return console.error(`Insert a callback output like so (callback)='PaymentComplete($event)' to check payment status`)
4545
return true
4646
}
47-
47+
4848
setUp() {
4949
this.paystackOptions = {
5050
container: "paystackEmbedContainer",
51-
key: this.key ,
52-
email: this.email ,
53-
amount: this.amount ,
54-
ref: this.ref ,
51+
key: this.key,
52+
email: this.email,
53+
amount: this.amount,
54+
ref: this.ref,
5555
metadata: this.metadata || {},
56-
currency: this.currency || "NGN" ,
57-
plan: this.plan || "" ,
58-
quantity: this.quantity || "" ,
59-
subaccount: this.subaccount || "" ,
60-
transaction_charge: this.transaction_charge || 0 ,
61-
bearer: this.bearer || "" ,
56+
currency: this.currency || "NGN",
57+
plan: this.plan || "",
58+
quantity: this.quantity || "",
59+
subaccount: this.subaccount || "",
60+
transaction_charge: this.transaction_charge || 0,
61+
bearer: this.bearer || "",
6262
callback: (res) => this.callback.emit(res),
6363
onClose: () => this.close.emit(),
6464
}
6565
}
6666
ngOnInit() {
67-
if(this.text) {
68-
console.error("Paystack Text input is deprecated. Add text into textnode like so <angular4-paystack>Pay With Paystack</angular4-paystack>")
67+
if (this.text) {
68+
console.error("Paystack Text input is deprecated. Add text into textnode like so <angular4-paystack>Pay With Paystack</angular4-paystack>")
6969
}
7070
this.pay()
7171
}

projects/angular4-paystack/src/lib/angular4-paystack.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
1+
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
22
import { PaystackOptions } from "./paystack-options";
33

44
interface MyWindow extends Window {
@@ -8,7 +8,6 @@ declare var window: MyWindow
88

99
@Component({
1010
selector: 'angular4-paystack',
11-
changeDetection: ChangeDetectionStrategy.OnPush,
1211
template: `<button [ngClass]="class" [ngStyle]="style" (click)="pay()">{{text}}<ng-content></ng-content></button>`,
1312
})
1413
export class Angular4PaystackComponent implements OnInit {

src/app/app.component.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
<div class="container">
2-
<div class="display-4 p-3">Title: {{ title }}</div>
3-
<h5>Result name: {{ results.name }} </h5>
4-
5-
<div>You have not paid yet</div>
6-
<!-- <app-test-comp (payment)="letMeKnow($event)"></app-test-comp> -->
1+
<div class="display-4 py-4 px-1 text-center bg-primary text-white">Angular4 Paystack</div>
2+
<div class="text-center lead">{{ title }}</div>
3+
<div class="paystack-buttons text-center d-md-flex d-lg-flex d-xl-flex justify-content-between">
74
<angular4-paystack
8-
class="m-3"
5+
[class]="'btn btn-primary m-3'"
96
[key]="'pk_test_c613fc7d428a64fd1e5daea22f8380551b28c78e'" [email]="'mailexample@mail.com'"
107
[amount]="'5000000'" [ref]="tRef" (close)="paymentCancel()" (callback)="paymentDone($event)"
118
[class]="'btn btn-primary'"
12-
>Pay With Paystack</angular4-paystack>
9+
>Pay With Paystack component</angular4-paystack>
1310

1411
<button
1512
class="btn btn-danger m-3"
1613
angular4-paystack
1714
[key]="'pk_test_c613fc7d428a64fd1e5daea22f8380551b28c78e'" [email]="'mailexample@mail.com'"
1815
[amount]="'5000000'" [ref]="tRef" (close)="paymentCancel()" (callback)="paymentDone($event)"
1916
[class]="'btn btn-primary btn-lg'"
20-
>Pay With Paystack</button>
21-
</div>
17+
>Pay With Paystack Directive</button>
18+
</div>
19+
<h3 class="text-center my-3">Paystack Embed</h3>
20+
<angular4-paystack-embed
21+
angular4-paystack
22+
[key]="'pk_test_c613fc7d428a64fd1e5daea22f8380551b28c78e'" [email]="'mailexample@mail.com'"
23+
[amount]="'5000000'" [ref]="tRef" (close)="paymentCancel()" (callback)="paymentDone($event)"
24+
[class]="'btn btn-primary btn-lg'"
25+
></angular4-paystack-embed>

src/app/app.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Component, OnInit } from '@angular/core';
66
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent implements OnInit {
9-
public title: string = 'app';
9+
public title: string = 'My app';
1010
public results = {
1111
name: ''
1212
}

0 commit comments

Comments
 (0)