Skip to main content
Lunar’s PayPal addon integrates with PayPal’s REST API to handle checkout payments, including order creation, capture, and refunds.

Installation

Require the Composer package

Enable the driver

Set the driver in config/lunar/payments.php.

Add PayPal credentials

Add the PayPal credentials to config/services.php.
REST API credentials can be created in the PayPal Developer Dashboard.

Configuration

The following configuration options are available.

Payment Flow

The PayPal checkout flow works as follows:
  1. The storefront calls the API endpoint to create a PayPal order from the current cart
  2. The customer is redirected to PayPal to approve the payment
  3. PayPal redirects the customer back to the storefront
  4. The storefront sends an authorization request with the PayPal order ID
  5. The addon captures the payment and creates the Lunar order

API Route

The addon registers an API route for creating PayPal orders from the current cart session.
This endpoint returns a PayPal order object containing the approval URL and order details. The route uses the web middleware.

Backend Usage

Authorize a payment

After the customer approves the payment on PayPal, authorize and capture it.

Refund a payment

Facade Methods

The Lunar\Paypal\Facades\Paypal facade provides direct access to the PayPal API.

Get a PayPal order

Capture a PayPal order

Refund a transaction

Build an order from a cart

Creates a PayPal order from a cart via the PayPal API and returns the response, including the approval URL and order details.