Skip to main content

Creating Payment Data

Overview

In order to process payments, you'll need to create a payment data object that contains the line items and total amount of the transaction. This guide will walk you through the steps to create a payment data object using the NGnair Payments API.

This step is similar to paylinks creation, the only difference is that instead of using our premade url and page, you'll instead just use the embedded paymentData, token and groupID attached to the response in order to process the payment.

Pre-requisites

  1. An account on NGnair.
  2. An active merchant account. You will see an active status for ready-to-use accounts.
  3. An API Key. If you don't have one, follow the steps in the API Keys guide.

API Request

Create a Paylink - Request (curl)
curl -X 'POST' \
'https://demo-be.ngnair.com/api/gateway/createCheckoutData' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"groupID": "string",
"token": "string",
"data": {
"form": {
"pricing": {
"methodVerifyOrProcess": "process",
"lineItems": [
{
"product": {
"sku": "string",
"name": "string",
"description": "string",
"price": 0
},
"amount": 0,
}
],
"amount": 0,
"tip": 0,
"tipType": "fixed",
"tax": 0,
"taxType": "fixed",
"shipping": 0
},
"allowEdit": true,
"allowExtraDiscount": true,
"allowTip": true,
"referenceID": "string",
"onSuccessURL": "string",
"onFailureURL": "string"
}
}
}'

To breakdown the request:

  1. Base URL and Headers: https://demo-be.ngnair.com/api/gateway/createCheckoutData

    • This is the endpoint for creating a new paylink. The root url may change based on the environment (sandbox, production).
    • The headers are set to accept JSON data.
  2. Request Body:

    • groupID: Your merchant group identifier
    • token: Your API key token. Specifically your private token.
    • data.form: Contains the payment form configuration
      • pricing: Payment details
        • methodVerifyOrProcess: Set to "process" for direct processing
        • lineItems: Array of products/services
          • product: Product details (SKU, name, description, price)
          • amount: Quantity of the item
        • amount: Total transaction amount
        • tip: Tip amount (optional)
        • tipType: "fixed" or "percentage"
        • tax: Tax amount (optional)
        • taxType: "fixed" or "percentage"
        • shipping: Shipping cost (optional)
      • allowEdit: Enable/disable payment form editing. Specifically the quantity per items on cart.
      • allowExtraDiscount: Enable/disable discount input of customer in the payment form.
      • allowTip: Enable/disable tipping
      • referenceID: Your internal reference number. You can use this to track the payment against your own system.
      • onSuccessURL: Redirect URL after successful payment
      • onFailureURL: Redirect URL after failed payment

Response

Create a Paylink - Response
{
"data": {
"payLinkID": "string",
"paymentData": "string",
"token": "string",
"groupID": "string",
"url": "string"
},
"token": "string",
"groupID": "string",
"url": "string"
}

To breakdown the response:

  1. Response Body:
    • data: Contains the paylink details
      • paymentData: Encrypted payment information
      • token: The public key that will be used to verify the paymentData
      • groupID: Your merchant group identifier
      • url: The payment URL to share with customers
    • token: Same as data.token
    • groupID: Same as data.groupID
    • url: Same as data.url

Sample Usage

Here's a complete example of creating a paylink for a single product:

