PHP Library
Paga-Connect
Paga-connect is a PHP module that helps you make API calls when processing Paga Transactions.
1. Create Paga Business Account
You need to create a Paga business account
2. Installation
composer require paga/paga-connect
Usage
Import class
To use Paga-connect, you would need to import it
require_once __DIR__ .'/vendor/autoload.php;
use PagaConnect\PagaConnectClient;
3. Usage
Initialize the class
To Initialize the class, use your Paga client id and password, for testing, set flag to true
use PagaConnect\PagaConnectClient;
$pagaConnect = PagaConnectClient::builder()
->setPrincipal("<Paga-Client-ID>")
->setCredential("<Paga-Secret-Key>")
->setRedirectUri("<Your-Redirect-URL>")
->setScope(array('USER_DEPOSIT_FROM_CARD','MERCHANT_PAYMENT','USER_DETAILS_REQUEST'))
->setUserData(array('FIRST_NAME','LAST_NAME','USERNAME','EMAIL'))
->setIsTest(true)
->build();
As shown above, you set the principal and credential given to you by Paga, then set your Redirect URL, scope, and User data are arrays of strings and are required to inform Paga-connect which data and operations you would need and initiate for the user.
4. Paga Connect Functions
Authorisation Code
To obtain your authorisation code, click here
Access Token
To get Access token, Use the authorization code gotten from the call to the backend and initialize it
$token_data = $pagaConnect->getAccessToken($authorization_code);
Merchant Payments:
This is the operation executed to make a payment to you on behalf of the customer. To make use of this function, call the merchantPaymentin PagaConnectClient which would return a JSON.
$payment_data = $pagaConnect->merchantPayment( $token_data['access_token'],"ref-12345",500, 7101, "1wxew", "NGN");
Money Transfer:
This operation allows you to transfer money from a user's Paga account to another user whose phone number is specified in the parameter. To make use of this function, call the moneyTransfer in PagaConnectClient which would return a JSON.
$result = $pagaConnect ->moneyTransfer( $token_data['access_token'],"ref123", "2200", "08184361000", "yes");
UserDetails:
This operation allows you to get details of the user. To make use of this function, call the getUserDetails in PagaConnectClient which would return a JSON.
$result = $pagaConnect ->getUserDetails( $token_data['access_token'],"ref123");
Updated over 3 years ago