PHP code example of adelowo / gbowo-paystack

1. Go to this page and download the library: Download adelowo/gbowo-paystack 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/ */

    

adelowo / gbowo-paystack example snippets



$paystack->addPlugin(new Paystack\Customer\CreateCustomer(PaystackAdapter::API_LINK));

$data = $paystack->createCustomer(["email" => "[email protected]", "first_name" => "Lanre", "last_name" => "Adelowo"]);

//$data contains the details of the newly created customer



$paystack->addPlugin(new Paystack\Customer\UpdateCustomer(PaystackAdapter::API_LINK));

$data = $paystack->updateCustomer("customerCode", ["email" => "[email protected]"]);

//$data contains the details of the updated customer



$paystack->addPlugin(new Paystack\Transaction\DeactivateAuthorization(PaystackAdapter::API_LINK));

$isDeactivated = $paystack->deactivateAuthorization("AUTH_cod3_h3r3");

//$isDeactivated is a boolean which truthiness determines if the authorization code was succesffuly deactivated


$paystack->addPlugin(new Paystack\Transaction\ExportTransactions(PaystackAdapter::API_LINK));

//can also pass in an array into the method call,
//e.g ["settled" => true, "currency" => "NGN", "status" => "Some status"]
//The dictionary would be converted to a query string which is sent alongside the request. 
//Do review the docs for valid params.
$pathToFile = $paystack->exportTransactions();

//$pathToFile would contain a link to a csv file which you then have to download


$paystack->addPlugin(new Paystack\Transaction\GetTransaction(PaystackAdapter::API_LINK));

$data = $paystack->getTransaction("20911");

//$data would contain everything paystack knows about that transaction

$paystack->addPlugin(new Paystack\Subscription\CreateSubscription(PaystackAdapter::API_LINK));

$data = $paystack->createSubscription(string $customerCode, string $planCode, string $customerAuthCode = "");
//The customer auth code can be excluded as it is only useful for customers with multiple authorizations.
//Please check the docs.


$paystack->addPlugin(new Paystack\Subscription\GetAllSubscriptions(PaystackAdapter::API_LINK));

$data = $paystack->getAllSubscriptions();


$paystack->addPlugin(new Paystack\Subscription\GetSubscription(PaystackAdapter::API_LINK));

$data = $paystack->getSubscription("SUB_code");


$paystack->addPlugin(new Paystack\Plan\CreatePlan(PaystackAdapter::API_LINK));

$params = ["name" => "some plan", "amount" => 1000, "interval" => "hourly"];
//visit the api docs to see all possible data that can be sent

$data = $paystack->createPlan($params);


$paystack->addPlugin(new Paystack\Plan\UpdatePlan(PaystackAdapter::API_LINK));

$params = ["name" => "renaming this plan", "amount" => 2000, "interval" => "weekly"];
//visit the api docs to see all possible data that can be sent

$status = $paystack->updatePlan(
	"PLN_gx2wn530m0i3w3m",
         ["name" => "renaming this plan yet again", "amount" => \Gbowo\toKobo(200000), "interval" => "weekly"]);

	


$paystack->addPlugin(new ListBanks(PaystackAdapter::API_LINK));

$banks = $paystack->listBanks();
// $paystack->listBanks(["perPage" => 20, "page" => 2]); //show 20 banks and show results from the second page (the results are paginated) 


$paystack->addPlugin(new GetBVN(PaystackAdapter::API_LINK));
$data = $paystack->getBVN("12345678901"); //Must be 11 digits, else an exception is thrown


$paystack->addPlugin(new GetAccountDetails(PaystackAdapter::API_LINK));

//Yeah, that's a valid account number. Run the code to get my bank details and throw me some cash :)
$data = $paystack->getAccountDetails(["account_number" => "0115544526", "bank_code" => "058"]));

$paystack->addPlugin(new GetCardBIN(PaystackAdapter::API_LINK));
$data = $paystack->getCardBIN("123456");


$paystack->addPlugin(new CheckPending(PaystackAdapter::API_LINK));
$data = $paystack->checkPending($transactionRef);