Sample Request
curl -X 'POST' \
'https://demo-be.ngnair.com/api/gateway/createCheckoutData' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"groupID": "MID-840-04-2025-000003",
"token": "b2e1bee9-db0b-4d0a-96b5-1bb8193e69c4",
"data": {
"form": {
"pricing": {
"methodVerifyOrProcess": "process",
"lineItems": [
{
"product": {
"sku": "TSHIRT-001",
"name": "Premium T-Shirt",
"description": "100% Cotton T-Shirt",
"price": 2999
},
"amount": 1
}
],
"amount": 2999,
"tip": 0,
"tipType": "fixed",
"tax": 299,
"taxType": "fixed",
"shipping": 500
},
"allowEdit": true,
"allowExtraDiscount": false,
"allowTip": true,
"referenceID": "ORDER123",
"onSuccessURL": "https://your-store.com/success",
"onFailureURL": "https://your-store.com/failed"
}
}
}'
Sample Response
{
"data": {
"paymentData": "U2FsdGVkX1+gyTpC1+sebSC2Rj8+Yc7Kd0gn//83iElTmkrISvdwE3hgpSZOTgRhiGSpIug7LOMAZ//Vt/oFA44eSToo9wrcURcfthBDd0Tt0w4ylVs2vkwRAQRpOKN540dChMRlYPzJTVYmPYNt572wbIdp99ZpHz8qUxxzxrlQC7n6c6N3pw1YRgWEaW9pRHk7viTR+DqyETgaV3es2ah5VRL+UiALeWfHOL8NKL9qFiKuZTUUolvCOUURZH+zG8QFqjD+DKNiGID53+Tj3Q/WWqBI1hIl+iFWom2AYAUXnijttKrX7U4yNZIVqTsF/fPR98nU90m8iHHKcP40Jc4U9pnKlNqJ5j74jTa/Scc5rvnRyvmk11BLvLiQHk1hTaaPBYaqXTlzVAG14skGo/8XjxvDSIXhOYOFg74sB7j9JKZhzdp3Xb3Ap0vg6KG62j08+LqjnLC003TICq2VgvpJHakvlVg9b/GwEB9jqvihuROc13a2wXzdoO4PLwyb10C2ntkXQr0eAzGE2EqHwNGGnJ5ne/iY0TVYXjaG9CnOrMgTYclGrwksSv4uCs1XkLyvKsgGphPsY6Uesx4KhemOfnYGDRBQEgs19vcYv2fZqQFzXpa1H04eRDmf3cU5/svyL9DsfQB6rB7hmETXmj90qOKA/MdfplqsWQJgwRQ1ZSCA9QrTEkSONjP2Ae57",
"token": "a743ca68-a550-47a2-b171-adde1840c31e",
"groupID": "MID-840-04-2025-000003",
"url": "https://demo.ngnair.com/pay?token=a743ca68-a550-47a2-b171-adde1840c31e&groupID=MID-840-04-2025-000003&paymentData=U2FsdGVkX1%2BgyTpC1%2BsebSC2Rj8%2BYc7Kd0gn%2F%2F83iElTmkrISvdwE3hgpSZOTgRhiGSpIug7LOMAZ%2F%2FVt%2FoFA44eSToo9wrcURcfthBDd0Tt0w4ylVs2vkwRAQRpOKN540dChMRlYPzJTVYmPYNt572wbIdp99ZpHz8qUxxzxrlQC7n6c6N3pw1YRgWEaW9pRHk7viTR%2BDqyETgaV3es2ah5VRL%2BUiALeWfHOL8NKL9qFiKuZTUUolvCOUURZH%2BzG8QFqjD%2BDKNiGID53%2BTj3Q%2FWWqBI1hIl%2BiFWom2AYAUXnijttKrX7U4yNZIVqTsF%2FfPR98nU90m8iHHKcP40Jc4U9pnKlNqJ5j74jTa%2FScc5rvnRyvmk11BLvLiQHk1hTaaPBYaqXTlzVAG14skGo%2F8XjxvDSIXhOYOFg74sB7j9JKZhzdp3Xb3Ap0vg6KG62j08%2BLqjnLC003TICq2VgvpJHakvlVg9b%2FGwEB9jqvihuROc13a2wXzdoO4PLwyb10C2ntkXQr0eAzGE2EqHwNGGnJ5ne%2FiY0TVYXjaG9CnOrMgTYclGrwksSv4uCs1XkLyvKsgGphPsY6Uesx4KhemOfnYGDRBQEgs19vcYv2fZqQFzXpa1H04eRDmf3cU5%2FsvyL9DsfQB6rB7hmETXmj90qOKA%2FMdfplqsWQJgwRQ1ZSCA9QrTEkSONjP2Ae57"
},
"token": "a743ca68-a550-47a2-b171-adde1840c31e",
"groupID": "MID-840-04-2025-000003",
"url": "https://demo.ngnair.com/pay?token=a743ca68-a550-47a2-b171-adde1840c31e&groupID=MID-840-04-2025-000003&paymentData=U2FsdGVkX1%2BgyTpC1%2BsebSC2Rj8%2BYc7Kd0gn%2F%2F83iElTmkrISvdwE3hgpSZOTgRhiGSpIug7LOMAZ%2F%2FVt%2FoFA44eSToo9wrcURcfthBDd0Tt0w4ylVs2vkwRAQRpOKN540dChMRlYPzJTVYmPYNt572wbIdp99ZpHz8qUxxzxrlQC7n6c6N3pw1YRgWEaW9pRHk7viTR%2BDqyETgaV3es2ah5VRL%2BUiALeWfHOL8NKL9qFiKuZTUUolvCOUURZH%2BzG8QFqjD%2BDKNiGID53%2BTj3Q%2FWWqBI1hIl%2BiFWom2AYAUXnijttKrX7U4yNZIVqTsF%2FfPR98nU90m8iHHKcP40Jc4U9pnKlNqJ5j74jTa%2FScc5rvnRyvmk11BLvLiQHk1hTaaPBYaqXTlzVAG14skGo%2F8XjxvDSIXhOYOFg74sB7j9JKZhzdp3Xb3Ap0vg6KG62j08%2BLqjnLC003TICq2VgvpJHakvlVg9b%2FGwEB9jqvihuROc13a2wXzdoO4PLwyb10C2ntkXQr0eAzGE2EqHwNGGnJ5ne%2FiY0TVYXjaG9CnOrMgTYclGrwksSv4uCs1XkLyvKsgGphPsY6Uesx4KhemOfnYGDRBQEgs19vcYv2fZqQFzXpa1H04eRDmf3cU5%2FsvyL9DsfQB6rB7hmETXmj90qOKA%2FMdfplqsWQJgwRQ1ZSCA9QrTEkSONjP2Ae57"
}

In this example:

  • The price values are in cents (2999 = $29.99)
  • Tax is set to $2.99 (fixed amount)
  • Shipping is set to $5.00
  • Tips are enabled but start at 0
  • Quantity editing is allowed
  • Extra discounts are disabled

Next Steps

Once you have the payment data and customer's payment information, you can proceed to commit the payment. This will process the payment and return a payment response.