PHPackages                             danialpanah/webpay - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. danialpanah/webpay

ActiveLibrary[HTTP &amp; Networking](/categories/http)

danialpanah/webpay
==================

Laravel Package for Processing Online Payments Through Webpay Payment Gateway

1.0.0(6y ago)380MITPHP

Since Apr 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/danialrp/laravel-webpay)[ Packagist](https://packagist.org/packages/danialpanah/webpay)[ RSS](/packages/danialpanah-webpay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Laravel Webpay Payment Gateway (Bahamta)
========================================

[](#laravel-webpay-payment-gateway-bahamta)

[![Build Status](https://camo.githubusercontent.com/ec638fe902fe422b0b29a8bf9dd5ce8757771788f35c28079cc27ddb452ea713/68747470733a2f2f7472617669732d63692e6f72672f64616e69616c72702f6c61726176656c2d7765627061792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/github/danialrp/laravel-webpay)[![Latest Release on Packagist](https://camo.githubusercontent.com/952a5b4f81edb5dca71a69623d14b31adce0d9af37e22297548f0da85522ee13/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69616c70616e61682f7765627061792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danialpanah/webpay)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

- [Introduction](#introduction)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Support &amp; Security](#support-security)
- [Webpay Official Documentation](https://webpay.bahamta.com/doc/api)
- [License](#license)

Introduction
------------

[](#introduction)

Laravel package for connecting and accept payments via Webpay payment gateway in your Laravel application.

Installation
------------

[](#installation)

- Use following command to install:

```
composer require danialpanah/webpay
```

**This package supports Laravel auto-discovery feature. If you are using Laravel 5.5 or greater no need to do any further actions, otherwise follow below steps.**

- Add the service provider to your `providers[]` array in `config/app.php` in your laravel application:

```
DanialPanah\Webpay\WebpayServiceProvider::class
```

- For using Laravel Facade add the alias to your `aliases[]` array in `config/app.php` in Laravel:

```
'Webpay': DanialPanah\Webpay\Facades\Webpay::class
```

Configuration
-------------

[](#configuration)

- After installation, you need to add your Webpay api settings. You can update **config/webpay.php** published file or in you Laravel **.env** file.
- Run the following command to publish the configuration file:

```
php artisan vendor:publish --provider "DanialPanah\Webpay\WebpayServiceProvider"
```

- **config/webpay.php**

```
return [
    'api_key' => env('WEBPAY_API_KEY', ''),
    'callback_url' => env('WEBPAY_CALLBACK_URL', '')
];
```

- Add this to `.env.example` and `.env` files:

```
#Webpay API key and Settings

#your webpay api key e.g "webpay:2bbc6c62-4fe..."
WEBPAY_API_KEY=

#address of rediricting after payment e.g "/payment/test"
WEBPAY_CALLBACK_URL=

```

Usage
-----

[](#usage)

Following are some approaches which you can have for initiate a payment through Webpay package:

- Initiate Payment and Receive the Payment URL:

```
// Importing the class namespaces before using it
use DanialPanah\WebPay\Webpay;

$samplePayment = [
   'amount' => 10000,  //required
   'reference_number' => '#####',  //required - invoice number(unique)
   'payer_mobile' => '',  //optional - payer mobile number for save/load cards in gateway
   'cards' => '',  //optional - allowed cards for perform payment
];

$webPay = new Webpay();
$paymentUrl = $webPay->sendPayment($samplePayment);

```

- Using Facades (Initiate Payment):

```
use DanialPanah\WebPay\Facades\Webpay;

$paymentUrl = Webpay::sendPayment($samplePayment);

```

- Verify Payment:

```
$paymentDetails = [
   'amount' => 10000,  //required
   'reference_number' => '#####'  //required - invoice number
];

$webPay = new Webpay();
$response = $webPay->verifyPayment($paymentDetails);

```

- Using Facades (Verify Payment):

```
use DanialPanah\WebPay\Facades\Webpay;

$response = Webpay::verifyPayment($paymentDetails);

```

- Sample Response of Verify Successful Payment:

```
array: [
  "ok" => true
  "result" => {
      "state": "paid"
      "total": 10000
      "wage": 1500
      "gateway": "sep"
      "terminal": "11423087"
      "pay_ref": "KmsctypmKSs0WfEB01H3ROJPLN2ZQrauExLR90nnXk"
      "pay_trace": "228945"
      "pay_pan": "610422******8585"
      "pay_cid": "4470D3E90AA5Z3FB7B21B3348D34EE25EC331915BCQP68BC4D0D1C0678548B8D"
      "pay_time": "2020-04-02T17:47:14.391164Z"
  }
]

```

- Laravel Sample Controller:

```
