PHPackages                             bsecure/bsecure-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. bsecure/bsecure-laravel

ActiveLibrary[Payment Processing](/categories/payments)

bsecure/bsecure-laravel
=======================

Pakistan's first universal checkout solution for e-commerce stores built on woocommerce, magento, shopify and more

1.0.5(5y ago)04391[1 issues](https://github.com/bSecureCheckout/bsecure-laravel/issues)MITPHPPHP &gt;=5.6

Since Dec 16Pushed 3y agoCompare

[ Source](https://github.com/bSecureCheckout/bsecure-laravel)[ Packagist](https://packagist.org/packages/bsecure/bsecure-laravel)[ Docs](https://github.com/bSecureCheckout/bsecure-laravel)[ RSS](/packages/bsecure-bsecure-laravel/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (0)

 [![](https://camo.githubusercontent.com/b1bb89397070b6dc3deb37fba737ed350f9ef527436429074e8f2925271328dc/68747470733a2f2f627365637572652d6465762e73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f6465762f72656163745f6170702f6173736574732f7365637572655f6c6f676f2e706e67)](https://camo.githubusercontent.com/b1bb89397070b6dc3deb37fba737ed350f9ef527436429074e8f2925271328dc/68747470733a2f2f627365637572652d6465762e73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f6465762f72656163745f6170702f6173736574732f7365637572655f6c6f676f2e706e67)

[![Latest Version on Packagist](https://camo.githubusercontent.com/71359c71a7a3f4642d92d7529ee3d0da99dbe192b7b01001305c06a122f39b53/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627365637572652f627365637572652d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bsecure/bsecure-laravel)[![Latest Stable Version](https://camo.githubusercontent.com/d1df3628dc613de67434c6b71d97e257ff9e9e4bbf1cf3d92b6d155b745ab732/68747470733a2f2f706f7365722e707567782e6f72672f627365637572652f627365637572652d6c61726176656c2f76)](//packagist.org/packages/bsecure/bsecure-laravel)[![Total Downloads](https://camo.githubusercontent.com/90a07588e62ceb0ec4093a3ea84dec0adfc3e4b1f877dccbb42b3da0462048f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627365637572652f627365637572652d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bsecure/bsecure-laravel)[![License](https://camo.githubusercontent.com/1bb08bb3279f324dd2c48ae094ed447823dd721f6cf6150d17424e3385981b9d/68747470733a2f2f706f7365722e707567782e6f72672f627365637572652f627365637572652d6c61726176656c2f6c6963656e7365)](//packagist.org/packages/bsecure/bsecure-laravel)[![Build Status](https://camo.githubusercontent.com/ab5f9b68977b5cc2d6bcd8dde4d16e98bf7fc293cfacca0045784c8de99ec3f3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d6c61726176656c2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-laravel/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/f142cb2ce41f7a0cf4537de625ca7f1f233509dc83ba76f554f34cd50b5e925b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d6c61726176656c2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-laravel/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bcb495c1fcb9a1f17758463921185d7ea7dc596571b7803c4ce08fd9d167f3ae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d6c61726176656c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-laravel/?branch=master)

bSecure Checkout
================

[](#bsecure-checkout)

Pakistan's first universal checkout solution that is easy and simple to integrate on your e-commerce store.

### About bSecure Checkout

[](#about-bsecure-checkout)

It gives you an option to enable *universal-login*, *two-click checkout* and accept multiple payment method for your customers, as well as run your e-commerce store hassle free.
It is built for *desktop*, *tablet*, and *mobile devices* and is continuously tested and updated to offer a frictionless payment experience for your e-commerce store.

### Installation

[](#installation)

You can install the package via **composer**

` composer require bSecure/bsecure-laravel`

**Prerequisites**

> PHP 7.2.5 and above

**Dependencies**

> "guzzlehttp/guzzle": "^7.2"

Usage
-----

[](#usage)

### Configuration Setup

[](#configuration-setup)

By following a few simple steps, you can set up your **bSecure Checkout** and **Single-Sign-On**.

#### Getting Your Credentials

[](#getting-your-credentials)

1. Go to [Partners Portal](https://builder.bsecure.pk/)
2. [App Integration](https://builder.bsecure.pk/integration-sandbox) &gt;&gt; Sandbox / Live
3. Select Environment Type (Custom Integration)
4. Fill following fields:
    a. *Store URL* its required in any case
    b. *Login Redirect URL* Required for feature **Login with bSecure**
    c. *Checkout Redirect URL* Required for feature **Pay with bSecure**
    d. *Checkout Order Status webhook* Required for feature **Pay with bSecure**
5. Save your client credentials (Client ID and Client Secret)
6. Please make sure to keep credentials at safe place in your code

bSecure Checkout
----------------

[](#bsecure-checkout-1)

Add provider for bSecure checkout in app.php

`bSecure\UniversalCheckout\CheckoutServiceProvider::class`

Add alias

`'BsecureCheckout' => bSecure\UniversalCheckout\BsecureCheckout::class`

#### Publish the language file.

[](#publish-the-language-file)

`php artisan vendor:publish --provider="bSecure\UniversalCheckout\CheckoutServiceProvider"`

It will create a vendor/bSecure folder inside resources/lang folder. If you want to customize the error messages your can overwrite the file.

#### Publish the configuration file

[](#publish-the-configuration-file)

`php artisan vendor:publish --provider="bSecure\UniversalCheckout\CheckoutServiceProvider" --tag="config"`

A file (bSecure.php) will be placed in config folder.

```
return [
  'client_id' => env('BSECURE_CLIENT_ID', ''),
  'client_secret' => env('BSECURE_CLIENT_SECRET',''),

  'environment' => env('BSECURE_ENVIRONMENT'),
];
```

### Examples

[](#examples)

#### Create Order

[](#create-order)

To create an order you should have an order\_id, customer and products object parameters that are to be set before creating an order.

##### Create Order Request Params:

[](#create-order-request-params)

###### Product Object:

[](#product-object)

Products object should be in below mentioned format:

```
"products": [
  {
  "id": "product-id",
  "name": "product-name",
  "sku": "product-sku",
  "quantity": 0,
  "price": 0,
  "sale_price": 0,
  "image": "product-image",
  "description": "product-description",
  "short_description": "product-short-description"
  }
]

```

###### Product Options Object:

[](#product-options-object)

Products object should be in below mentioned format:

```
'product_options' =>
    array (
      0 => array (
              'id' => 'option-id(numeric)',
              'name' => 'option-name',
              'value' => array (
                0 => array (
                        'name' => 'option-value-name',
                        'price' => 'option-value-price',
                     ),
              ),
           ),
    ),

```

###### Shipment Object

[](#shipment-object)

Shipment object should be in below mentioned format:

> 1- If the merchant want his pre-specified shipment method then he should pass shipment method detail in below mentioned format:

```
"shipment": {
  "charges": "numeric",
  "method_name": "string"
}

```

###### Customer Object

[](#customer-object)

Customer object should be in below mentioned format:

> 1- If the customer has already signed-in via bSecure into your system and you have auth-code for the customer you can just pass that code in the customer object no need for the rest of the fields.

> 2- Since all the fields in Customer object are optional, if you don’t have any information about customer just pass the empty object, or if you have customer details then your customer object should be in below mentioned format:

```
"customer": {
  "name": "string",
  "email": "string",
  "country_code": "string",
  "phone_number": "string",
}

```

#### Create Order

[](#create-order-1)

```
use bSecure\UniversalCheckout\BsecureCheckout;
```

```
$order = new BsecureCheckout();

$order->setOrderId($orderId);
$order->setCustomer($customer);
$order->setCartItems($products);
$order->setShipmentDetails($shipment);

$result =  $order->createOrder();
return $result;
```

In response createOrder(), will return order expiry, checkout\_url, order\_reference and merchant\_order\_id.

```
array (
  'expiry' => '2020-11-27 10:55:14',
  'checkout_url' => 'bSecure-checkout-url',
  'order_reference' => 'bsecure-reference',
  'merchant_order_id' => 'your-order-id',
)

```

> If you are using a web-solution then simply redirect the user to checkout\_url

```
if(!empty($result['checkout_url']))
return redirect($result['checkout_url']);

```

> If you have Android or IOS SDK then initialize your sdk and provide order\_reference to it

```
if(!empty($result['order_reference']))
return $result['order_reference'];

```

When order is created successfully on bSecure, you will be redirected to bSecure SDK or bSecure checkout app where you will process your checkout.

#### Callback on Order Placement

[](#callback-on-order-placement)

Once the order is successfully placed, bSecure will redirect the customer to the url you mentioned in “Checkout redirect url” in your [environment settings](https://builder.bsecure.pk/) in Partners Portal, with one additional param “order\_ref” in the query string.

#### Order Updates

[](#order-updates)

By using order\_ref you received in the "**[Callback on Order Placement](#callback-on-order-placement)**" you can call below method to get order details.

```
use bSecure\UniversalCheckout\BsecureCheckout;
```

```
$order_ref = $order->order_ref;

$orderStatusUpdate = new BsecureCheckout();
$result =  $orderStatusUpdate->orderStatusUpdates($order_ref);
return $result;
```

#### Order Status Change Webhook

[](#order-status-change-webhook)

Whenever there is any change in order status or payment status, bSecure will send you an update with complete order details (contents will be the same as response of *[Order Updates](https://github.com/bSecureCheckout/bsecure-laravel/tree/master#order-updates)*) on the URL you mentioned in *Checkout Order Status webhook* in your environment settings in Partners Portal. (your webhook must be able to accept POST request).

In response of "**[Callback on Order Placement](#callback-on-order-placement)**" and "**[Order Updates](#order-updates)**" you will recieve complete details of your order in below mentioned format:

```
{
  "status": 200,
  "message": [
    "Request Successful"
  ],
  "body": {
    "merchant_order_id": "your-order-id",
    "order_ref": "bsecure-order-reference",
    "order_type": "App/Manual/Payment gateway",
    "placement_status": "6",
    "payment_status": null,
    "customer": {
      "name": "",
      "email": "",
      "country_code": "",
      "phone_number": "",
      "gender": "",
      "dob": ""
    },
    "payment_method": {
      "id": 5,
      "name": "Debit/Credit Card"
    },
    "card_details": {
      "card_type": null,
      "card_number": null,
      "card_expire": null,
      "card_name": null
    },
    "delivery_address": {
      "country": "",
      "province": "",
      "city": "",
      "area": "",
      "address": "",
      "lat": "",
      "long": ""
    },
    "shipment_method": {
      "id": 0,
      "name": "",
      "description": "",
      "cost": 0
    },
    "items": [
      {
        "product_id": "",
        "product_name": "",
        "product_sku": "",
        "product_qty": ""
      },
    ],
    "created_at": "",
    "time_zone": "",
    "summary": {
      "total_amount": "",
      "sub_total_amount": "",
      "discount_amount": "",
      "shipment_cost": "",
      "merchant_service_charges": ""
    }
  },
  "exception": null
}

```

### Managing Orders and Payments

[](#managing-orders-and-payments)

#### Payment Status

[](#payment-status)

IDValueDescription0PendingOrder received, no payment initiated.Awaiting payment (unpaid).1CompletedOrder fulfilled and complete. Payment also recieved.2FailedPayment failed or was declined (unpaid) or requires authentication.#### Order Status

[](#order-status)

IDValueDescription1CreatedA customer created an order but not landed on bsecure2InitiatedOrder is awaiting fulfillment.3PlacedOrder fulfilled and complete Payment received. Order is awaiting fulfillment. – requires no further action4Awaiting ConfirmationAwaiting action by the customer to authenticate the transaction.5CanceledCanceled by an admin or the customer.6ExpiredOrders that were not fulfilled within a pre-specified timeframe. timeframe7FailedPayment failed or was declined (unpaid).Note that this status may not show immediately and instead show as Pending until verified8Awaiting PaymentOrder received, no payment initiated. Awaiting payment (unpaid)bSecure Single Sign On (SSO)
----------------------------

[](#bsecure-single-sign-on-sso)

Add provider for bSecure checkout and single-sign-on in app.php

`bSecure\UniversalCheckout\SSOServiceProvider::class`

Add alias

`'BsecureSSO' => bSecure\UniversalCheckout\BsecureSSO::class`

### Publish the language file.

[](#publish-the-language-file-1)

`php artisan vendor:publish --provider="bSecure\UniversalCheckout\SSOServiceProvider"`

It will create a vendor/bSecure folder inside resources/lang folder. If you want to customize the error messages your can overwrite the file.

### Publish the configuration file

[](#publish-the-configuration-file-1)

`php artisan vendor:publish --provider="bSecure\UniversalCheckout\SSOServiceProvider" --tag="config"`

A file (bSecure.php) will be placed in config folder.

Before using bSecure SSO, you will also need to add credentials for the OAuth services your application utilizes. These credentials should be placed in your config/bSecure.php configuration file. For example:

```

return [
  'client_id' => env('BSECURE_CLIENT_ID', ''),
  'client_secret' => env('BSECURE_CLIENT_SECRET',''),

  'environment' => env('BSECURE_ENVIRONMENT'),
];

```

### Routing

[](#routing)

Next, you are ready to authenticate users! You will need two routes: one for redirecting the user to the OAuth provider, and another for receiving the customer profile from the provider after authentication. We will access BsecureSSO using the BsecureSSO Facade:

### Authenticate Client

[](#authenticate-client)

Client Authentication is of two type sdk and web client validation.

> If you are using a web-solution then use below method

```
use bSecure\UniversalCheckout\BsecureSSO;

$state = $requestData['state'];

$client = new BsecureSSO();
return $client->authenticateWebClient($state);
```

In response, authenticateWebClient will return redirect\_url, then simply redirect the user to redirect\_url

```
array (
  "redirect_url": "your-authentication-url"

)

```

> If you are using a sdk-solution then use below method

```
use bSecure\UniversalCheckout\BsecureSSO;

$state = $requestData['state'];

$client = new BsecureSSO();
return $client->authenticateSDKClient($state);
```

In response, authenticateSDKClient will return request\_id, merchant\_name and store\_url which you have to pass it to your SDK.

```
array (
  "request_id": "your-request-identifier",
  "merchant_name": "builder-company-name",
  "store_url": "builder-store-url"
)

```

### Client Authorization

[](#client-authorization)

On Successful Authorization,
bSecure will redirect to Login redirect url you provided when setting up environment in Partners portal, along with two parameters in query string: **code** and **state**

```
eg: https://my-store.com/sso-callback?code=abc&state=xyz

```

code recieved in above callback is cutsomer's auth\_code which will be further used to get customer profile.

#### Verify Callback

[](#verify-callback)

Verify the state you received in the callback by matching it to the value you stored in DB before sending the client authentication request, you should only proceed if and only if both values match.

### Get Customer Profile

[](#get-customer-profile)

Auth\_code recieved from **Client Authorization** should be passed to method below to get customer profile.

```
use bSecure\UniversalCheckout\BsecureSSO;

$auth_code = $requestData['auth_code'];

$client = new BsecureSSO();
return $client->customerProfile($auth_code);
```

In response, it will return customer name, email, phone\_number, country\_code, address book.

```
array (
    'name' => 'customer-name',
    'email' => 'customer-email',
    'phone_number' => 'customer-phone-number',
    'country_code' => customer-phone-code,
    'address' =>
        array (
          'country' => '',
          'state' => '',
          'city' => '',
          'area' => '',
          'address' => '',
          'postal_code' => '',
        ),
)

```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Contributions
-------------

[](#contributions)

**"bSecure – Your Universal Checkout"** is open source software.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~27 days

Total

6

Last Release

1904d ago

PHP version history (2 changes)1.0.0PHP ^7.2.5|^8.0

1.0.1PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/643da019ee59d48b5bdd5f319da813a392ca46c9cd6e7cf540a92aaf161fcbe4?d=identicon)[bSecure](/maintainers/bSecure)

---

Top Contributors

[![bsecureadmin](https://avatars.githubusercontent.com/u/252302712?v=4)](https://github.com/bsecureadmin "bsecureadmin (34 commits)")[![SaraHasan224](https://avatars.githubusercontent.com/u/38839068?v=4)](https://github.com/SaraHasan224 "SaraHasan224 (2 commits)")

---

Tags

SSOsingle sign onecommercee-commercepayment gatewaybsecureuniversal-checkouttwo-step-checkoutuniversal-loginfrictionless payment

### Embed Badge

![Health badge](/badges/bsecure-bsecure-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/bsecure-bsecure-laravel/health.svg)](https://phpackages.com/packages/bsecure-bsecure-laravel)
```

###  Alternatives

[shetabit/multipay

PHP Payment Gateway Integration Package

293355.3k4](/packages/shetabit-multipay)[cybersource/rest-client-php

Client SDK for CyberSource REST APIs

40930.1k6](/packages/cybersource-rest-client-php)[amsgames/laravel-shop

Package set to provide shop or e-commerce functionality (such as CART, ORDERS, TRANSACTIONS and ITEMS) to Laravel for customizable builds.

4775.9k](/packages/amsgames-laravel-shop)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4849.3k](/packages/sebdesign-laravel-viva-payments)[luigel/laravel-paymongo

A laravel wrapper for Paymongo API

7961.3k1](/packages/luigel-laravel-paymongo)[lunarphp/stripe

Stripe payment driver for Lunar.

2064.7k4](/packages/lunarphp-stripe)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
