descom/omnipay-paypal

PayPal Orders v2 (REST) driver for Omnipay

Maintainers

Package info

github.com/descom-es/omnipay-paypal

pkg:composer/descom/omnipay-paypal

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-07-08 11:55 UTC

This package is auto-updated.

Last update: 2026-07-09 11:17:27 UTC


README

PayPal Orders v2 (REST) driver for Omnipay.

Tests Analyse Style fix

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.