Skip to content

Commit

Permalink
update congig
Browse files Browse the repository at this point in the history
  • Loading branch information
zoranbogoevski committed Nov 15, 2023
1 parent b0fe9b0 commit d792b2e
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 17 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Halkbank Payment Gateway for Laravel

Integrate Halkbank's online payment gateway seamlessly into your Laravel application with this dedicated package. Designed specifically for Macedonian businesses, this package provides an easy-to-use interface for integrating Halkbank payment services.

## Prerequisites

Before you begin, ensure you have the following:
- PHP >= 7.4

## Installation

Follow these steps to install the package:

1. **Install via Composer**
Run the following command to install the package:
```
composer require kalimeromk/halkbank-payment
```



## Publish Configurations and Views
```
php artisan vendor:publish --provider="Kalimeromk\HalkbankPayment\HalkBankPaymentServiceProvider"
```
## Configure the Package
Edit the published config/payment.php with your Halkbank credentials and settings.
Usage

## Routes
```Initiate Payment: /payment/{amount}
Payment Success: /payment/success
Payment Failure: /payment/fail
Payment Form
Access the payment form by navigating to /payment/{amount}.
Handling Responses
Success: PaymentController@paymentSuccess
Failure: PaymentController@paymentFail
```
## Customization

Views: Customize the payment form in resources/views/vendor/payment.
Controller: Extend PaymentController to modify or add new payment processing logic.
Routes: Add new routes in your Laravel application as needed.
Configuration: Update config/payment.php for any changes in payment parameters.

3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"description": "A Laravel package for handling HalkBank payments.",
"type": "library",
"require": {
"php": "^7.2|^8.0",
"illuminate/support": "^8.0"
"php": "^7.2|^8.0"
},
"autoload": {
"psr-4": {
Expand Down
28 changes: 25 additions & 3 deletions src/Config/payment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Bank Payment Configuration
|--------------------------------------------------------------------------
|
| This configuration file provides a centralized place to set up values for
| the bank payment gateway integration.
|
| 'client_id' : Merchant ID provided by the bank.
| 'store_key' : Store key value defined by the bank.
| 'store_type' : Authentication model, e.g., '3D_PAY_HOSTING'.
| 'currency' : Currency code. ISO_4217 standard. Example: '949' for TL.
| 'transaction_type': Type of transaction, e.g., 'Auth'.
| 'ok_url' : URL to redirect to if authentication is successful.
| 'fail_url' : URL to redirect to if authentication fails.
| 'lang' : Language parameter ('tr' for Turkish, 'en' for English).
| 'layout' : Location of the master blade file for views.
|
| Credit Card Number : 4125552874276464
| Expiration Date:08/25
| CVC2 / CVV2 Number: 576
| 3D Secure Password: a
*/
'client_id' => '180000093',
'store_key' => 'TEMP0151',
'store_type' => '3D_PAY_HOSTING',
Expand All @@ -9,6 +32,5 @@
'ok_url' => 'http://localhost:87/payment-success',
'fail_url' => 'http://localhost:87/payment-fail',
'lang' => 'en',

'layout' => ''// put master blade location ,
];
'layout' => '',
];
16 changes: 10 additions & 6 deletions src/HalkBankPaymentServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Kalimeromk\HalkBankPayment;

namespace Kalimeromk\HalkbankPayment;

use Illuminate\Support\ServiceProvider;

Expand All @@ -8,17 +9,20 @@ class HalkBankPaymentServiceProvider extends ServiceProvider
public function boot(): void
{
$this->loadRoutesFrom(__DIR__.'/routes.php');
$this->loadViewsFrom(__DIR__ . '/resources/views', 'payment');
$this->loadViewsFrom(__DIR__.'/resources/views', 'payment');
$this->publishes([
__DIR__.'/Config/payment.php' => config_path('payment.php'),
], 'config');
$this->publishes([
__DIR__ . '/Config/payment.php' => config_path('payment.php'),
__DIR__ . '/resources/views' => resource_path('views/vendor/payment'),
]);
__DIR__.'/resources/views' => resource_path('views/vendor/payment'),
], 'views');
}

public function register(): void
{
$this->mergeConfigFrom(
__DIR__ . '/Config/payment.php', 'payment'
__DIR__.'/Config/payment.php',
'payment'
);
}

Expand Down
31 changes: 26 additions & 5 deletions src/Http/Controllers/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
namespace Kalimeromk\HalkbankPayment\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Contracts\View\Factory;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Application;

class PaymentController extends Controller
{
public function showPaymentForm()
/**
* @param int $amount
* @return \Illuminate\Contracts\Foundation\Application|Factory|View|Application
*/
public function showPaymentForm(int $amount)
{
$clientId = config('payment.client_id');
$amount = "9.95";
$oid = ""; // Order Id. This can be generated dynamically if needed.
$okUrl = config('payment.ok_url');
$failUrl = config('payment.fail_url');
Expand All @@ -24,9 +30,24 @@ public function showPaymentForm()
$hashstr = $clientId.$oid.$amount.$okUrl.$failUrl.$transactionType.$instalment.$rnd.$storekey;
$hash = base64_encode(pack('H*', sha1($hashstr)));

return view('payment::payment',
compact('clientId', 'amount', 'oid', 'okUrl', 'failUrl', 'transactionType', 'instalment', 'rnd', 'storekey',
'storetype', 'lang', 'currencyVal', 'hash'));
return view(
'payment::payment',
compact(
'clientId',
'amount',
'oid',
'okUrl',
'failUrl',
'transactionType',
'instalment',
'rnd',
'storekey',
'storetype',
'lang',
'currencyVal',
'hash'
)
);
}

public function paymentSuccess()
Expand Down
2 changes: 1 addition & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Kalimeromk\HalkbankPayment\Http\Controllers\PaymentController;

Route::prefix('payment')->group(function () {
Route::get('/', [PaymentController::class, 'showPaymentForm'])->name('payment.form');
Route::get('/{amount}', [PaymentController::class, 'showPaymentForm'])->name('payment.form');
Route::post('/', [PaymentController::class, 'showPaymentForm'])->name('payment.post');
Route::get('success', [PaymentController::class, 'paymentSuccess'])->name('payment.success');
Route::get('fail', [PaymentController::class, 'paymentFail'])->name('payment.fail');
Expand Down

0 comments on commit d792b2e

Please sign in to comment.