PHP code example of yogigr / payment-gateway

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

    

yogigr / payment-gateway example snippets


use yogigr\PaymentGateway\Facades\PaymentGateway;

$methods = PaymentGateway::getPaymentMethodOptions();

use yogigr\PaymentGateway\Facades\PaymentGateway;

$data = [
    'amount' => 100000,
    'email' => '[email protected]',
    'phone' => '628100000000',
    'product_details' => 'Product details',
    'merchant_order_id' => 'order id / kode',
    'invoice_id' => 'Invoice id',
    'merchant_user_info' => 'Customer info / user id', // (opsional)
    'customer_name' => 'Customer name',
    'callback_path' => '/payment/callback',
    'return_path' => '/invoices',
    'success_path' => '/invoices?status=success',
    'expiry_period' => 60, 
    'address' => 'Customer address',
    'city' => 'Customer city',
    'postal_code' => 'Postal code',
    'country_code' => 'ID'
];

$paymentMethod = 'credit_card';

$response = PaymentGateway::createInvoice($data, $paymentMethod);

if ($response->statusCode == '00') {
    redirect($response->paymentUrl);
}

use yogigr\PaymentGateway\Facades\PaymentGateway;
use Illuminate\Http\Request;

class CallbackController extends Controller
{
    public function callback(Request $request)
    {
        $result = PaymentGateway::callback($request);

        if ($result['resultCode'] === '00') { // success
            // actions if success
        }
    }
}

use yogigr\PaymentGateway\Facades\PaymentGateway;

$transaction = PaymentGateway::checkTransaction($merchantOrderId);

dd($transaction);
bash
   php artisan vendor:publish --provider="yogigr\PaymentGateway\PaymentGatewayServiceProvider" --tag="config"