Download the PHP package bryceandy/laravel-selcom without Composer
On this page you can find all versions of the php package bryceandy/laravel-selcom. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bryceandy/laravel-selcom
More information about bryceandy/laravel-selcom
Files in bryceandy/laravel-selcom
Package laravel-selcom
Short Description Laravel package that integrates with Selcom APIs (Utility Payments, Wallet Cashin, Agent Cashout, C2B, Qwiksend, VCN, Checkout & International Money Transfer
License MIT
Informations about the package laravel-selcom
Selcom package for Laravel apps
This package enables Laravel developers to integrate their websites/APIs with all Selcom API services
Installation
Pre-installation requirements
- Supports Laravel projects starting version 8.*
- Minimum PHP version is 7.4
- Your server must have the cURL PHP extension (ext-curl) installed
Then proceed to install:
Configuration
To access Selcom's APIs, you will need to provide the package with access to your Selcom vendorID, API Key and Secret Key.
After obtaining the three credentials from Selcom support, add their values in the .env
variables:
Note that when starting you will be provided with test credentials.
When you change to live credentials don't forget to change SELCOM_IS_LIVE
to true
.
We are going to update more configuration settings as we move along, but feel free to publish the config to fully customize it.
Run the migration command to create a table that stores Selcom payments:
Checkout API
Checkout is the simplest Selcom API we can start processing payments with.
Checkout payments using USSD
This API automatically pulls your user's USSD payment menu directly after being called.
Note: As of now, this is only applicable to AirtelMoney and TigoPesa customers.
Other networks may use USSD checkout manually with tokens as shown with other checkout options below.
Checkout to the payments page (without cards)
The payment page contains payment options such as QR code, Masterpass, USSD wallet pull, mobile money payment with tokens.
To redirect to this page, we will use the previous example, but return without the no_redirection
option or assign it to false
:
Checkout to the payments page (with cards)
To use the cards on the payment page, return the following request:
Optionally, you may specify using the .env
file the following:
-
The page where your users will be redirected once they complete a payment:
- The page where your users will be taken when they cancel the payment process:
If you feel lazy, this package already ships with these pages for you. And if you want to customize them, run:
- Also, you can assign a prefix for the package. This will be applied to the routes and order IDs
Customizing the payment page theme
The configuration contains a colors
field which specifies the theme of your payment page.
To customize the colors, add the color values in the .env
file:
For JSON requests (API applications), this type of checkout to the payments page will return data with
payment_gateway_url
instead of redirecting to that page:
Checkout payments with cards (without navigating to the payment page)
To use a card without navigating to the payment page, you need to have already created a card for the paying user by navigating to the payment page.
This is very useful for recurring or on-demand card payments. The data is the same as the previous card checkout, except we are adding no_redirection
, user_id
& buyer_uuid
:
This method will fetch 3 saved cards of the user and try all of them until a payment is successful or all fail.
Obtaining the buyer's UUID
If this user has visited the payment page before to make a payment, then their uuid is already in the database.
Listing a user's stored cards
To fetch the user's stored cards could be useful to know if a user has cards, or if there is a need to delete.
You will require a user's ID and buyer_uuid
:
Deleting a user's stored card
To delete a user's stored card you need a buyer_uuid
and card ID obtained from fetchCards
request above.
Checkout webhook/callback
The package comes with an implementation of the payment webhook.
When Selcom sends the payment status to your site, the data in the selcom_payments
table will be updated and an event Bryceandy\Selcom\Events\CheckoutWebhookReceived
will be dispatched.
You can create a listener for the event:
Then in your listener App\Listeners\ProcessWebhook
, you can do anything with the order ID:
Check order status
To query order statuses to Selcom, simply run:
Once you have obtained the order data, you can use it as you wish. The example below updates the payment in the database:
List orders
To list all orders made to Selcom, simply indicate from_date
and to_date
:
Cancel order
To cancel a Selcom order, simply run: