PHP code example of mirmuxsin / laravel-midtrans

1. Go to this page and download the library: Download mirmuxsin/laravel-midtrans library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mirmuxsin / laravel-midtrans example snippets


return [
    'server_key' => env('MIDTRANS_SERVER_KEY'),
    'client_key' => env('MIDTRANS_CLIENT_KEY'),

    'sandbox_server_key' => env('MIDTRANS_SB_SERVER_KEY'),
    'sandbox_client_key' => env('MIDTRANS_SB_CLIENT_KEY'),

    'is_production' => env('MIDTRANS_IS_PRODUCTION', false),
    'is_sanitized' => true,
    'is_3ds' => true,

    'append_notif_url' => null,
    'overrideNotifUrl' => null,
    'payment_idempotency_key' => null,

    'curl_options' => null,
];

use Sawirricardo\Midtrans\Laravel\Facades\Midtrans;
$transactionToken = Midtrans::client()->snap()->create(new TransactionDto());
echo $transactionToken->token;
echo $transactionToken->redirect_url;

//checkout.blade.php
// if you use Snap, you can 
bash
php artisan vendor:publish --tag="laravel-midtrans-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-midtrans-config"
bash
php artisan vendor:publish --tag="laravel-midtrans-views"