PayPal Orders v2 (REST) driver for Omnipay.
Implements the current PayPal Orders v2 API (/v2/checkout/orders) with the redirect
approval flow: create an order, redirect the buyer to PayPal, capture on return.
composer require descom/omnipay-paypaluse Omnipay\Omnipay;
$gateway = Omnipay::create('PayPal');
$gateway->initialize([
'clientId' => 'YOUR_CLIENT_ID',
'secret' => 'YOUR_SECRET',
'testMode' => true, // sandbox
'currency' => 'EUR',
]);
$response = $gateway->purchase([
'amount' => '12.00',
'currency' => 'EUR',
'transactionId' => 'ORDER-42',
'description' => 'My order',
'returnUrl' => 'https://shop.test/paypal/return',
'cancelUrl' => 'https://shop.test/paypal/cancel',
])->send();
// Redirect the buyer (GET) to the PayPal approval page.
$response->redirect();On buyer return PayPal appends ?token={orderId} to your returnUrl. Capture the order:
$response = $gateway->completePurchase([
'token' => $_GET['token'],
])->send();
if ($response->isSuccessful()) {
// $response->getTransactionReference() -> capture id
}This is a framework-agnostic Omnipay driver: it has no Laravel dependency and ships no
routes or service providers. The buyer-return endpoint (the URL you set as returnUrl)
is the host application's responsibility — it should call completePurchase() to capture
the order and then redirect the buyer back to the storefront.
On the descom platform this return route is provided generically by
descom/payment-gateway, so no
PayPal-specific glue is required here.