@mafpay/weblib-vue v1.1.4-beta.2
Mafpay web library Vue.js 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-vue --saveOr if you use yarn
yarn add @mafpay/weblib @mafpay/weblib-vueTo configure the minimum styles add the following styles to your main JS file:
import "../node_modules/@mafpay/weblib/dist/mafpay/mafpay.css"or import it inside your main CSS file:
@import url("../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();Create Card Payment Form
This payment form consists of five customizable UI components:
<MafpayCardNumber /><MafpayCardHolderName /><MafpayCardExpiry /><MafpayCardCvc /><MafpayCardSubmit />
that can be imported as shown in the following snippet of code
<template>
<form method="POST" action="https://payment.sandbox.mafpayments.com/tokenize">
<div class="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"/>
<MafpayCardHolderName />
<MafpayCardNumber />
<MafpayCardExpiry />
<MafpayCardCvc masked="false" />
<MafpayCardSubmit />
</div>
</form>
</template>
<script>
import Vue from "vue";
import {
MafpayCardNumber,
MafpayCardExpiry,
MafpayCardHolderName,
MafpayCardCvc,
MafpayCardSubmit
} from "@mafpay/weblib-vue"
export default Vue.extend({
components: { MafpayCardNumber, MafpayCardExpiry, MafpayCardHolderName, MafpayCardCvc, MafpayCardSubmit }
});
</script>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 Vue JS:
<template>
<MafpayCardNumber @cardNumberStatus="cardNumberStatusHandler" />
</template>
<script>
import Vue from "vue";
import {
MafpayCardNumber,
} from "@mafpay/weblib-vue"
export default Vue.extend({
components: { MafpayCardNumber },
methods: {
cardNumberStatusHandler: function(event) {
console.log(event.detail);
}
}
});
</script>Buy Now Pay Later
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-buy-now-pay-later"
To use the checkout token with our Vue JS component, please follow the example below:
<template>
<MafpayCheckout :token.prop="token" />
</template>
<script>
import Vue from "vue";
import { MafpayCheckout } from "@mafpay/weblib-vue";
export default Vue.extend({
components: { MafpayCheckout },
data: function () {
return {
token: "",
};
},
mounted: async function () {
const { checkoutToken } = await createCheckoutSession(); // createCheckoutSession() function implementation is defined by the merchant
this.token = checkoutToken;
},
});
</script>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 Vue JS:
<template>
<div>
<mafpay-threeds-component :threedsauthid.prop="threeDSAuthID" @processComplete="processCompleteHandler" />
</div>
</template>
<script>
import Vue from "vue";
import {
MafpayThreedsComponent,
} from "@mafpay/weblib-vue";
export default Vue.extend({
components: { MafpayThreedsComponent },
data: function () {
return {
threeDSAuthID: "",
};
},
methods: {
processCompleteHandler: function(event) {
console.log(event.detail);
}
},
mounted: async function () {
const { threeDSAuthID } = await createThreeDSAuthID(); // createThreeDSAuthID() function implementation is defined by the merchant
this.threeDSAuthID = threeDSAuthID;
},
});
</script>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
4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 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
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago