1. Go to this page and download the library: Download bryceandy/laravel-selcom 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/ */
bryceandy / laravel-selcom example snippets
use Bryceandy\Selcom\Facades\Selcom;
Selcom::checkout([
'name' => "Buyer's full name",
'email' => "Buyer's email",
'phone' => "Buyer's msisdn, for example 255756334000",
'amount' => "Amount to be paid",
'transaction_id' => "Unique transaction id",
'no_redirection' => true,
// Optional fields
'currency' => 'Default is TZS',
'items' => 'Number of items purchased, default is 1',
'payment_phone' => 'The number that will make the USSD transactions, if not specified it will use the phone value',
]);
use Bryceandy\Selcom\Facades\Selcom;
return Selcom::checkout([
'name' => "Buyer's full name",
'email' => "Buyer's email",
'phone' => "Buyer's msisdn, for example 255756334000",
'amount' => "Amount to be paid",
'transaction_id' => "Unique transaction id",
]);
use Bryceandy\Selcom\Facades\Selcom;
return Selcom::cardCheckout([
'name' => "Buyer's full name",
'email' => "Buyer's email",
'phone' => "Buyer's msisdn, for example 255756334000",
'amount' => "Amount to be paid",
'transaction_id' => "Unique transaction id",
'address' => "Your buyer's address",
'postcode' => "Your buyer's postcode",
// Optional fields
'user_id' => "Buyer's user ID in your system",
'buyer_uuid' => $buyerUuid, // Important if the user has to see their saved cards.
// See the last checkout section on how to fetch a buyer's UUID
'country_code' => "Your buyer's ISO country code: Default is TZ",
'state' => "Your buyer's state: Default is Dar Es Salaam",
'city' => "Your buyer's city: Default is Dar Es Salaam",
'billing_phone' => "Your buyer's billing phone number: forexample 255756334000",
'currency' => 'Default is TZS',
'items' => 'Number of items purchased, default is 1',
]);
use Bryceandy\Selcom\Facades\Selcom;
Selcom::cardCheckout([
'name' => "Buyer's full name",
'email' => "Buyer's email",
'phone' => "Buyer's msisdn, for example 255756334000",
'amount' => "Amount to be paid",
'transaction_id' => "Unique transaction id",
'no_redirection' => true,
'user_id' => "Buyer's user ID in your system",
'buyer_uuid' => $buyerUuid, // See instructions below on how to obtain this value
'address' => "Your buyer's address",
'postcode' => "Your buyer's postcode",
// Optional fields
'country_code' => "Your buyer's ISO country code: Default is TZ",
'state' => "Your buyer's state: Default is Dar Es Salaam",
'city' => "Your buyer's city: Default is Dar Es Salaam",
'billing_phone' => "Your buyer's billing phone number: forexample 255756334000",
'currency' => 'Default is TZS',
'items' => 'Number of items purchased, default is 1',
]);
namespace App\Listeners;
use Bryceandy\Selcom\Events\CheckoutWebhookReceived;
use Bryceandy\Selcom\Facades\Selcom;
use Illuminate\Support\Facades\DB;
class ProcessWebhook
{
/**
* Handle the event.
*
* @param CheckoutWebhookReceived $event
*/
public function handle(CheckoutWebhookReceived $event)
{
// Get the order id
$orderId = $event->orderId;
// Fetch updated record in the database, and do what you need with it
$status = DB::table('selcom_payments')
->where('order_id', $orderId)
->value('payment_status');
if ($status === 'PENDING') {
Selcom::orderStatus($orderId); // Or dispatch a job minutes later to query order status
}
}
}
use Bryceandy\Selcom\Facades\Selcom;
use Illuminate\Support\Facades\DB;
$order = Selcom::orderStatus($orderId);