Node Library
Paga Collect Node library
The Paga Collect API allows anyone to initiate a payment request to a third party and automatically get notified when the payment request is fulfilled. This library makes it easier and faster for developers to integrate the API
1. Installation
Use the package manager npm to install paga-collect.
npm install paga-collect
2. Usage
Once installed to use the library see sample code below:
const PagaCollectClient = require('paga-collect');
const pagaCollectClient = new PagaCollectClient()
.setClientId("<publicId>")
.setPassword("<secretkey>")
.setApiKey("<HMAC>")
.setTest(true)
.build();
Paga Collect API Operations
Now that you have created a collect api object you can easily call its operations
Request Payment
Register a new request for payment between a payer and a payee. Once a payment request is initiated successfully, the payer is notified by the platform (this can be suppressed) and can proceed to authorize/execute the payment. Once the payment is fulfilled, a notification is sent to the supplied callback URL. See the callback notification section for more details.
To make a payment request see sample code below:
let data = {
"referenceNumber": "53yw19011000009112",
"amount": 200,
"callBackUrl": "http://localhost:5000/core/webhook/paga",
"currency": "NGN",
"expiryDateTimeUTC": "2021-05-20T19:35:47",
"isAllowPartialPayments": false,
"isSuppressMessages": false,
"payee": {"bankAccountNumber": "XXXXXXXXXXX",
"bankId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"name": "John Doe",
"accountNumber": "XXXXXXXXXX"},
"payer": {"email": "[email protected]",
"name": "Foo Bar",
"bankId": "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX",
"phoneNumber": "XXXXXXXXXXX"},
"payerCollectionFeeShare": 1.0,
"recipientCollectionFeeShare": 0.0,
"paymentMethods": ["BANK_TRANSFER", "FUNDING_USSD"]
}
pagaCollectClient.paymentRequest(data).then(resp => {
console.log(JSON.stringify(resp))
});
Register Persistent Payment Account
An operation for business to create Persistent Payment Account Numbers that can be assigned to their customers for payment collection.
To create a persistent payment account see the sample code below:
let data = {
"referenceNumber": "53yw19011000009112",
"phoneNumber": 07022222222,
"firstName": "John",
"lastName": "Doe",
"accountName": John DOe,
"financialIdentificationNumber": 22222222222220,
"accountReference": 2222222222,
"creditBankId": 40090E2F-7446-4217-9345-7BBAB7043C4C,
"creditBankAccountNumber": 0000000000,
"callBackUrl": "http://localhost:5000/core/webhook/paga"
}
pagaCollectClient.registerPersistentPaymentAccount(data).then(resp => {
console.log(JSON.stringify(resp))
});
Query Status
Query the current status of a submitted request
To check the status of a submitted request see the sample code below:
let data = {referenceNumber:'529383853031111'}
pagaCollectClient.paymentStatus(data).then(resp => {
console.log(JSON.stringify(resp))
});
Query History
Get payment requests for a period between given start and end dates. The period window should not exceed 1 month.
See sample code below:
let data = {
referenceNumber : "82353464000000",
startDateTimeUTC : "2021-04-19T19:15:22",
endDateTimeUTC : "2021-05-18T19:15:22"
}
pagaCollectClient.paymentHistory(data).then(resp => {
console.log(JSON.stringify(resp))
});
Get Banks
Retrieve a list of supported banks and their complementary unique ids on the bank. This is required for populating the payer (optional) and payee objects in the payment request model.
See usage sample code below:
let data = {referenceNumber:'529383853031111'}
pagaCollectClient.getBanks(data).then(resp => {
console.log(JSON.stringify(resp))
});
Update Persistent Payment Account
This endpoint allows for changing any of the account properties except the accountNumber (NUBAN) and the accounReference properties which cannot be changed. To make use of this function, call the updatePersistentPaymentAccount inside PagaCollectClient which will return a JSONObject.
See usage sample code below:
let data = {
referenceNumber: uuidv412637332,
accountIdentifier: "0013188322",
firstName: "Shane",
lastName: "Moss",
}
pagaCollectClient.updatePersistentPaymentAccount(data).then(resp => {
console.log(JSON.stringify(resp))
});
Get Persistent Payment Account
A method to query the properties associated with an existing persistent payment account.
To make use of this function, call the getPersistentPaymentAccount inside PagaCollectClient which will return a JSONObject
See usage sample code below:
let data = {
referenceNumber: uuidv4459585589292,
accountIdentifier: "0013188322",
}
pagaCollectClient.getPersistentPaymentAccount(data).then(resp => {
console.log(JSON.stringify(resp))
});
Delete Persistent Payment Account
This endpoint allows for deleting a persistent payment account.
To make use of this function, call the deletePersistentPaymentAccount inside PagaCollectClient which will return a JSONObject.
See usage sample code below:
let data = {
referenceNumber: uuidv482929200101,
accountIdentifier: "0013188322"
}
pagaCollectClient.deletePersistentPaymentAccount(data).then(resp => {
console.log(JSON.stringify(resp))
});
Payment Request Refund
This end-point can be used to either cancel or initiate a refund if we were unable to fulfill the request for one reason or the other.
To make use of this function, call the paymentRequestRefund inside PagaCollectClient which will return a JSONObject.
See usage sample code below:
let data = {
referenceNumber: "e38a59d2-ea69-456f-8b82-4a9288c83bf3",
refundAmount: 2000,
currency: "NGN",
accountIdentifier: "1030850838"
}
pagaCollectClient.paymentRequestRefund(data).then(resp => {
console.log(JSON.stringify(resp))
});
Updated about 3 years ago