Skip to content

Commit

Permalink
updated callback functions order
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Ighalo committed Aug 19, 2020
1 parent 09dca34 commit c3880a5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "my-workspace",
"version": "0.0.0",
"version": "1.0.1",
"scripts": {
"ng": "ng",
"start": "ng serve",
Expand Down
8 changes: 5 additions & 3 deletions projects/seerbit-anguar-demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ export class AppComponent {
available_quantities = [1,2,3]

PaymentDone(response) {
console.log('callback')
console.log(response) /*response of transaction*/
}
PaymentCancel(response) {

console.log('cancel')
console.log(response)
}

cartTotalCost = ()=>{
Expand Down Expand Up @@ -57,7 +59,7 @@ export class AppComponent {
"description": "TEST",
"country": "NG",
"amount": this.cart_total_cost,
"callbackurl": "localhost:4200",//Replace this with URL available on the WWW
"public_key": "SBPUBK_CECPLUSINMDQIHH3GYV2NNYHGPV9JEKQ", //replace this with your own public key from your Merchant Dashboard
"callbackurl": "",//Replace this with URL available on the WWW
"public_key": "SBTESTPUBK_dhrpzbRpR34l6VmqkCFOKA94L5E1jSTu", //replace this with your own public key from your Merchant Dashboard
};
}
5 changes: 5 additions & 0 deletions projects/seerbit-angular/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions projects/seerbit-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seerbit-angular",
"version": "0.0.2",
"version": "1.0.1",
"peerDependencies": {
"@angular/common": "^8.2.14",
"@angular/core": "^8.2.14"
Expand All @@ -20,4 +20,4 @@
"seerbit",
"payments"
]
}
}
12 changes: 9 additions & 3 deletions projects/seerbit-angular/src/lib/seer-bit.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, OnInit, Output, Input, EventEmitter, HostListener } from '@angular/core';
import { PrivateSeerBitOptions, SeerBitOptions } from './models/SeerBitOptions';
import { SeerbitService } from './seerbit-service';

interface MyWindow extends Window {
SeerbitPay:
{
(options: any, close: any, callback: any)
(options: any,callback: any, close: any)
};
}
declare var window: MyWindow;
Expand All @@ -19,10 +20,13 @@ export class SeerBitComponent {
@Output() callback: EventEmitter<any> = new EventEmitter<any>();
@Output() close: EventEmitter<any> = new EventEmitter<any>();
private _options: Partial<PrivateSeerBitOptions>;
closeFn: any; callbackFn: any;
closeFn: any;
callbackFn: any;

constructor(private seerBitService: SeerbitService) {

}

generateOptions(obj: any) {
this._options = this.seerBitService.getSeerBitOptions(obj);
this.closeFn = (...response) => {
Expand All @@ -40,7 +44,9 @@ export class SeerBitComponent {
}
return this.seerBitService.checkInput(obj);
}

@HostListener('click')

async buttonClick() {
this.pay();
}
Expand All @@ -52,6 +58,6 @@ export class SeerBitComponent {
return errorText;
}
await this.seerBitService.loadScript();
window.SeerbitPay(this._options, this.closeFn, this.callbackFn)
window.SeerbitPay(this._options, this.callbackFn,this.closeFn)
}
}
11 changes: 6 additions & 5 deletions projects/seerbit-angular/src/lib/seer-bit.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ interface MyWindow extends Window {
SeerbitPay:
{
(options: any,
close: any,
callback: any)
callback: any,
close: any
)
};
}
declare var window: MyWindow;
Expand All @@ -28,7 +29,7 @@ export class SeerBitButtonDirective {
private _options: Partial<PrivateSeerBitOptions>;
closeFn:any; callbackFn:any;
constructor(private seerBitService: SeerbitService) {
console.log(seerBitService)
// console.log(seerBitService)
}

async pay() {
Expand All @@ -40,7 +41,7 @@ console.log(seerBitService)
return errorText;
}
await this.seerBitService.loadScript();
window.SeerbitPay(this._options, this.closeFn, this.callbackFn)
window.SeerbitPay(this._options, this.callbackFn,this.closeFn)
}
generateOptions(obj: any) {
this._options = this.seerBitService.getSeerBitOptions(obj);
Expand All @@ -55,7 +56,7 @@ console.log(seerBitService)
}
validateInput(obj: SeerBitOptions) {
if (!this.callback.observers.length) {
return 'Seerbit: Insert a callback output like so (callback)=\'PaymentComplete($event)\' to check payment status';
return 'Seerbit: Insert a callback function like so (callback)=\'PaymentComplete($event)\' to check payment status';
}
return this.seerBitService.checkInput(obj);
}
Expand Down

0 comments on commit c3880a5

Please sign in to comment.