PHP code example of royryando / laravel-duitku
1. Go to this page and download the library: Download royryando/laravel-duitku 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/ */
royryando / laravel-duitku example snippets
'providers' => [
Royryando\Duitku\DuitkuServiceProvider::class
];
[
...
[
'code' => 'M1',
'name' => 'Bank Mandiri',
'image' => 'https://example.com/image.jpg',
'fee' => 0
],
...
]
[
'success' => true,
'reference' => 'D7999PJ38HNY7TSKHSGX',
'payment_url' => 'https://url.to.payment.example.com/',
'va_number' => '0000123123123',
'amount' => 100000,
'message' => 'SUCCESS' // message from Duitku
]
[
'success' => false,
'message' => 'The selected payment channel not available' // message from Duitku
]
[
'reference' => 'D7999PJ38HNY7TSKHSGX', // reference code from Duitku
'amount' => 100000,
'message' => 'SUCCESS',
'code' => '00', // 00=>Success, 01=>Pending, 02=>Failed/Expired
]
use Royryando\Duitku\Http\Controllers\DuitkuBaseController;
class DuitkuController extends DuitkuBaseController
{
//
}
...
protected function onPaymentSuccess(
string $orderId, string $productDetail, int $amount, string $paymentCode,
string $shopeeUserHash, string $reference, string $additionalParam
): void
{
// Your code here
}
...
...
protected function onPaymentFailed(
string $orderId, string $productDetail, int $amount, string $paymentCode,
string $shopeeUserHash, string $reference, string $additionalParam
): void
{
// Your code here
}
...
Route::post('callback/payment', [\App\Http\Controllers\DuitkuController::class, 'paymentCallback']);
protected $except = [
'callback/payment',
];