Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
karim-007 committed Jan 23, 2023
1 parent dc807ed commit 0fc26c2
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 116 deletions.
Binary file modified .DS_Store
Binary file not shown.
112 changes: 59 additions & 53 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ This is a php/laravel wrapper package for [Bkash](https://developer.bka.sh/)
composer require karim007/laravel-bkash-tokenize
```

## Examples
![]()<img src="example/bkash1.png" alt="bkash" width="150" height="150">
![]()<img src="example/bkash2.png" alt="bkash" width="150" height="150">
![]()<img src="example/bkash3.png" alt="bkash" width="150" height="150">
![]()<img src="example/bkash4.png" alt="bkash" width="150" height="150">
![]()<img src="example/bkash5.png" alt="bkash" width="150" height="150">


### vendor publish (config)

```bash
Expand Down Expand Up @@ -66,14 +74,8 @@ Route::group(['middleware' => ['web']], function () {
});
```

### 3. you can also override the methods

#must be included in your controller
```
use Karim007\LaravelBkashTokenize\Facade\BkashPaymentTokenize;
```

### 4. payment page
### 3. payment page
you will find it App\Http\Controllers\BkashTokenizePaymentController
```
public function index()
{
Expand Down Expand Up @@ -104,6 +106,25 @@ public function createPayment(Request $request)
}
```
###create payment response
```array
array[
"statusCode" => "0000"
"statusMessage" => "Successful"
"paymentID" => "TR0011WQ1674418613025"
"bkashURL" => "https://sandbox.payment.bkash.com/redirect/tokenized/?paymentID=TR0011WQ1674418613025&hash=t1-54Dtkmi*wr1KeWV55Z8fl5_DqsaW2q.zQWAQrPtpMsg*5zhuy3w17ZbXEvQ)qU7IT_ ▶"
"callbackURL" => "base_url/bkash/callback"
"successCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=success"
"failureCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=failure"
"cancelledCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=cancel"
"amount" => "100"
"intent" => "sale"
"currency" => "BDT"
"paymentCreateTime" => "2023-01-23T02:16:57:784 GMT+0600"
"transactionStatus" => "Initiated"
"merchantInvoiceNumber" => "63cd99abe6bae"
]
```

### 5. callback function

Expand All @@ -127,56 +148,41 @@ public function callBack(Request $request)
```
### 5. execute payment
```php
public function executePayment($paymentID)
{
return BkashPaymentTokenize::executePayment($paymentID);
}
```

### 6. query payment

```
public function queryPayment($paymentID)
{
/*{
"paymentID":"TR0011FN1674417661851",
"mode":"0011",
"paymentCreateTime":"2023-01-23T02:01:06:713 GMT+0600",
"paymentExecuteTime":"2023-01-23T02:04:05:736 GMT+0600",
"amount":"100",
"currency":"BDT",
"intent":"sale",
"merchantInvoice":"485605798",
"trxID":"AAN20A8HOI",
"transactionStatus":"Completed",
"verificationStatus":"Complete",
"statusCode":"0000",
"statusMessage":"Successful",
"payerReference":"485605798"
}*/
return BkashPaymentTokenize::queryPayment($paymentID);
}
```

### 7. success,cancel,failure

```
private function success($message,$transId)
### 5. execute payment response
```json
{
return view('bkashT::success',compact('message','transId'));
"statusCode":"0000",
"statusMessage":"Successful",
"paymentID":"TR0011FN1674417661851",
"payerReference":"485605798",
"customerMsisdn":"01877722345",
"trxID":"AAN20A8HOI",
"amount":"100",
"transactionStatus":"Completed",
"paymentExecuteTime":"2023-01-23T02:04:05:736 GMT+0600",
"currency":"BDT",
"intent":"sale"
}
```

private function cancel($message,$transId=null)
{
return view('bkashT::failed',compact('message','transId'));
}
### 6. query payment response

private function failure($message,$transId=null)
```json
{
return view('bkashT::failed',compact('message','transId'));
"paymentID":"TR0011FN1674417661851",
"mode":"0011",
"paymentCreateTime":"2023-01-23T02:01:06:713 GMT+0600",
"paymentExecuteTime":"2023-01-23T02:04:05:736 GMT+0600",
"amount":"100",
"currency":"BDT",
"intent":"sale",
"merchantInvoice":"485605798",
"trxID":"AAN20A8HOI",
"transactionStatus":"Completed",
"verificationStatus":"Complete",
"statusCode":"0000",
"statusMessage":"Successful",
"payerReference":"485605798"
}

```
Expand Down
Binary file added example/.DS_Store
Binary file not shown.
Binary file added example/bkash1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/bkash2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/bkash3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/bkash4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added example/bkash5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 13 additions & 63 deletions src/Controllers/BkashTokenizePaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public function createPayment(Request $request)
{
$inv = uniqid();
$request['intent'] = 'sale';
$request['mode'] = '0011';
$request['mode'] = '0011'; //0011 for checkout
$request['payerReference'] = $inv;
$request['currency'] = 'BDT';
$request['amount'] = 100;
$request['amount'] = 10;
$request['merchantInvoiceNumber'] = $inv;
$request['callbackURL'] = config("bkash.callbackURL");;

Expand All @@ -29,10 +29,10 @@ public function createPayment(Request $request)
"statusMessage" => "Successful"
"paymentID" => "TR0011WQ1674418613025"
"bkashURL" => "https://sandbox.payment.bkash.com/redirect/tokenized/?paymentID=TR0011WQ1674418613025&hash=t1-54Dtkmi*wr1KeWV55Z8fl5_DqsaW2q.zQWAQrPtpMsg*5zhuy3w17ZbXEvQ)qU7IT_ ▶"
"callbackURL" => "http://127.0.0.1:8000/bkash/callback"
"successCallbackURL" => "http://127.0.0.1:8000/bkash/callback?paymentID=TR0011WQ1674418613025&status=success"
"failureCallbackURL" => "http://127.0.0.1:8000/bkash/callback?paymentID=TR0011WQ1674418613025&status=failure"
"cancelledCallbackURL" => "http://127.0.0.1:8000/bkash/callback?paymentID=TR0011WQ1674418613025&status=cancel"
"callbackURL" => "base_url/bkash/callback"
"successCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=success"
"failureCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=failure"
"cancelledCallbackURL" => "base_url/bkash/callback?paymentID=TR0011WQ1674418613025&status=cancel"
"amount" => "100"
"intent" => "sale"
"currency" => "BDT"
Expand All @@ -48,66 +48,16 @@ public function callBack(Request $request)
{
//paymentID=TR00117B1674409647770&status=success&apiVersion=1.2.0-beta
if ($request->status == 'success'){
$response = $this->executePayment($request->paymentID);
if (!$response){
$response = $this->queryPayment($request->paymentID);
$response = BkashPaymentTokenize::executePayment($request->paymentID);
if (!$response){ //if executePayment payment not found call queryPayment
$response = BkashPaymentTokenize::queryPayment($request->paymentID);
}
if (isset($response['statusCode']) && $response['statusCode'] == "0000") return $this->success('Thank you for your payment',$response['trxID']);
return $this->failure($response['statusMessage']);
if (isset($response['statusCode']) && $response['statusCode'] == "0000") return BkashPaymentTokenize::success('Thank you for your payment',$response['trxID']);
return BkashPaymentTokenize::failure($response['statusMessage']);
}else if ($request->status == 'cancel'){
return $this->cancel('Your payment is canceled');
return BkashPaymentTokenize::cancel('Your payment is canceled');
}else{
return $this->failure('Your transaction is failed');
return BkashPaymentTokenize::failure('Your transaction is failed');
}
}

public function executePayment($paymentID)
{
/*{
"statusCode":"0000",
"statusMessage":"Successful",
"paymentID":"TR0011FN1674417661851",
"payerReference":"485605798",
"customerMsisdn":"01877722345",
"trxID":"AAN20A8HOI",
"amount":"100",
"transactionStatus":"Completed",
"paymentExecuteTime":"2023-01-23T02:04:05:736 GMT+0600",
"currency":"BDT",
"intent":"sale",
}*/
return BkashPaymentTokenize::executePayment($paymentID);
}
public function queryPayment($paymentID)
{
/*{
"paymentID":"TR0011FN1674417661851",
"mode":"0011",
"paymentCreateTime":"2023-01-23T02:01:06:713 GMT+0600",
"paymentExecuteTime":"2023-01-23T02:04:05:736 GMT+0600",
"amount":"100",
"currency":"BDT",
"intent":"sale",
"merchantInvoice":"485605798",
"trxID":"AAN20A8HOI",
"transactionStatus":"Completed",
"verificationStatus":"Complete",
"statusCode":"0000",
"statusMessage":"Successful",
"payerReference":"485605798"
}*/
return BkashPaymentTokenize::queryPayment($paymentID);
}
private function success($message,$transId)
{
return view('bkashT::success',compact('message','transId'));
}
private function cancel($message,$transId=null)
{
return view('bkashT::failed',compact('message','transId'));
}
private function failure($message,$transId=null)
{
return view('bkashT::failed',compact('message','transId'));
}
}
3 changes: 3 additions & 0 deletions src/Facade/BkashPaymentTokenize.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @method static queryPayment($paymentID)
* @method static bkashSuccess($pay_success)
* @method static refreshToken()
* @method static success($message,$transId)
* @method static cancel($message,$transId=null)
* @method static failure($message,$transId=null)
*/
class BkashPaymentTokenize extends Facade
{
Expand Down
12 changes: 12 additions & 0 deletions src/Payment/TBPayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,17 @@ public function refreshToken($refresh_token)
{
return $this->getUrlToken("/checkout/token/refresh",$refresh_token);
}
public function success($message,$transId)
{
return view('bkashT::success',compact('message','transId'));
}
public function cancel($message,$transId=null)
{
return view('bkashT::failed',compact('message','transId'));
}
public function failure($message,$transId=null)
{
return view('bkashT::failed',compact('message','transId'));
}

}

0 comments on commit 0fc26c2

Please sign in to comment.