Skip to content

Commit

Permalink
Merge pull request #73 from awinnen/onInit_callback_integration
Browse files Browse the repository at this point in the history
add onInit callback handler
  • Loading branch information
Enngage authored May 28, 2019
2 parents 7eb1472 + 5626c83 commit f12e41c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions demo/app/pages/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export class HomeComponent implements AfterViewInit, OnInit {
console.log('onClick');
this.resetStatus();
},
onInit: (data, actions) => {
console.log('onInit', data, actions);
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
IOnShippingChangeActions,
IOnShippingChangeData,
IPayPalConfig,
IInitCallbackData,
IOnInitCallbackActions,
} from '../models/paypal-models';
import { PayPalScriptService } from '../services/paypal-script.service';

Expand Down Expand Up @@ -246,6 +248,11 @@ export class NgxPaypalComponent implements OnChanges, OnDestroy, AfterViewInit {
config.onClick();
}
},
onInit: (data: IInitCallbackData, actions: IOnInitCallbackActions) => {
if(config.onInit){
config.onInit(data, actions);
}
}
}).render(`#${this.payPalButtonContainerId}`);
});
}
Expand Down
15 changes: 15 additions & 0 deletions projects/ngx-paypal-lib/src/lib/models/paypal-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export interface IPayPalConfig {
* Cancel handler
*/
onCancel?: (data: ICancelCallbackData, actions: any) => void;

/**
* Init handler.
* can be used for validation, see: https://developer.paypal.com/docs/checkout/integration-features/validation/#
*/
onInit?: (data: IInitCallbackData, actions: IOnInitCallbackActions) => void;
}

export type TrueFalse = 'true' | 'false';
Expand Down Expand Up @@ -149,6 +155,15 @@ export interface IOnApproveCallbackActions {
};
}

export interface IOnInitCallbackActions {
enable: () => void;
disable: () => void;
}

export interface IInitCallbackData {

}

export interface IPayPalButtonStyle {
label?: 'paypal' | 'checkout' | 'pay' | 'installment';
size?: 'small' | 'medium' | 'large' | 'responsive';
Expand Down

0 comments on commit f12e41c

Please sign in to comment.