Installation
Require the Composer package
Enable the driver
Set the driver inconfig/lunar/payments.php.
Add PayPal credentials
Add the PayPal credentials toconfig/services.php.
Configuration
The following configuration options are available.| Key | Default | Description |
|---|---|---|
services.paypal.env | sandbox | The PayPal environment. Set to sandbox for testing or any other value (e.g., live) for production |
services.paypal.client_id | null | The PayPal OAuth client ID |
services.paypal.secret | null | The PayPal OAuth client secret |
lunar.payments.paypal.success_route | checkout.success | The named route PayPal redirects to after a successful approval |
Payment Flow
The PayPal checkout flow works as follows:- The storefront calls the API endpoint to create a PayPal order from the current cart
- The customer is redirected to PayPal to approve the payment
- PayPal redirects the customer back to the storefront
- The storefront sends an authorization request with the PayPal order ID
- 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.web middleware.
Backend Usage
Authorize a payment
After the customer approves the payment on PayPal, authorize and capture it.Refund a payment
Facade Methods
TheLunar\Paypal\Facades\Paypal facade provides direct access to the PayPal API.