Recurring Payments (Card Tokenization)

Recurring Payments is a feature on Monnify that allows you to debit a customer’s card automatically, without requiring any form of authorization. Below is a flow for a regular card transaction:

Recurring Payments

With Card Tokenization, you would be able to debit a customer’s card without requiring any input from the customer. This allows you to set up an automated system to debit your customer’s cards.


How Card Tokenization Works

  1. The first transaction requiring customer authorization is done from your web or mobile application.
  2. You get a token linked to the card.
  3. Save the card token.
  4. Charge the card using the saved token.

Charge the customer’s card from your web or mobile application.

When a customer initiates a card transaction on either your web or mobile application and provides their card details, you charge their card for that initial payment to confirm the validity of the card.


Get Card Token

Once the first card transaction is successful, you get a card token by performing a re-query on the transaction using the Get Transaction Status API. When a GET request is made to the endpoint, you'd get a response with a cardDetails object in the request body, which has the cardToken field, which holds the card’s token.


Sample response from the Get Transaction Status

json
Copy button
{
"requestSuccessful": true,
"responseMessage": "success",
"responseCode": "0",
"responseBody": {
"transactionReference": "MNFY|85|20220121154916|000006",
"paymentReference": "1642776556694",
"amountPaid": "30.00",
"totalPayable": "30.00",
"settlementAmount": "20.00",
"paidOn": "21/01/2022 03:49:28 PM",
"paymentStatus": "PAID",
"paymentDescription": "Paying for Product A",
"currency": "NGN",
"paymentMethod": "CARD",
"product": {
"type": "WEB_SDK",
"reference": "1642776556694"
},
"cardDetails": {
"cardType": "MC Scheme",
"last4": "1608",
"expMonth": "08",
"expYear": "24",
"bin": "469667",
"bankCode": "044",
"bankName": "Access bank",
"reusable": true,
"countryCode": null,
"cardToken": "MNFY_8BA4740A8ED449E7BE404335977193AC",
"supportsTokenization": true
},
"accountDetails": null,
"accountPayments": [],
"customer": {
"email": "[email protected]",
"name": "Smart Mekiliuwa"
},
"metaData": {
"deviceType": "mobile",
"ipAddress": "127.0.0.1"
}
}
}

Store Card Token

Once you have gotten the token for the transaction, you store the token and the email address used for the transaction. It is important to save the email for the original transaction with the obtained token as this pair of information must match for subsequent automated payments using the card token.


Requery to get Card Token

Inasmuch as support for tokenisation has been enabled for your integration, you can simply call the Get Transaction Status API to get the card token associated with such card.


Charge the Card Token

When a customer selects the card for a new transaction or when you want to charge them subsequently, you make a request to the Charge Card Token API with the saved token and the customer’s email. Ensure you send the same email used for the initial transaction when making this request.



Sample Error Messages

Error MessageMeaningAction
Card token has expired.This means that the supplied token has expiredRegenerate and supply a valid token
Invalid card tokenThis means that the token supplied in the request does not existCheck that the supplied token is correct and valid
Duplicate payment referenceThis implies that the payment reference used in the request payload has been previously used in the same environment by the merchantEnsure that the payment reference is unique for each request
Was this page helpful? Tell us what you think..
Copyright © 2024 Monnify