PHP code example of bensondevs / laravel-midtrans

1. Go to this page and download the library: Download bensondevs/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/ */

    

bensondevs / laravel-midtrans example snippets


use Bensondevs\Midtrans\Models\Concerns\Billable;

class User extends Authenticatable
{
    use Billable;
}

$response = $user->snapCharge([
    'order_id' => now()->timestamp,
    'gross_amount' => 100000,
]);

$redirectUrl = $response->getRedirectUrl();

$user->refund($order, 50000, 'Customer requested refund');

$user->subscribe($plan, PaymentType::CreditCard, $cardToken);

$user->gopaySubscribe($plan);

$user->registerCard('4811111111111114', '12', '2025');

$activationUrl = $user->getGopayActivationUrl('https://yourapp.com/redirect');
bash
php artisan vendor:publish --tag=midtrans-config