descom / omnipay-paypal
PayPal Orders v2 (REST) driver for Omnipay
Requires
- php: ^8.4
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- league/omnipay: ^3.2
- omnipay/common: ^3.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- guzzlehttp/psr7: ^1|^2
- omnipay/tests: ^4.1
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.5|^11.5
This package is auto-updated.
Last update: 2026-07-09 11:17:27 UTC
README
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.
Instalation
composer require descom/omnipay-paypal
Basic Usage
Create purchase request
use 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();
Complete purchase request
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 }
Framework integration
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.