From a74a184f625b3c60aedf91dd108ad98609a34d19 Mon Sep 17 00:00:00 2001 From: Ashinzekene Date: Thu, 17 May 2018 08:40:05 +0100 Subject: [PATCH] example design ups --- .../lib/angular4-paystack-embed.component.ts | 44 +++++++++---------- .../src/lib/angular4-paystack.component.ts | 3 +- src/app/app.component.html | 24 +++++----- src/app/app.component.ts | 2 +- 4 files changed, 38 insertions(+), 35 deletions(-) diff --git a/projects/angular4-paystack/src/lib/angular4-paystack-embed.component.ts b/projects/angular4-paystack/src/lib/angular4-paystack-embed.component.ts index d785c66..e9ffbfb 100644 --- a/projects/angular4-paystack/src/lib/angular4-paystack-embed.component.ts +++ b/projects/angular4-paystack/src/lib/angular4-paystack-embed.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, Output,EventEmitter, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { PaystackOptions } from "./paystack-options"; interface myWindow extends Window { @@ -8,7 +8,7 @@ declare var window: Partial @Component({ selector: 'angular4-paystack-embed', - changeDetection: ChangeDetectionStrategy.OnPush, + changeDetection: ChangeDetectionStrategy.OnPush, template: `
` }) @@ -28,44 +28,44 @@ export class Angular4PaystackEmbed implements OnInit { @Output() close: EventEmitter = new EventEmitter() @Output() callback: EventEmitter = new EventEmitter() private paystackOptions: Partial; - constructor() {} + constructor() { } pay() { this.setUp() console.log("OK payment will begin") - if(!this.checkInput()) return + if (!this.checkInput()) return window.PaystackPop.setup(this.paystackOptions) } - checkInput(){ - if(!this.key) return console.error("Paystack key cannot be empty") - if(!this.email) return console.error("Paystack email cannot be empty") - if(!this.amount) return console.error("Paystack amount cannot be empty") - if(!this.ref) return console.error("Paystack ref cannot be empty") + checkInput() { + if (!this.key) return console.error("Paystack key cannot be empty") + if (!this.email) return console.error("Paystack email cannot be empty") + if (!this.amount) return console.error("Paystack amount cannot be empty") + if (!this.ref) return console.error("Paystack ref cannot be empty") if (!this.callback.observers.length) return console.error(`Insert a callback output like so (callback)='PaymentComplete($event)' to check payment status`) return true } - + setUp() { this.paystackOptions = { container: "paystackEmbedContainer", - key: this.key , - email: this.email , - amount: this.amount , - ref: this.ref , + key: this.key, + email: this.email, + amount: this.amount, + ref: this.ref, metadata: this.metadata || {}, - currency: this.currency || "NGN" , - plan: this.plan || "" , - quantity: this.quantity || "" , - subaccount: this.subaccount || "" , - transaction_charge: this.transaction_charge || 0 , - bearer: this.bearer || "" , + currency: this.currency || "NGN", + plan: this.plan || "", + quantity: this.quantity || "", + subaccount: this.subaccount || "", + transaction_charge: this.transaction_charge || 0, + bearer: this.bearer || "", callback: (res) => this.callback.emit(res), onClose: () => this.close.emit(), } } ngOnInit() { - if(this.text) { - console.error("Paystack Text input is deprecated. Add text into textnode like so Pay With Paystack") + if (this.text) { + console.error("Paystack Text input is deprecated. Add text into textnode like so Pay With Paystack") } this.pay() } diff --git a/projects/angular4-paystack/src/lib/angular4-paystack.component.ts b/projects/angular4-paystack/src/lib/angular4-paystack.component.ts index 800cc95..3312747 100644 --- a/projects/angular4-paystack/src/lib/angular4-paystack.component.ts +++ b/projects/angular4-paystack/src/lib/angular4-paystack.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { PaystackOptions } from "./paystack-options"; interface MyWindow extends Window { @@ -8,7 +8,6 @@ declare var window: MyWindow @Component({ selector: 'angular4-paystack', - changeDetection: ChangeDetectionStrategy.OnPush, template: ``, }) export class Angular4PaystackComponent implements OnInit { diff --git a/src/app/app.component.html b/src/app/app.component.html index 1028292..e63e15b 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,15 +1,12 @@ -
-
Title: {{ title }}
-
Result name: {{ results.name }}
- -
You have not paid yet
- +
Angular4 Paystack
+
{{ title }}
+
Pay With Paystack + >Pay With Paystack component -
\ No newline at end of file + >Pay With Paystack Directive +
+

Paystack Embed

+ \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8684ee7..345d637 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -6,7 +6,7 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { - public title: string = 'app'; + public title: string = 'My app'; public results = { name: '' }