1. Go to this page and download the library: Download joynala/multi-pay 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/ */
joynala / multi-pay example snippets
// 1. Same payload for every gateway — only the name changes
$result = MultiPay::gateway('stripe')->pay([
'amount' => 100,
'currency' => 'USD',
'order_id' => 'ORD-1001',
'customer' => ['name' => 'John Doe', 'email' => '[email protected]'],
]);
return redirect($result['payment_url']);
// 2. When the customer comes back, verify with one call
$result = MultiPay::confirm($session, $request);
if ($result->success) {
// money confirmed by the gateway — fulfil the order
}
[
'success' => true,
'gateway' => 'razorpay',
'payment_id' => 'plink_...', // gateway-side reference, stored on the session
'payment_url' => 'https://...', // send the customer here
'status' => 'pending',
'supports_iframe' => false,
'message' => 'Razorpay payment link generated successfully.',
'raw' => [...], // full gateway response
]
class PaymentController extends Controller
{
public function success(Request $request, string $session)
{
$result = MultiPay::confirm($session, $request);
if (!$result->success) {
return redirect()->route('checkout')->with('error', $result->message);
}
Order::where('order_no', MultiPay::session($session)->order_id)
->update(['status' => 'paid']);
return redirect()->route('orders.thankyou');
}
public function callback(Request $request, string $session) // server-to-server
{
MultiPay::confirm($session, $request);
return response()->json(['ok' => true]);
}
public function cancel(Request $request, string $session)
{
MultiPay::cancel($session);
return redirect()->route('checkout')->with('error', 'Payment cancelled.');
}
public function failure(Request $request, string $session)
{
$result = MultiPay::confirm($session, $request); // records the failure with gateway proof
return redirect()->route('checkout')->with('error', 'Payment failed.');
}
}
// A listener is a clean place for fulfilment logic:
class FulfilOrder
{
public function handle(PaymentSucceeded $event): void
{
Order::where('order_no', $event->session->order_id)->update(['status' => 'paid']);
}
}
$session = MultiPay::session($uuid); // fetch the PaymentSession (throws PaymentSessionNotFoundException)
MultiPay::cancel($uuid); // mark cancelled — only affects sessions still 'pending'; never downgrades a paid session