1.2.2-beta.2 • Published 4 years ago

@mafpay/weblib-vue v1.2.2-beta.2

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 years ago

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 --save

Or if you use yarn

yarn add @mafpay/weblib @mafpay/weblib-vue

To 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></MafpayCardNumber>
  • <MafpayCardHolderName></MafpayCardNumber>
  • <MafpayCardExpiry></MafpayCardNumber>
  • <MafpayCardCvc></MafpayCardNumber>
  • <MafpayCardSubmit></MafpayCardNumber>

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></MafpayCardHolderName>
      <MafpayCardNumber></MafpayCardNumber>
      <MafpayCardExpiry></MafpayCardExpiry>
      <MafpayCardCvc masked="false"></MafpayCardCvc>
      <MafpayCardSubmit></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"></MafpayCardNumber>
</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);
    }
  }
});
</script>

And here is an example below, to give you an idea of how to use methods with Vue JS:

<template>
  <div>
    <MafpayCardNumber ref="mafpayCardNumberRef"></MafpayCardNumber>
    <button @click="resetHandler">Reset</button>
  </div>
</template>

<script>
import Vue from "vue";
import {
  MafpayCardNumber,
} from "@mafpay/weblib-vue"

export default Vue.extend({
  components: { MafpayCardNumber },
  methods: {
    resetHandler: function() {
      this.$refs.mafpayCardNumberRef.resetField();
    }
  }
});
</script>

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 Vue JS library, please follow the example below:

<template>
  <MafpayCheckout :token.prop="token"></MafpayCheckout>
</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>
    <MafpayThreedsComponent v-if="threeDSAuthID" :threedsauthid.prop="threeDSAuthID"  @processComplete="processCompleteHandler"></MafpayThreedsComponent>
  </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);
    }
  },
  mounted: async function () {
    const { threeDSAuthID } = await createThreeDSAuthID(); // createThreeDSAuthID() function implementation is defined by the merchant
    this.threeDSAuthID = threeDSAuthID;
  },
});
</script>

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 Vue JS library, please follow the example below:

<template>
  <MafpayGooglePayButton
      token="Checkout Token"
      merchantId="Your merchant Id from Google Pay business console"
      buttonColor="white"
      enableButtonLoading="true"
      @googlePayClose="googlePayCloseHandler"
      @loadingEvent="loadingEventHandler"
  ></MafpayGooglePayButton>
</template>

<script>
import Vue from "vue";
import { MafpayGooglePayButton } from "@mafpay/weblib-vue";

export default Vue.extend({
  components: { MafpayGooglePayButton },
  methods: {
    googlePayCloseHandler: function(event) {
      console.log(event);
    },
    loadingEventHandler: function(event) {
      console.log(event);
    },
  },
});
</script>
1.3.8

3 years ago

1.3.7

3 years ago

1.4.0-beta.7

3 years ago

1.4.0-beta.5

3 years ago

1.3.6

3 years ago

1.4.0-beta.3

3 years ago

1.4.0-beta.2

3 years ago

1.4.0-beta.1

3 years ago

1.3.5

3 years ago

1.2.3-beta.20

3 years ago

1.2.3-beta.21

3 years ago

1.2.3-beta.22

3 years ago

1.2.3-beta.23

3 years ago

1.2.3-beta.24

3 years ago

1.2.3-beta.25

3 years ago

1.2.3-beta.26

3 years ago

1.2.3-beta.27

3 years ago

1.2.3-beta.15

3 years ago

1.2.3-beta.16

3 years ago

1.2.3-beta.17

3 years ago

1.2.3-beta.18

3 years ago

1.2.3-beta.19

3 years ago

1.3.4

3 years ago

1.3.2

3 years ago

1.3.0

3 years ago

1.2.3-beta.9

3 years ago

1.2.3-beta.7

4 years ago

1.2.3-beta.8

3 years ago

1.2.3-beta.5

4 years ago

1.2.3-beta.4

4 years ago

1.2.4

3 years ago

1.2.3

4 years ago

1.2.3-beta.10

3 years ago

1.2.3-beta.11

3 years ago

1.2.3-beta.13

3 years ago

1.2.3-beta.14

3 years ago

1.2.2-beta.8

4 years ago

1.2.2-beta.7

4 years ago

1.2.2-beta.6

4 years ago

1.2.2-beta.5

4 years ago

1.2.2-beta.4

4 years ago

1.2.3-beta.3

4 years ago

1.2.3-beta.1

4 years ago

1.2.3-beta.2

4 years ago

1.2.2

4 years ago

1.2.2-beta.3

4 years ago

1.2.2-beta.2

4 years ago

1.2.2-beta.1

4 years ago

1.2.1

4 years ago

1.1.4-beta.3

4 years ago

1.1.4-beta.2

4 years ago

1.1.3

4 years ago

1.1.3-beta.2

4 years ago

1.1.3-beta.1

4 years ago

1.1.2

4 years ago

1.1.2-beta.0

4 years ago

1.1.1

4 years ago

1.1.1-beta.2

4 years ago

1.1.1-beta.1

4 years ago

1.1.1-beta.0

4 years ago

1.1.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.1-beta.1

5 years ago

1.0.1-beta.0

5 years ago

1.0.0

5 years ago

1.0.0-beta.3

5 years ago