Skip to content

PayPal

The PayPal driver uses REST API v2 for checkout orders and OAuth 2.0 client credentials for server-to-server requests. It also provides shared subscription, payout, and payment-link operations.

Setup

PAYPAL_CLIENT_ID=your_client_id
PAYPAL_CLIENT_SECRET=your_client_secret
PAYPAL_CURRENCY=USD
PAYPAL_BASE_URL=https://api.paypal.com
PAYPAL_CALLBACK_URL=https://example.com/payment/return
PAYPAL_CANCEL_URL=https://example.com/payment/cancel
PAYPAL_WEBHOOK_ID=your_paypal_webhook_id

For sandbox, use PayPal's sandbox API base URL and sandbox application credentials. Configure a webhook ID when using PayPal's webhook signature verification; this setting is PAYPAL_WEBHOOK_ID.

Checkout and capture

use Alphabalex\PaymentMadeEasy\Facades\Payment;

$driver = Payment::driver('paypal');
$order = $driver->initializePayment([
    'amount'       => 50.00,
    'currency'     => 'USD',
    'reference'    => 'ORDER_123',
    'callback_url' => 'https://example.com/payment/return',
    'cancel_url'   => 'https://example.com/payment/cancel',
]);

// Redirect the buyer to the link whose rel is "approve".
// After approval, capture/complete through the provider's supported flow,
// then verify the order status server-side.
$payment = $driver->verifyPayment($order['id']);

Amounts are major units, represented by decimal values. A successful approval redirect is not itself confirmation of capture; verify the order/capture status before fulfilment.

The driver implements the shared subscription, disbursement, and payment-link interfaces. PayPal plans are created using PayPal billing products/plans. Payouts require PayPal's Payouts product to be enabled and its recipient format; review the API reference before using transfer operations.

Webhooks

The handler uses PayPal's certificate-based webhook signature verification rather than an HMAC shared secret. Register POST /webhooks/payment-gateways/paypal, configure the provider webhook ID, and enable signature verification. Review webhook behavior.

See PayPal in the API reference for subscription and disbursement examples. Related: configuration · gateway directory.