Paga provides digital payment and financial services to businesses and individuals. If you’re looking to integrate with Paga, webhooks can be used to receive notifications about events that occur within the Paga platform, such as payments and transactions.

6 Steps To Use Paga’s API With Webhook
  1. Create a beta Paga Business Account and get your API Keys
  2. Set up your own webhook server (where Paga will be pinging)
  3. Whitelist Paga’s IP address 
  4. Initiate events to test the webhooks for request-payment in the Paga Collect API
  5. Test your environment
  6. Create a live Paga Business Account and switch your API keys

How Paga Uses Webhooks To Improve Your Integration 

See This Video For API Call Demonstrations

With Paga APIs, you can set up webhooks to receive real-time notifications about specific events, such as when a payment is completed or a transaction fails.

To set up a webhook, you’ll need to provide Paga with a URL endpoint that will be called whenever the event you’re interested in occurs.

Once you have set up the webhook, Paga will send a POST request to the specified URL endpoint whenever the relevant event occurs. The request will contain a JSON payload that includes information about the event, such as the status of the transaction, the transaction ID, and other relevant details.

In your application, you’ll need to write code to handle the incoming webhook requests and process the information in the payload. This could involve updating your database, sending notifications to your users, or triggering other actions based on the information received in the webhook.

Here is a sample Node.js code for calling the requestPayment enpoint:

var https = require('follow-redirects').https;
var fs = require('fs');

var options = {
  'method': 'POST',
  'hostname': 'beta-collect.paga.com',
  'path': '/paymentRequest',
  'headers': {
    'hash': ' {{hashedData}}',
    'Authorization': 'Basic OTNEQUNCMUMtOTFEQy00QkY3LTkzNzktNEY3ODVDNUU0QzhGOnlOOEBxZVpadjdCNEdCYg==',
    'Content-Type': 'application/json'
  },
  'maxRedirects': 20
};

var req = https.request(options, function (res) {
  var chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function (chunk) {
    var body = Buffer.concat(chunks);
    console.log(body.toString());
  });

  res.on("error", function (error) {
    console.error(error);
  });
});

var postData = JSON.stringify({
  "referenceNumber": "0057543919876",
  "amount": "700000",
  "currency": "NGN",
  "payer": {
    "name": "Phem Phem",
    "phoneNumber": "08064493187",
    "email": "89657c84-9dea-4799-8352-fe48acb4881c@email.webhook.site"
  },
  "payee": {
    "name": "Topnecks Nigeria Limited",
    "phoneNumber": "08022222222"
  },
  "expiryDateTimeUTC": "2023-10-30T00:00:00",
  "isSuppressMessages": false,
  "payerCollectionFeeShare": 1,
  "payeeCollectionFeeShare": 0,
  "isAllowPartialPayments": false,
  "isAllowOverPayments": false,
  "callBackUrl": "https://webhook.site/89657c84-9dea-4799-8352-fe48acb4881c",
  "paymentMethods": [
    "BANK_TRANSFER",
    "FUNDING_USSD",
    "REQUEST_MONEY"
  ],
  "displayBankDetailToPayer": false
});

req.write(postData);

req.end();

Here is a sample Node.js Express Framework code listening for when event is triggered:

In this example, a Node application is set up with a single endpoint, /webhook, the callBackUrl in our post request, which accepts POST requests. When a webhook is triggered, the payload sent to the URL is passed to the callback function in the app.post method, which can then process the data and return a response.

We hope you found this helpful. You can always contact our Developer Marketing Team via Mail or join our PagaX Developer Community.

Comments to: How To Request Payment With Paga Collect API

Leave a Reply

%d bloggers like this: