@mafpay/weblib-angular9 v1.2.3-beta.2
Mafpay web library Angular9 version
Using MAF Pay library will provide the comfort during implementing the payment page, by providing the pre-defined web components that validate and process the user inputs by its own.
MAF Pay payment services allows merchants to accept payments by integrating with the payment APIs in the Javascript Framework of their choice. It offers:
- Customizable UI components.
- Validations to limit the chances of incorrect data entry.
- An easier API integration process.
- Tokenization service to securely store customer's data.
How to setup it
In your vue project, install the dependencies for payments component:
npm install @mafpay/weblib @mafpay/weblib-angular9 --saveOr if you use yarn
yarn add @mafpay/weblib @mafpay/weblib-angular9To configure the minimum styles add the following styles into angular.json
"styles": [
"./node_modules/@mafpay/weblib/dist/mafpay/mafpay.css"
],Include MAF Pay components by calling defineCustomElements() in your main JS file:
import { defineCustomElements } from "@mafpay/weblib";
defineCustomElements();Next step is to import MAF Pay in an Angular module, as shown in the code snippet below:
import { MafpayWeblibModule } from '@mafpay/weblib-angular9';
@NgModule({
imports: [
MafpayWeblibModule
],
})
export class YourModule { }Create Card Payment Form
This payment form consists of six customizable UI components:
<mafpay-card-number></mafpay-card-number><mafpay-card-holder-name></mafpay-card-holder-name><mafpay-card-expiry></mafpay-card-expiry><mafpay-card-cvc></mafpay-card-cvc><mafpay-remember-card></mafpay-remember-card><mafpay-card-submit></mafpay-card-submit>
that can be used as shown in the following snippet of code
import { Component } from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<form method="POST" action="https://payment.sandbox.mafpayments.com/tokenize">
<div className="payment-form">
<input type="hidden" name="merchantId" value="Your Marchent ID"/>
<input type="hidden" name="apiKey" value="Your API Key"/>
<input type="hidden" name="command" value="tokenize"/>
<mafpay-card-holder-name></mafpay-card-holder-name>
<mafpay-card-number></mafpay-card-number>
<mafpay-card-expiry></mafpay-card-expiry>
<mafpay-card-cvc masked="false"></mafpay-card-cvc>
<mafpay-card-submit></mafpay-card-submit>
</div>
</form>
`,
})
export class YourComponent {
}To create the card payment form and apply the required UI customization you need to follow the steps in our integration guide: "https://apidocs.mafpayments.com/online/#web-library-create-card-payment-form"
And here is an example below, to give you an idea of how to use events with Angular:
import { Component, HostListener } from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<mafpay-card-number></mafpay-card-number>
`,
})
export class YourComponent {
@HostListener('cardNumberStatus', ['$event'])
cardNumberStatusEventHandler(event: any) {
console.log(event.detail);
}
}And here is an example below, to give you an idea of how to use methods with Angular:
import {Component, ElementRef, ViewChild} from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<mafpay-card-number #mafpayCardNumberRef></mafpay-card-number>
<button (click)="resetHandler()">Reset</button>
`,
})
export class YourComponent {
@ViewChild('mafpayCardNumberRef', { read: ElementRef }) mafpayCardNumberRef: ElementRef;
resetHandler() {
this.mafpayCardNumberRef.nativeElement.resetField();
}
}Checkout Component
To create the checkout session component and apply the required UI customization you need to follow the steps in our integration guide: "https://apidocs.mafpayments.com/online/#web-library-checkout-component"
To use the checkout token with our Angular library, please follow the example below:
import { Component, HostListener, OnInit } from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<mafpay-checkout [token]="token"></mafpay-checkout>
`,
})
export class YourComponent implements OnInit {
token: string | undefined;
ngOnInit() {
// createCheckoutSession() function implementation is defined by the merchant
this.createCheckoutSession().then(({ checkoutToken }) => {
this.token = checkoutToken;
});
}
}3D Secure 2
To create the 3DS component and apply the required customization you need to follow the steps in our integration guide: "https://apidocs.mafpayments.com/online/#web-library-3d-secure-2"
The example below gives you an idea of how to use our 3DS component with Angular:
import {Component, HostListener, OnInit} from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<mafpay-threeds-component *ngIf="threeDSAuthID" [threedsauthid]="threeDSAuthID"></mafpay-threeds-component>
`,
})
export class YourComponent implements OnInit {
threeDSAuthID: string | undefined;
ngOnInit() {
// createThreeDSAuthID() function implementation is defined by the merchant
this.createThreeDSAuthID().then(({ checkoutToken }) => {
this.threeDSAuthID = checkoutToken;
});
}
@HostListener('processComplete', ['$event'])
processCompleteEventHandler(event: any) {
console.log(event.detail);
}
}Google Pay
To create the Google Pay button component and apply the required UI customization you need to follow the steps in our integration guide: "https://apidocs.mafpayments.com/online/#web-library-google-pay"
To use the Google Pay button component with our Angular library, please follow the example below:
import {Component, HostListener} from '@angular/core';
@Component({
selector: 'app-your-component',
template: `
<mafpay-google-pay-button
token="Checkout Token"
merchantId="Your merchant Id from Google Pay business console"
buttonColor="white"
enableButtonLoading="true"
></mafpay-google-pay-button>
`,
})
export class YourComponent {
@HostListener('googlePayClose', ['$event'])
googlePayCloseHandler(event: any) {
console.log(event.detail);
}
@HostListener('loadingEvent', ['$event'])
loadingEventHandler(event: any) {
console.log(event.detail);
}
}3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago