Skip to content

Commit

Permalink
go to payment gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
AndikaHilmiHamdani committed Mar 20, 2022
1 parent 6bf6978 commit 29c1887
Show file tree
Hide file tree
Showing 23 changed files with 874 additions and 123 deletions.
11 changes: 11 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function initMidtrans()
{
// Set your Merchant Server Key
\Midtrans\Config::$serverKey = env('MIDTRANS_SERVER_KEY');
// Set to Development/Sandbox Environment (default). Set to true for Production Environment (accept real transaction).
\Midtrans\Config::$isProduction = false;
// Set sanitization on (default)
\Midtrans\Config::$isSanitized = true;
// Set 3DS transaction for credit card to true
\Midtrans\Config::$is3ds = true;
}
}
63 changes: 63 additions & 0 deletions app/Http/Controllers/MidtransController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class MidtransController extends Controller
{
//call initialize midtrans payment gateway
$this->initMidtrans();

$params = array(
'transaction_details' => array(
'order_id' => rand(),
'gross_amount' => 10000,
),

'item_details' => array(
array(
'id' => 'ITEM1',
'price' => 10000,
'quantity' => 1,
'name' => 'abc',
'brand' => 'def',
'categoty' => 'ghi',
'merchant_name' => 'jkl',
)
),

'customer_details' => array(
'first_name' => 'dobleh',
'last_name' => 'jamal',
'email' => 'abc@abc.com',
'phone' => '+6213456',

'billing_address' => array(
'first_name' => 'dobleh',
'last_name' => 'jamal',
'email' => 'abc@abc.com',
'phone' => '+6213456',
'address' => 'aaa',
'city' => 'bbb',
'postal_code' => '123',
'country_code' => 'IDN'
),

'shipping_address' => array(
'first_name' => 'dobleh',
'last_name' => 'jamal',
'email' => 'abc@abc.com',
'phone' => '+6213456',
'address' => 'aaa',
'city' => 'bbb',
'postal_code' => '123',
'country_code' => 'IDN'
)

)
);

$snapToken = \Midtrans\Snap::getSnapToken($params);
return view('bayar', ['snapToken' => $snapToken]);
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"laravel/sanctum": "^2.14.1",
"laravel/tinker": "^2.7",
"laravel/ui": "^3.4",
"midtrans/midtrans-php": "^2.5",
"spatie/laravel-permission": "^5.5"
},
"require-dev": {
Expand Down
57 changes: 56 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 29 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 29c1887

Please sign in to comment.