The PayPal Payment Gateway add-on integrates the PayPal REST API with your Larapen e-shop — customers are redirected to PayPal’s hosted checkout to complete payment, then returned to your site with automatic capture, webhook confirmation, and full refund support.
Key Features
- PayPal REST API — Uses PayPal’s modern REST API with CAPTURE intent to create orders and capture payments securely.
- Redirect-based checkout — Customers are redirected to PayPal’s hosted checkout page to log in and approve payment, then returned to your site. No credit card form needed on your site.
- Dual confirmation — Payments are confirmed both by the return redirect (immediate) and by webhooks (asynchronous), ensuring orders are marked as paid even if the customer closes their browser.
- Refund support — Process full or partial refunds directly from the admin panel. Refund transactions are tracked automatically with support for pending (eCheck) and completed statuses.
- Encrypted credentials — Client ID, Client Secret, and Webhook ID are encrypted at rest using Laravel’s
Crypt::encryptString(). Never stored in plain text. - Multi-currency — Supports any ISO 4217 currency code (USD, EUR, GBP, etc.) configured in the admin panel.
- Brand customization — Configure the brand name displayed on the PayPal checkout page (max 127 characters).
- Polymorphic payables — Works with any model implementing the
Payablecontract, not limited to shop orders. - Payment gateway contract — Implements the Larapen
PaymentGatewayInterface, integrating seamlessly with the E-Shop checkout flow.
Admin Panel
| Section | Description |
|---|---|
| Settings | Configure PayPal Client ID, Client Secret, Webhook ID, mode (sandbox/live), currency, and brand name. All sensitive credentials stored encrypted. |
Payment Flow
- Customer selects “PayPal” at checkout.
- The shop creates a PayPal order via the REST API with CAPTURE intent.
- Customer is redirected to PayPal’s hosted checkout page to log in and approve.
- After approval, PayPal redirects back to
/paypal/returnwhere the payment is captured. - Order is marked as paid, a transaction record is created, and the customer sees the success page.
- PayPal also sends a
PAYMENT.CAPTURE.COMPLETEDwebhook as a reliable backup.
Webhook Events
| Event | Action |
|---|---|
PAYMENT.CAPTURE.COMPLETED | Confirms the payment was successfully captured. Marks the order as paid if not already confirmed by the return redirect. |
PAYMENT.CAPTURE.DENIED | Logs the payment denial. Updates the order payment status to failed. |
PAYMENT.CAPTURE.REFUNDED | Confirms a refund was processed. Updates the order payment status to refunded. |
Configuration
| Setting | Description |
|---|---|
| Mode | sandbox for testing or live for production payments. Controls which API endpoint and credentials are used. |
| Client ID | PayPal REST API Client ID. Stored encrypted. |
| Client Secret | PayPal REST API Client Secret. Stored encrypted. |
| Webhook ID | PayPal Webhook ID for verifying incoming webhook signatures. Stored encrypted. Optional but recommended. |
| Currency | ISO 4217 currency code (e.g., USD, EUR, GBP). |
| Brand Name | Name displayed on the PayPal checkout page (max 127 characters). Falls back to the application name. |
Dependencies
Required: The E-Shop add-on must be installed and active. The PayPal add-on registers as a payment gateway via the PaymentGatewayInterface contract and is automatically discovered by the shop’s payment system. The srmklive/paypal Composer package (PayPal SDK) is required.
Setup Guide
- Install and activate the E-Shop add-on first.
- Install the PayPal SDK:
composer require srmklive/paypal. - Install and activate the PayPal add-on.
- Go to PayPal > Settings in the admin panel.
- Enter your Client ID and Client Secret from the PayPal Developer Dashboard.
- Create a webhook in PayPal Dashboard pointing to
https://yoursite.com/paypal/webhookand enter the Webhook ID. - Subscribe to events:
PAYMENT.CAPTURE.COMPLETED,PAYMENT.CAPTURE.DENIED,PAYMENT.CAPTURE.REFUNDED. - PayPal will appear as a payment option during checkout.
Ideal for
- E-commerce sites wanting the world’s most recognized online payment method.
- International sellers accepting payments from 200+ markets in 25+ currencies.
- Businesses wanting buyer protection and trust signals that increase conversion rates.
- Sites targeting customers who prefer paying without entering credit card details directly.
- Digital product sellers needing secure, instant payment confirmation via webhooks.