PHP code example of craftcodex / mpi-php-sdk

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

    

craftcodex / mpi-php-sdk example snippets


return [
    'credential' => [
        'key' => env('MPI_KEY'),
        'token' => env('MPI_TOKEN'),
    ],
    'callback_url' => env('MPI_CALLBACK_URL'),
];

use CraftCodex\MpiPhpSdk\Services\VirtualAccount;

VirtualAccount::make('va_bca')
                ->referencePrefix('PAYMENT-')
                ->callbackUrl(url('callback/va'))
                ->expiredIn(minutes: 10)
                ->displayName('Display Name')
                ->amount(1000000)
                ->send();

if ($request->successful()) {
    $response = $request->json();

    if ($response['success'] && @$response['data_payment']['status'] == 'pending') {
        // successfull response
        return;
    }

    if ($response['error_code']) {
        // Error response
        return;
    }
}
bash
composer 
bash
php artisan vendor:publish --tag="mpi-php-sdk-config"