PHP code example of paga / paga-collect

1. Go to this page and download the library: Download paga/paga-collect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

paga / paga-collect example snippets





$collectClient = PagaCollectClient::builder()
                ->setApiKey("<apiKey>")
                ->setClientId("<publicId>")
                ->setPassword("<password>")
                ->setTest(true)
                ->build();

$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"=>"XXXXXXXXX",
              "bankId" => "XXXXX-XXX-XXX-XXX-XXXXXX",
              "name" => "John Doe",
              "phoneNumber" => "XXXXXXXXXXX",
            "accountNumber" => "XXXXXXXXXXX"],
    "payer" => ["email" => "[email protected]", 
                "name"=> "Foo Bar", 
                "bankId"=> "XXXXX-XXX-XXX-XXX-XXXXXX",
      ],
    "payerCollectionFeeShare"=> 1.0,
    "recipientCollectionFeeShare"=> 0.0,
    "paymentMethods"=> ["BANK_TRANSFER", "FUNDING_USSD"]
    ];

$paymentRequest = $collectClient->paymentRequest($data);$response = 


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

$data = ['referenceNumber' => "234455555"];
$paymentStatus = $collectAPI ->paymentStatus($data);

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

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

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

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

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