Link a Maya e-wallet

Why link a Maya e-wallet?

Linking a customer's Maya e-wallet will allow your business to charge a current transaction and future transaction.

In this guide you will learn how to link a customer's Maya e-wallet up to executing a payment.

Step 1 Setup Maya Business Manager

First, set up your Maya Business Manager account.

Step 2 Redirect your customer to Maya's Connect Single Sign-on page

Add a Link Maya Wallet button to your website to initiate Wallet Link.

<html>
  <head>
    <title>Wear Vamos</title>
  </head>
  <body>
    <form action="/link-maya-wallet" method="POST">
      <button type="submit">Link Maya Wallet</button>
    </form>
  </body>
</html>

The Wallet Link initiation will need the following input:

FieldDescription
redirectUrl (object) (required)An object that contains where Maya will redirect to after a successful payment. The fields supported are success, failure, cancel.
metadata (object)Used to provide additional data to the transaction such as payment faciliator information.
Optional: Initiating a payment as a Payment Facilitator

You need to provide the Payment Facilitator information in the metadata object.
Check out this guide for more details.

Metadata Object

  • subMerchantRequestReferenceNumber - Reference number of the sub-merchant for the related transaction
  • pf - For a payment facilitator, this provides details regarding the sub-merchant.
    • smi - Sub-merchant ID
    • smn - Sub-merchant name
    • mci - Sub-merchant city location
    • mpc - ISO 4217 Numeric currency code
    • mco - ISO 3166 Alpha-3 country code
    • mst - Sub-merchant abbreviated state location (required if country is USA)
    • mcc - ISO 18245 merchant category code
    • postal code - Sub-merchant postal code
    • contactNo - Contact number without spaces, dashes, or parentheses
    • state - Sub-merchant state location in full text
    • addressLine1 - Sub-merchant street address

One of the important fields when creating the wallet link is the redirectUrl in which you will pass the following:

  • success - URL of the page where your customers will be redirected after a successful payment.
  • failure - URL of the page where your customers will be redirected to when the payment fails.
  • cancel - URL of the page where your customer will be redirected when they cancel a payment.

After successfully initiating the wallet link, redirect your customer to the URL where the customer will fill-in their Maya account credentials to link their wallet while also saving the linkId on your application.

const express = require('express');
const app = express();

const fetch = require('node-fetch');

app.post('/link-maya-wallet', async (req, res) => {
  const url = 'https://pg-sandbox.paymaya.com/payby/v2/paymaya/link';
    const options = {
    method: 'POST',
    headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        Authorization: `Basic ${btoa('PUBLIC_KEY')}`
    },
    body: req.body
    };

    fetch(url, options)
    .then(res => res.json())
    .then(json => {
      saveLinkId(json.linkId)
        res.redirect(303, json.redirectUrl);
    })
    .catch(err => console.error('error:' + err));
});

app.listen(8080, () => console.log(`Listening on port ${8080}!`));

📘

Quick Test #1

At this point you will now be able to see Maya's Single Sign-on Page

  1. Click "Link Maya Wallet" button
  2. You get redirected to Maya's Single Sign-on Page
Maya's Single Sign-on PageMaya's Single Sign-on Page

Maya's Single Sign-on Page

Step 3 Success Page

Once the customer's Maya wallet is successfully linked, it should get redirected to a success page.

You need to host this success page in your website.

<html>
  <head><title>Wallet linked</title></head>
  <body>
    <h1>Wallet linked</h1>
  </body>
</html>

📘

Quick Test #2

  1. Click "Link Maya Wallet" button
  2. You get redirected to Maya's Single Sign-on Page
  3. You will have to use a test PayMaya account Sandbox Credentials and Cards
  4. On successful link, it will redirect to your success page

Step 4 Executing a payment

Once you have successfully linked the customer's wallet, you can now execute wallet payment using the linkId to charge their Maya wallet.

const express = require('express');
const app = express();

const fetch = require('node-fetch');

app.post('/wallet-link/:linkId/execute-maya-wallet-payment', async (req, res) => {
  const url = `https://pg-sandbox.paymaya.com/payby/v2/paymaya/link/${req.params.linkId}/execute`;
    const options = {
    method: 'POST',
    headers: {
        Accept: 'application/json',
        'Content-Type': 'application/json',
        Authorization: `Basic ${btoa('SECRET_KEY')}`
    },
    body: req.body
    };

    fetch(url, options)
    .then(res => res.json())
    .then(json => {
        res.send({ 
        message: 'Successful payment'
      })
    })
    .catch(err => console.error('error:' + err));
});

app.listen(8080, () => console.log(`Listening on port ${8080}!`));

You can reuse linkId for future transactions for that customer.


Did this page help you?