By clicking the Continue button, your zenkipayKey and a code snippet that you must copy and/or adapt on your website will be displayed, said snippet brings an example of the information required to make a payment.
For the most current version we execute in a terminal in the root directory of our project:
1
npm i @zenkipay-pkg/angular
Important:In our dependency we use the version of rxjs that uses the selected Angular version, if your version of rxjs is not the one that comes by default with your version of Angular, it may give you some compatibility errors, for this you can try between versions according to your version of rxjs .
Since we have our dependency installed, we proceed to add it to our Angular module, for this we need to pass our zenkipayKey in the configuration. Here is an example:
Once you have installed and configured our module, you have at your disposal the use of the zenkipay-button component that inserts the Zenkipay payment button and our ZenkipayService that allows you to check if your merchant has the crypto love discount enabled and its percentage, or not; it also allows you to open the payment modal. Said component and service will be described below:
Zenkipay-button component
The selector of our component is zenkipay-button , it has a series of inputs and outputs, described in the following tables:
With this method you can check if your merchant has the crypto love discount enabled, for this you need to pass an object of type href="#paymentdetails"> PaymentDetails as a parameter, and it will will return the percentage of your discount through an observable, in case the discount is not enabled it will return null .
Pay method
With this method you can open the modal to make a payment, for this you need to pass an object of type href="#paymentdetails"> PaymentDetails as a parameter, it returns an observable that can emit several events of type ZenkiPayment , therefore we recommend that you save the reference of that subscription and unsubscribe as soon as the process of that particular payment is finished.
Test payment
Once you have prepared your integration, we proceed to make a test payment from your site, for this we click on the button Make a test payment with signed data , which will show you a modal like the following:
import{Component,OnInit,OnDestroy}from"@angular/core";import{PaymentDetails,Style,ZenkiPayment,ZenkipayService,}from"@zenkipay-pkg/angular";import{Observable,Subscription,switchMap}from"rxjs";import{YourApiService}from"./services/your-api/your-api.service";@Component({selector:"app-root",templateUrl:"./app.component.html",styleUrls:["./app.component.scss"],})exportclassAppComponentimplementsOnInit,OnDestroy{privatereadonly_subscriptions: Subscription[]=[];private_purchaseData!:string;private_purchaseSignature!:string;publicdiscountPercentage?: number|null;// Optional
publicstyle: Style={shape:"pill",// Optional
size:"lg",// Optional
};publicgetpaymentDetails():PaymentDetails{return{// * Your purchase data will be the same string used to create the signature
purchaseData: this._purchaseData,purchaseSignature: this._purchaseSignature,};}constructor(privatereadonly_zenkipayService: ZenkipayService,privatereadonly_yourApiService: YourApiService){}publicngOnInit():void{this._yourApiService.getPurchaseData().pipe(switchMap(({purchaseData,purchaseSignature}):Observable<number|null>=>{this._purchaseData=purchaseData;this._purchaseSignature=purchaseSignature;returnthis._zenkipayService.getDiscountPercentage(this.paymentDetails);})).subscribe((discountPercentage: number|null):void=>{this.discountPercentage=discountPercentage;});}publicngOnDestroy():void{for(leti=0;i<this._subscriptions.length;i++){this._subscriptions[i].unsubscribe();}}publiczenkiPayment(zenkiPayment: ZenkiPayment):void{console.log(zenkiPayment);}publicpayWithZenkipay():void{this._subscriptions.push(this._zenkipayService.pay(this.paymentDetails).subscribe((zenkiPayment: ZenkiPayment):void=>{console.log(zenkiPayment);}));}}