1. Go to this page and download the library: Download neputertech/getpay-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/ */
neputertech / getpay-gateway example snippets
use Illuminate\Http\Request;
use NeputerTech\GetpayGateway\Facades\Getpay;
class PaymentController
{
public function pay(Request $request)
{
$refID = 'ORD-'.now()->timestamp; // your unique order reference
// Redirects to the package's checkout route with all businessName: 'Acme Inc', // optional
imageUrl: asset('images/logo.png'), // optional
themeColor: '#2F855A', // optional (hex)
orderInfoUi: null // optional (custom UI payload)
);
}
}
use Illuminate\Http\Request;
use NeputerTech\GetpayGateway\Exceptions\GetpayException;
use NeputerTech\GetpayGateway\Facades\Getpay;
class PaymentController
{
public function callback(Request $request)
{
$token = $request->query('token');
try {
$status = Getpay::verify($token); // returns the gateway response array
// Example success check
if (data_get($status, 'message') === 'SUCCESS') {
// TODO: mark order as paid using $status
return redirect()->route('thankyou')->with('status', 'Payment successful');
}
return redirect()->route('payments.getpay.failed')
->withErrors('Payment not successful.');
} catch (GetpayException $e) {
// 4001: Token decoding failed
// 4002: Invalid token data
// 4003: Gateway error
// 4004: Transaction failed
return redirect()->route('payments.getpay.failed')
->withErrors($e->getMessage());
}
}
public function failed()
{
return back()->withErrors('Payment cancelled/failed.');
}
}