Paga-connect is a PHP module that helps you make API calls when processing Paga Transactions.
You need to create a Paga business account
composer require paga/paga-connect
To use Paga-connect, you would need to import it
require_once __DIR__ .'/vendor/autoload.php; use PagaConnect\PagaConnectClient;
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.
To obtain your authorisation code, click here
To get Access token, Use the authorization code gotten from the call to the backend and initialize it
$token_data = $pagaConnect->getAccessToken($authorization_code);
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");
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");
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 1 year ago