B2C-Billers-PHP
This repository contains Java SDK and samples for Business to Consumer bill payments.
Prerequisites
- PHP 5+ or PHP 7
Welcome
Read our FAQs here
Biller
A biller is any Organization/Institution/Business that is able to exchange services for a fee. e.g Telecoms provider(Airtel, Glo, MTN), Government Body(Lagos State) etc.
Category
Billers are grouped under categories. For instance, all cable providers(DSTV, GOTV) can e grouped under a cable
Category.
Customer
An individual that has an intent and/or pays for any of the services offered by a Biller.
PaymentItem
A biller(e.g DSTV) can offer different services and hence different prices for them. Each of those services, falls under a payment-item and has a unique payment-item-code. We say that a user has intent to pay for a payment-item offered by a Biller. An example of a payment-item under DSTV is the DSTV Premium Bouquet
What this SDK provides for you
Get All Billers
1 2 |
Get a list of all billers supported on our platform. |
Get All Categorys
1 2 |
Get a list of all categorys and associated billers supported on our platform. |
Get All Billers under a Category
1 2 |
Get a list of all biilers under a particular category. |
Get Biller Payment Items
1 2 |
Get a list of all payment-items under aparticular Biller. |
Validate Customer
1 2 |
Validates a customer-id under a particular biller. |
Make payment for a customer
1 2 |
Makes a payment for a payment-item for a particular customer. |
Query the status of a transaction
1 2 |
Query the status of a transaction made in the past based on the Request Reference |
Quick start
Composer
1 2 |
"interswitch/interswitch": "dev-master" |
1 2 |
composer require interswitch/interswitch:dev-master |
Samples
Check out the samples folder for sample code on all the features above.
Support Team
Still experiencing issues, quickly talk to our Engineers at Support chat or Support chat and get your issues fixed in a giffy
B2C-Funds-Transfer-PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
<?php use Interswitch\Interswitch; use Interswitch\transfer\fundtransfer; use Interswitch\transfer\transferrequestbuilder; require_once __DIR__ . '/../vendor/autoload.php'; $initiatingEntityCode = "PBL"; //test clientId and clientSecret //$clientId = "IKIA2EFBE1EF63D1BBE2AF6E59100B98E1D3043F477A"; //$clientSecret = "uAk0Amg6NQwQPcnb9BTJzxvMS6Vz22octQglQ1rfrMA="; // sandbox clienId client $clientId = "IKIA6570778A3484D6F33BC7E4165ADCA6CF06B2860A"; $clientSecret = "DXfUwpuIvMAKN84kv38uspqGOsStgFS0oZMjU7bPwpU="; /***- START- ***/ /** * Interswitch.ENV_SANDBOX, is for sandbox environment * * Interswitch.ENV_PROD, is for production environment */ $transfer = new FundsTransfer($clientId,$clientSecret,Interswitch::ENV_SANDBOX); //$transfer = new FundTransfer($clientId, $clientSecret, Interswitch::ENV_PRODUCTION); // Production //$transfer = new FundTransfer($clientId, $clientSecret); // Defaults to Sandbox $bankResponse = $transfer->fetchBanks(); $bankResponseCode = json_decode($bankResponse["HTTP_CODE"]); $bankResponseBody = json_decode($bankResponse["RESPONSE_BODY"]); if($bankResponseCode == 200) { $cbnCode = $bankResponseBody->banks[0]->cbnCode;// central bank code $bankName = $bankResponseBody->banks[0]->bankName;// bank Name $bankCode = $bankResponseBody->banks[0]->bankCode;// bankcode in alphabetical form: UBA, GTB, FBN echo $cbnCode." ".$bankName." ".$bankCode."\n"; //printed response //build transfer request $request = (new TransferRequestBuilder($initiatingEntityCode)) ->amount("100000") // mandatory, minor denomination ->channel(FundsTransfer.LOCATION) // mandatory: ATM-1, POS-2, WEB-3, MOBILE-4, KIOSK-5, PCPOS-6, LOCATION-7, DIRECT DEBIT-8 ->destinationBankCode(cbnCode)/* mandatory: To be gotten from the get all banks code (transfer.fetchBanks())*/ ->toAccountNumber("0114951936") // mandatory ->requestRef("60360575603527")// mandatory ->senderPhoneNumber("07036913492") // optional ->senderEmail("grandeur_man@yahoo.com") // optional ->senderLastName("Desmond") // optional ->senderOtherNames("Samuel") // optional ->receiverPhoneNumber("07036913492") // optional ->receiverEmail("grandeur_man@yahoo.com") // optional ->receiverLastName("Desmond") // optional ->receiverOtherNames("Samuel") // optional ->fee("10000")// optional (minor denomination) ->build(); $validationResponse = $transfer->validateAccount($request); if($validationResponse["HTTP_CODE"] === 200) { $accountName =json_decode($validationResponse["RESPONSE_BODY"])->accountName; echo "Account Name is ".$accountName; } else if(!$validationResponse["HTTP_CODE"] || $validationResponse["HTTP_CODE"] != 200) { //account validation was not successful, continue on } $response = $transfer->send($request); if($response["HTTP_CODE"] === 200) { $responseBody = json_decode($response["RESPONSE_BODY"]); $mac = $responseBody->mac; $transactionDate = $responseBody->transactionDate; $responseCode = $responseBody->responseCode; echo $mac." ".$transactionDate." ".$responseCode; } else if(!$response["HTTP_CODE"] || $response["HTTP_CODE"] != 200) { var_dump($response); } } ?> |