PHP Library

Paga Collect PHP 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 composer to install paga-collect.

composer require paga/paga-collect

2. Usage

Import class

To use Paga-collect, you would need to import it

 require_once __DIR__ .'/vendor/autoload.php;
 use PagaCollect\PagaCollectClient;

Once installed to use the library see sample code below:

$collectAPI = PagaCollectClient::builder()
    ->setClientId("<publicId>")
    ->setAPIKey("<HMAC>")
    ->setPassword("<secretKey>")
    ->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 the sample code below:

$data = ["referenceNumber" => "908w1111000001129",
    "amount" => 200,
    "callBackUrl" => "http://localhost:5000/core/webhook/paga",
    "currency" => "NGN",
    "expiryDateTimeUTC" => "2021-05-20T19:35:47",
    "isAllowPartialPayments" => false,
    "isSuppressMessages" => false,
    "payee" => ["bankAccountNumber"=>"2097582221",
              "bankId" => "40090E2F-7446-4217-9345-7BBAB7043C4C",
              "name" => "Odun Ransome",
              "phoneNumber" => "08034882885",
            "accountNumber" => "2856196652"],
    "payer" => ["email" => "[email protected]", 
                "name"=> "Zubair Abubakar", 
                "bankId"=> "40090E2F-7446-4217-9345-7BBAB7043C4C",
      ],
    "payerCollectionFeeShare"=> 1.0,
    "recipientCollectionFeeShare"=> 0.0,
    "paymentMethods"=> ["BANK_TRANSFER", "FUNDING_USSD"]
    ];

$paymentRequest = $collectAPI->paymentRequest($data);
echo $paymentRequest;

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 sample code below:

$data= [
    'referenceNumber'=>"475758538595",
    'phoneNumber'=>"07048376234",
    'firstName'=>"Ian", 
    'lastName'=>"Lankasy",
    'accountName'=>"Ian Lankasy", 
    'financialIdentificationNumber'=>"12345454326",
    'accountReference'=>"123467891334",
    'callbackUrl' => "http://localhost:9091/test-callback"
];

$payment_request= $collectAPI->registerPersistentPaymentAccount($data);

echo $payment_request;

Query Status

Query the current status of a submitted request


To check the status of a submitted request see sample code below:

$getStatus = $collectAPI ->paymentStatus(['referenceNumber' => "53w111100000112"]);
echo $getStatus;

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:

$data = [
    "referenceNumber" => "8235346400000099",
    "startDateTimeUTC" => "2021-04-21T19:15:22",
    "endDateTimeUTC" => "2021-05-18T19:15:22"
];

$paymentHistory = $collectAPI->paymentHistory($data);
echo $paymentHistory;

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:

$getBanks = $collectAPI ->getBanks(['referenceNumber' => "234455555"]);
echo $getBanks;

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.


See usage sample code below:

$data= [
    'referenceNumber'=>"47575685389595",
    'phoneNumber'=>"07048576234",
    'firstName'=>"Ian", 
    'lastName'=>"Lankansa",
    'accountName'=>"Ian Lankansa", 
    'accountIdentifier'=>"12345484326",
    'callbackUrl' => "http://localhost:9091/test-callback"
];
$updatePersistentPaymentAccount = $collectAPI ->updatePersistentPaymentAccount($data);

Get Persistent Payment Account

A method to query the properties associated with an existing persistent payment account.


See usage sample code below:

$data= [
    'referenceNumber'=>"47575685389595",
    'accountIdentifier'=>"12345484326"
];
$getPersistentPaymentAccount = $collectAPI ->getPersistentPaymentAccount($data);

Delete Persistent Payment Account

This endpoint allows for deleting a persistent payment account.


See usage sample code below:

$data= [
    'referenceNumber'=>"47575685389595",
    'accountIdentifier'=>"12345484326"
];
$deletePersistentPaymentAccount = $collectAPI ->deletePersistentPaymentAccount($data);

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.


See usage sample code below:

$data= [
    'referenceNumber'=>"47575685389595",
    'accountIdentifier'=>"12345484326"
    'refundAmount'=>500,
    'currency'=> "NGN",
];
$paymentRequestRefund = $collectAPI ->paymentRequestRefund($data);