PHPackages                             sarahasan/bsecure-payment-plugin-test - 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. sarahasan/bsecure-payment-plugin-test

ActiveLibrary[Payment Processing](/categories/payments)

sarahasan/bsecure-payment-plugin-test
=====================================

bSecure Payment Plugin is a JavaScript 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.

17PHP

Since Jul 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/SaraHasan224/payment-plugin)[ Packagist](https://packagist.org/packages/sarahasan/bsecure-payment-plugin-test)[ RSS](/packages/sarahasan-bsecure-payment-plugin-test/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![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 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.

### Installation

[](#installation)

You can install the package via **composer**

` composer require bSecure/bsecure-payment-plugin-test`

**Prerequisites**

> PHP 7.2.5 and above

**Dependencies**

> "guzzlehttp/guzzle": "^7.2"

Usage
-----

[](#usage)

### Configuration

[](#configuration)

#### **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:

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', ''),
  'environment' => env('BSECURE_INTEGRATION_TYPE'),
  'store_id' => env('BSECURE_STORE_SLUG'),
];
```

### Examples

[](#examples)

#### Create Payment Transaction

[](#create-payment-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:

```
bSecurePaymentTransactionParameters.__00trid__ = '';
bSecurePaymentTransactionParameters.__01curr__ = '';
bSecurePaymentTransactionParameters.__02trdt__ = '';
bSecurePaymentTransactionParameters.__03stamt__ = '';
bSecurePaymentTransactionParameters.__04damt__ = '';
bSecurePaymentTransactionParameters.__05tamt__ = '';
bSecurePaymentTransactionParameters.__06cname__ = '';
bSecurePaymentTransactionParameters.__07ccc__ = '';
bSecurePaymentTransactionParameters.__08cphn__ = '';
bSecurePaymentTransactionParameters.__09cemail__ = '';
bSecurePaymentTransactionParameters.__10ccc__ = '';
bSecurePaymentTransactionParameters.__11cstate__ = '';
bSecurePaymentTransactionParameters.__12ccity__ = '';
bSecurePaymentTransactionParameters.__13carea__ = '';
bSecurePaymentTransactionParameters.__14cfadd__ = '';
bSecurePaymentTransactionParameters.__15mid__ = '';
bSecurePaymentTransactionParameters.__16stid__ = '';
bSecurePaymentTransactionParameters.__17seh__ = '';
bSecurePaymentTransactionParameters.__18ver__ = '';
bSecurePaymentTransactionParameters.__19lan__ = '';
bSecurePaymentTransactionParameters.__20red__ = '';
bSecurePaymentTransactionParameters.__21cenv__ = '';
```

#### Glossary

[](#glossary)

KeyPropertyTypeDefaultDescription`__00trid__`Order idstringrequiredA unique value created by the merchant to identify the transaction.`__01curr__`currencystring'PKR'Currency of Transaction amount. It has a fixed value of ***PKR***`__02trdt__`Transaction date timestringrequiredMerchant provided date and time of transaction. The format of date time should be *yyyyMMddHHmmss*.`__03stamt__`Subtotal amountstringrequiredThe transaction subtotal amount amount.`__04damt__`Discount amountstringrequiredThe transaction discount amount.`__05tamt__`Total amountstringrequiredThe transaction total amount.`__06cname__`Customer nameoptionalrequiredThe name of transaction customer`__07ccc__`Customer country codestringrequiredThe country code of transaction customer`__08cphn__`Customer phone numberstringrequiredThe phone number of transaction customer`__09cemail__`Customer email addressstringoptionalThe email address of transaction customer`__10ccc__`Customer country namestringrequiredThe country name of transaction customer. It has a fixed value of ***PK***`__11cstate__`Customer state namestringrequiredThe state name of transaction customer`__12ccity__`Customer city namestringrequiredThe city name of transaction customer`__13carea__`Customer area namestringrequiredThe area name of transaction customer`__14cfadd__`Customer formatted addressstringrequiredThe formatted address of transaction customer`__15mid__`Merchant idstringrequiredUnique Id assigned to merchant by **bSecure Builder Portal**.`__16stid__`Store slugstringrequiredUnique Slug assigned to each store by **bSecure Builder Portal**.`__17seh__`Client idstringrequiredUsed to allow the plugin .`__19lan__`Order LangstringENLanguage of Transaction. It has a fixed value of **EN**`__20red__`Redirect urlstringrequiredThe URL where merchant wants the transaction results to be shown. Once the transaction has been processed, response details will be sent over to the merchant on this URL using an HTTP POST Request.`__21cenv__`Integration typestringrequiredThe transaction integration type 1: Live 2: Sandbox#### **b) Calculating Secure hash:**

[](#b-calculating-secure-hash)

Secure Hash is used to detect whether a transaction request and response has been tampered with. The **Client Id** generated for merchant at its [App Integration](https://builder.bsecure.pk/integration-sandbox) Tab is added to the transaction message and then an SHA256 algorithm is applied to generate a secure hash. The secure hash is then sent to the receiving entity with the transaction message. Because the receiving entity is the only other entity apart from transaction initiator that knows the shared secret it recreates the same secure hash and matches it with the one in the request message. If the secure hash matches, the receiving entity continues processing the transaction. If it doesn’t match, it assumes that the transaction request has been tampered with and will stop processing the transaction and send back an error message. This is a security feature to secure the transaction and is recommended.
The pp\_SecureHash field is used for the SHA256 secure hash of initiator’s shared secret and the transaction request. The secure hash value is the Hex encoded SHA256 output of the transaction request or response fields. The order that the fields are hashed in are:

1. The Shared Secret (shared between the PG and a merchant), the system generated value, is always first.
2. Then all transaction request fields are concatenated to the Shared Secret in alphabetical order of the field name. The sort should be in ascending order of the ASCII value of each field string. If one string is an exact substring of another, the smaller string should be before the longer string. For example, Card should come before CardNum.
3. Fields must not have any spaces or separators between them and must not include any null terminating characters.
    `For example, if the Shared Secret is 0F5DD14AE2E38C7EBD8814D29CF6F6F0, and the transaction request includes the following fields:`

    ParameterSample Valuespp\_MerchantID1421pp\_OrderInfoA48cvE28pp\_Amount2995In ascending alphabetical order the transaction request fields inputted to the SHA256 hash would be: `0F5DD14AE2E38C7EBD8814D29CF6F6F02995MER123A48cvE28`
    Example of a Secure Hash Calculation 0F5DD14AE2E38C7EBD8814D29CF6F6F02995MER123A48cvE28 Merchant should also ensure that:

    1. UTF-8 encoding should be used to convert the input from a printable string to a byte array. Note that 7-bit ASCII encoding is unchanged for UTF-8.
    2. The hash output must be hex-encoded.

`Note: Inorder to calculate secure hash we are using libraries named [CryptoJS](https://www.npmjs.com/package/crypto-js)`

#### Create Order

[](#create-order)

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

```
$order = new BsecurePayments();

$order->setTransactionDetails($orderId);
$order->setCustomer($customer);

$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',
  '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 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\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

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

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.

### Community

Maintainers

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

### Embed Badge

![Health badge](/badges/sarahasan-bsecure-payment-plugin-test/health.svg)

```
[![Health](https://phpackages.com/badges/sarahasan-bsecure-payment-plugin-test/health.svg)](https://phpackages.com/packages/sarahasan-bsecure-payment-plugin-test)
```

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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