PHPackages                             bsecure/bsecure-payments - 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-payments

ActiveLibrary[Payment Processing](/categories/payments)

bsecure/bsecure-payments
========================

bSecure Payment Plugin is a Php library that allows you to securely process your payments. This plugin instantly creates a form that adheres to PCI, HIPAA, GDPR, or CCPA security requirements.

1.0.0(3y ago)15MITPHPPHP &gt;=5.6

Since Jul 18Pushed 3y agoCompare

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

READMEChangelog (2)Dependencies (2)Versions (2)Used By (0)

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/b927e89ca27037c73f768014a4fd2de32029222f0948ee81377119da4cd2ee62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627365637572652f627365637572652d7061796d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bsecure/bsecure-payments)[![Latest Stable Version](https://camo.githubusercontent.com/a2da0712923fd9a3175183c4a848e5c2e40a7c289fa3a62096dafe3b4b5e3e4d/68747470733a2f2f706f7365722e707567782e6f72672f627365637572652f627365637572652d7061796d656e74732f76)](//packagist.org/packages/bsecure/bsecure-payments)[![Total Downloads](https://camo.githubusercontent.com/92e7afb0137450197dc16a5d2d79808ec3431d7b85081d470f322db86598246a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62536563757265436865636b6f75742f627365637572652d7061796d656e74732d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/bsecure/bsecure-payments)[![License](https://camo.githubusercontent.com/03feea965b4f048a93de321a1074611fd6ac56e02e44977b7fafd825bfa5effa/68747470733a2f2f706f7365722e707567782e6f72672f627365637572652f627365637572652d7061796d656e74732f6c6963656e7365)](//packagist.org/packages/bsecure/bsecure-payments)[![Build Status](https://camo.githubusercontent.com/6f8e1862e9ff8b510bbb6288d2de5998c59b268a2a1ee99cfd0a4fce7a3ea511/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d7061796d656e74732d7068702f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-payments-php/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/3f3ba4cfc80dff3cd49a9d1df45cda8315a596c61fff9b9892db73c7588d2150/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d7061796d656e74732d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-payments-php/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e30066f444187ba3826f3785668dc6387564b4a902f28621f6924da8bbb79eae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62536563757265436865636b6f75742f627365637572652d7061796d656e74732d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bSecureCheckout/bsecure-payments-php/?branch=master)

bSecure Payments
================

[](#bsecure-payments)

bSecure Payments is a library that allows you to securely process your payments. This plugin instantly creates a form that adheres to PCI, HIPAA, GDPR, or CCPA security requirements.
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.

### About bSecure Payment Plugin

[](#about-bsecure-payment-plugin)

This Payment Gateway Integration Guide is a technical integration document for merchants to integrate with bSecure Payment Plugin allowing their customers to perform e-commerce transactions over the internet.
It guides merchants on how to use various functionality of the bSecure. The Merchant can enable credit card payments over their e-commerce website with this integration:

### Who Should Read This Guide

[](#who-should-read-this-guide)

The document is intended for application developers and business analysts of merchants to allow them to integrate effectively with the bSecure Payment Plugin.

### Merchant Setup Process

[](#merchant-setup-process)

In order to process online payments using the bSecure Payment Plugin, the merchant needs to be registered on bSecure [Builder Portal](https://builder.bsecure.pk/).
The below process assumes that the merchant has been registered and all the parameters related to the merchant have been configured.
Once merchant has signed up for bSecure Builder Portal and get its payment gateway configured, the merchant will be in a position to perform test transaction using the sample code provided. Once the sample transaction has been successfully processed it indicates that all the required systems have been configured correctly and the merchant is ready to go.

#### Getting Your Credentials

[](#getting-your-credentials)

1. Go to [Builder Portal](https://builder.bsecure.pk/)
2. [App Integration](https://builder.bsecure.pk/integration-sandbox) &gt;&gt; Sandbox / Live
3. Copy **Client Id** from App Integration tab and save it in a secure file.
4. Copy **Client Secret** from App Integration tab and save it in a secure file.
5. Copy **Store Slug** from App Integration tab and save it in a secure file.
6. Get **Merchant Id** from [Builder Portal](https://builder.bsecure.pk/)

### Installation

[](#installation)

You can install the package via **composer**

` composer require bsecure/bsecure-payments`

**Prerequisites**

> PHP 7.2.5 and above

**Dependencies**

> "guzzlehttp/guzzle": "^7.2"

Usage
-----

[](#usage)

### Configuration

[](#configuration)

bSecure Payments
----------------

[](#bsecure-payments-1)

Add provider for bSecure payments in app.php

`bSecure\Payments\PaymentServiceProvider::class`

Add alias

`'BsecurePayments' => bSecure\Payments\BsecurePayments::class`

#### Publish the language file.

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

`php artisan vendor:publish --provider="bSecure\Payments\PaymentServiceProvider"`

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\Payments\PaymentServiceProvider" --tag="config"`

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

```
return [
    'client_id' => env('BSECURE_CLIENT_ID', ''),
    'integration_type' => env('BSECURE_INTEGRATION_TYPE','sandbox'), //use 'production' for live orders and 'sandbox' for testing orders. When left empty or `null` the sandbox environment will be used
    'store_slug' => env('BSECURE_STORE_SLUG'),   //If store id is not mentioned your orders will be marked against your default store
    'merchant_id' => env('BSECURE_MERCHANT_ID'),   //If store id is not mentioned your orders will be marked against your default store
];
```

#### **a) Setting up a transaction:**

[](#a-setting-up-a-transaction)

The bSecure Payment Plugin will receive an HTTP POST request from the merchant website which will contain the merchant authentication details along with the transaction details. The Payment Plugin will inquire the required details from the customer and process transaction:

##### Transaction Details

[](#transaction-details)

```
[
    'order_id' => '',
    'transaction_dt' => Carbon::now()->toString(),
    'sub_total_amt' => '',
    'discount_amt' => '',
    'total_amt' => '',
    'redirect_url' => '',
],
```

##### Customer Details

[](#customer-details)

```
[
    'name' => '',
    'country_code' => '',
    'phone_number' => '',
    'email' => '',
],
```

##### Customer Address Details

[](#customer-address-details)

```
[
    'country' => '',
    'province' => '',
    'city' => '',
    'area' => '',
    'address' => '',
],
```

### Examples

[](#examples)

#### Create Transaction

[](#create-transaction)

```
use bSecure\Payments\BsecurePayments;
```

```
$order = new BsecurePayments();

$order->setTransactionDetails($transactionDetails);
$order->setCustomer($customer);
$order->setCustomerAddress($customerAddress);

return $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',
  'store_url' => 'store-url',
  'merchant_store_name' => 'your-store-name',
  '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 native app's webview with 'checkout\_url' and provide order\_reference to it for url matching

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

```

Once transaction is created you will be able to 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\Payments\BsecurePayments;
```

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

$orderStatusUpdate = new BsecurePayments();
$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 placed. But payment is awaiting for fulfillment by the customer.1CompletedOrder fulfilled, placed and payment has also been received.2FailedPayment failed or was declined or maximum attempt for payment request reached.#### Order Status

[](#order-status)

IDValueDescription1CreatedOrder created by merchant2InitiatedCustomer landed on bSecure checkout URL. Order is awaiting fulfillment.3PlacedCustomer successfully placed the order4Awaiting ConfirmationCustomer successfully placed the order, but is awaiting for customer confirmation to authenticate the transaction.5CanceledCustomer cancelled the order at the time of confirmation.6ExpiredOrder not processed within expected time frame. timeframe7FailedMax payment attempt reached8Awaiting PaymentCustomer successfully placed the order, but is payment is due or awaiting payment### 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

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1446d ago

### Community

Maintainers

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

---

Tags

paymentpaymentsnodepayment gatewaybsecurepayment pluginbsecure-payment-plugin

### Embed Badge

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

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

###  Alternatives

[shetabit/multipay

PHP Payment Gateway Integration Package

293361.0k4](/packages/shetabit-multipay)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.5M9](/packages/chargebee-chargebee-php)[cybersource/rest-client-php

Client SDK for CyberSource REST APIs

40952.8k6](/packages/cybersource-rest-client-php)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42361.9k4](/packages/bitpay-sdk)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4851.0k](/packages/sebdesign-laravel-viva-payments)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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