PHPackages                             lahiru/laravel-solidgate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lahiru/laravel-solidgate

ActiveLibrary[API Development](/categories/api)

lahiru/laravel-solidgate
========================

Laravel SDK for SolidGate — card &amp; APM payments, subscriptions, webhooks, and reporting with official HMAC-SHA512 signing, typed responses, and smart API defaults.

v1.0.7(1mo ago)121MITPHPPHP ^8.2CI passing

Since May 30Pushed 1mo agoCompare

[ Source](https://github.com/Lprabodha/laravel-solidgate)[ Packagist](https://packagist.org/packages/lahiru/laravel-solidgate)[ Docs](https://github.com/Lprabodha/laravel-solidgate)[ RSS](/packages/lahiru-laravel-solidgate/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (10)Used By (0)

Laravel SolidGate
=================

[](#laravel-solidgate)

[![Latest Version](https://camo.githubusercontent.com/1a0870952590d12609fd51b9b86611c3e561aa7ac4a013bb664e4a904d281c3f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e302e372d626c75652e737667)](https://packagist.org/packages/lahiru/laravel-solidgate)[![PHP Version](https://camo.githubusercontent.com/744f8821cc27dec8b0013ade48179731a44eadf4f943e0b1d9ffcb93f80177de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d626c75652e737667)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/dbb9f99edf3ae932568d54a747bb466f7ad014712bc4ce5c451e7f631409ff7b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e7825323025374325323031332e782d7265642e737667)](https://laravel.com)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Laravel package for the [SolidGate](https://docs.solidgate.com/) payment gateway. Use the **facade** or **dependency injection**, get **typed responses**, and call **74+ API endpoints** with correct HMAC-SHA512 signing and sensible defaults.

**Good for:** server-side card/APM charges, subscriptions, hosted checkout, embedded payment forms, webhooks, and reporting.

---

Table of Contents
-----------------

[](#table-of-contents)

**Getting started**

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Choose your integration](#choose-your-integration)
- [Using the package in Laravel](#using-the-package-in-laravel)
- [Quick Start](#quick-start)

**Checkout (customer-facing)**

- [Checkout integrations](#checkout-integrations)
    - [Payment Page (hosted)](#payment-page-hosted)
    - [Payment Form (embedded)](#payment-form-embedded)

**Server-side API**

- [Card Payments](#card-payments)
- [Alternative Payments (APM)](#alternative-payments-apm)
- [Subscriptions](#subscriptions)
- [Products, Taxes &amp; Reporting](#products-taxes--reporting)
- [Webhooks](#webhooks)

**Reference**

- [Responses &amp; Error Handling](#responses--error-handling)
- [Helper Classes](#helper-classes)
- [Troubleshooting](#troubleshooting)
- [API Reference Map](#api-reference-map)
- [Development](#development)
- [Changelog](#changelog)
- [License &amp; References](#license--references)

---

Features
--------

[](#features)

FeatureDescription**74+ endpoints**Card, APM, subscriptions, taxes, checkout, webhooks, reporting**Checkout docs**[Payment Page](#payment-page-hosted) and [Payment Form](#payment-form-embedded) with copy-paste Laravel examples**Correct signing**HMAC-SHA512 over exact JSON body — matches official PHP SDK**Smart defaults**Auto-fills `platform`, `payment_type`, and card expiry formatting**Type-safe responses**`SolidGateResponse` with dot-notation and error helpers**Webhook support**Signature verification middleware + Laravel events**Helper classes**`Platform`, `PaymentType`, `RefundReason`, currency utilities**Laravel native**HTTP client, service container, facade, config publishing---

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10.x, 11.x, 12.x, or 13.x (Laravel 13 requires PHP 8.3+)

---

Installation
------------

[](#installation)

```
composer require lahiru/laravel-solidgate
```

Publish the config (recommended):

```
php artisan vendor:publish --tag=solidgate-config
```

Copy environment variables from `.env.example`:

```
cp vendor/lahiru/laravel-solidgate/.env.example .env.example.solidgate
# Merge the SolidGate keys into your .env
```

---

Configuration
-------------

[](#configuration)

Get your keys from **SolidGate Hub → Developers → Channel details**:

Key typePrefixUsed forAPI keys`api_pk_*` / `api_sk_*`Outgoing API requestsWebhook keys`wh_pk_*` / `wh_sk_*`Incoming webhook verification### Environment variables

[](#environment-variables)

```
# ── Required ──────────────────────────────────────────────
SOLIDGATE_PUBLIC_KEY=api_pk_your_public_key
SOLIDGATE_SECRET_KEY=api_sk_your_secret_key

# ── API URLs (defaults are production) ──────────────────
SOLIDGATE_API_BASE_URL=https://pay.solidgate.com/api/v1/
SOLIDGATE_SUBSCRIPTIONS_BASE_URL=https://subscriptions.solidgate.com/api/v1/
SOLIDGATE_GATE_BASE_URL=https://gate.solidgate.com/api/
SOLIDGATE_REPORTS_BASE_URL=https://reports.solidgate.com/
SOLIDGATE_TIMEOUT=30
SOLIDGATE_VERIFY_SSL=true
SOLIDGATE_LOG_REQUESTS=false

# ── Payment defaults (applied when fields are omitted) ────
SOLIDGATE_DEFAULT_PLATFORM=WEB
SOLIDGATE_DEFAULT_PAYMENT_TYPE=1-click

# ── Webhooks (optional) ───────────────────────────────────
SOLIDGATE_WEBHOOK_ENABLED=false
SOLIDGATE_WEBHOOK_PATH=solidgate/webhook
SOLIDGATE_WEBHOOK_PUBLIC_KEY=wh_pk_your_webhook_public_key
SOLIDGATE_WEBHOOK_SECRET=wh_sk_your_webhook_secret
SOLIDGATE_SIGNATURE_HEADER=Signature
SOLIDGATE_WEBHOOK_MIDDLEWARE=solidgate.webhook
```

> **Tip:** Each API group uses a different base URL. Card payments go to `pay.solidgate.com`, subscriptions to `subscriptions.solidgate.com`, APM to `gate.solidgate.com`, and reports to `reports.solidgate.com`. The package routes these automatically — you only call the facade methods.

### Config file (`config/solidgate.php`)

[](#config-file-configsolidgatephp)

After publishing, keys are read from `config('solidgate.public_key')` and `config('solidgate.secret_key')` (backed by `SOLIDGATE_*` env vars).

---

Choose your integration
-----------------------

[](#choose-your-integration)

Pick the flow that matches your product. All options below use this package on the server; only Payment Form also needs frontend JS.

IntegrationCustomer experiencePackage methodsBest when**[Payment Page](#payment-page-hosted)**Redirect to Solidgate-hosted page`createPaymentPage()`, `deactivatePaymentPage()`Fastest setup, minimal frontend**[Payment Form](#payment-form-embedded)**Card fields on your site`generateSignature()` + app helper for `merchantData`Full UI control, no redirect**Card API (`charge`)**You collect PAN (PCI scope)`charge()`, `auth()`, `recurring()`Full backend control**APM**PayPal, Pix, etc.`initializeAlternativePayment()`Alternative payment methods**Subscriptions**Recurring billing`retrieveSubscription()`, `cancelSubscription()`, …SaaS / memberships---

Using the package in Laravel
----------------------------

[](#using-the-package-in-laravel)

### Facade (typical)

[](#facade-typical)

```
use Lahiru\LaravelSolidGate\Facades\SolidGate;

$response = SolidGate::charge([...]);
```

### Dependency injection (testable)

[](#dependency-injection-testable)

```
use Lahiru\LaravelSolidGate\Contracts\SolidGateClientInterface;

public function __construct(
    protected SolidGateClientInterface $solidgate
) {}

$this->solidgate->charge([...]);
```

### Signing helper (Payment Form)

[](#signing-helper-payment-form)

```
$signature = SolidGate::generateSignature($jsonPayload);
```

Uses the same HMAC-SHA512 algorithm as outbound API requests and webhook verification.

---

Quick Start
-----------

[](#quick-start)

Three-minute path to a successful server-side charge. For hosted or embedded checkout, jump to [Checkout integrations](#checkout-integrations).

### 1. Make your first charge

[](#1-make-your-first-charge)

```
use Lahiru\LaravelSolidGate\Facades\SolidGate;
use Lahiru\LaravelSolidGate\Support\Platform;

$response = SolidGate::charge([
    'amount'            => 10000,          // $100.00 in cents
    'currency'          => 'USD',
    'order_id'          => (string) Str::uuid(),
    'order_description' => 'Premium package',
    'customer_email'    => 'customer@example.com',
    'ip_address'        => $request->ip(),
    'platform'          => Platform::WEB,  // WEB | MOB | APP
    'card_number'       => '4111111111111111',
    'card_holder'       => 'John Doe',
    'card_exp_month'    => '12',
    'card_exp_year'     => 2030,
    'card_cvv'          => '123',
]);

if ($response->isSuccessful()) {
    $status = $response->get('order.status'); // e.g. "processing", "settle_ok"
} else {
    $error = $response->getErrorMessage();
}
```

`platform` and `payment_type` are auto-filled from config when omitted. Card expiry fields are normalized automatically (`3` → `"03"`, year cast to integer).

### 2. Full controller example

[](#2-full-controller-example)

```
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Lahiru\LaravelSolidGate\Contracts\SolidGateClientInterface;
use Lahiru\LaravelSolidGate\Support\Platform;

class PaymentController extends Controller
{
    public function __construct(
        protected SolidGateClientInterface $solidgate
    ) {}

    public function charge(Request $request): JsonResponse
    {
        $response = $this->solidgate->charge([
            'amount'            => $request->integer('amount'),
            'currency'          => $request->string('currency'),
            'order_id'          => (string) Str::uuid(),
            'order_description' => $request->string('order_description'),
            'customer_email'    => $request->string('customer_email'),
            'ip_address'        => $request->ip(),
            'platform'          => Platform::WEB,
            'card_number'       => $request->string('card_number'),
            'card_holder'       => $request->string('card_holder'),
            'card_exp_month'    => $request->string('card_exp_month'),
            'card_exp_year'     => $request->integer('card_exp_year'),
            'card_cvv'          => $request->string('card_cvv'),
        ]);

        if (! $response->isSuccessful()) {
            return response()->json([
                'error'   => $response->getError(),
                'message' => $response->getErrorMessage(),
            ], 422);
        }

        return response()->json([
            'status' => $response->get('order.status'),
            'order'  => $response->get('order'),
        ]);
    }
}
```

### 3. Recurring / token payment

[](#3-recurring--token-payment)

```
use Lahiru\LaravelSolidGate\Support\PaymentType;

$response = SolidGate::recurring([
    'amount'          => 10000,
    'currency'        => 'USD',
    'order_id'        => (string) Str::uuid(),
    'customer_email'  => 'customer@example.com',
    'ip_address'      => $request->ip(),
    'payment_type'    => PaymentType::RECURRING,
    'recurring_token' => 'token-from-previous-payment',
]);
```

---

Checkout integrations
---------------------

[](#checkout-integrations)

Customer-facing checkout using Solidgate UI. For server-side card capture without Solidgate JS, see [Card Payments](#card-payments).

Payment PagePayment Form**Docs**[Payment Page](https://docs.solidgate.com/payments/integrate/payment-page/)[Payment Form](https://docs.solidgate.com/payments/integrate/payment-form/)**UX**Redirect to hosted URLEmbedded on your page**Frontend**None required`solid-form.js` + `PaymentFormSdk.init()`**Backend**`createPaymentPage()``generateSignature()` + encrypt `paymentIntent`**PCI**Card data on SolidgateCard data tokenized by Solidgate iframe---

### Payment Page (hosted)

[](#payment-page-hosted)

**When to use:** you want checkout live quickly with almost no frontend work.

**Flow**

1. Laravel calls `SolidGate::createPaymentPage(['order' => [...], 'page_customization' => [...]])`.
2. API returns a `url` (expires in ~24 hours).
3. Redirect the customer with `redirect()->away($url)`.
4. After payment, Solidgate sends the user to your `success_url` or `fail_url`.

**API**

MethodEndpointPurpose`createPaymentPage($attributes)``POST /init`Create hosted page, get URL`deactivatePaymentPage($pageId)``POST /deactivate`Invalidate page before expiry**Minimal example**

```
use Illuminate\Support\Str;
use Lahiru\LaravelSolidGate\Facades\SolidGate;
use Lahiru\LaravelSolidGate\Support\Platform;

$response = SolidGate::createPaymentPage([
    'order' => [
        'order_id'          => (string) Str::uuid(),
        'amount'            => 10000,
        'currency'          => 'USD',
        'order_description' => 'Premium package',
        'customer_email'    => $request->user()->email,
        'ip_address'        => $request->ip(),
        'platform'          => Platform::WEB,
        'success_url'       => route('checkout.success'),
        'fail_url'          => route('checkout.fail'),
    ],
]);

if (! $response->isSuccessful()) {
    return back()->withErrors(['payment' => $response->getErrorMessage()]);
}

return redirect()->away($response->get('url'));
```

**Controller + route**

```
// app/Http/Controllers/PaymentPageController.php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Str;
use Lahiru\LaravelSolidGate\Facades\SolidGate;
use Lahiru\LaravelSolidGate\Support\Platform;

class PaymentPageController extends Controller
{
    public function checkout(Request $request)
    {
        $response = SolidGate::createPaymentPage([
            'order' => [
                'order_id'          => (string) Str::uuid(),
                'amount'            => $request->integer('amount'),
                'currency'          => $request->string('currency'),
                'order_description' => $request->string('description'),
                'customer_email'    => $request->user()->email,
                'ip_address'        => $request->ip(),
                'platform'          => Platform::WEB,
                'success_url'       => route('checkout.success'),
                'fail_url'          => route('checkout.fail'),
            ],
        ]);

        if (! $response->isSuccessful()) {
            return back()->withErrors(['payment' => $response->getErrorMessage()]);
        }

        return redirect()->away($response->get('url'));
    }
}
```

```
// routes/web.php
Route::get('/checkout', [PaymentPageController::class, 'checkout'])->name('checkout.start');
```

**Subscriptions / catalog:** use `product_price_id` in `order` (from `SolidGate::getProductPrices()`). See [Create your payment page](https://docs.solidgate.com/payments/integrate/payment-page/create-your-payment-page/).

**Checklist**

- Unique `order_id` per checkout attempt
- Public `ip_address` (not `127.0.0.1` in production)
- `success_url` and `fail_url` registered and reachable
- Store `id` from response if you need `deactivatePaymentPage()` later

---

### Payment Form (embedded)

[](#payment-form-embedded)

**When to use:** checkout must match your site design and stay on the same URL.

**Flow**

1. Build a `paymentIntent` array (amount, currency, `order_id`, customer, URLs, etc.).
2. Server returns `merchantData`: `merchant`, `signature`, `paymentIntent` (encrypted).
3. Blade loads `https://cdn.solidgate.com/js/solid-form.js` and calls `PaymentFormSdk.init({ merchantData })`.

**`merchantData` shape (passed to JS)**

KeySource`merchant``config('solidgate.public_key')``signature``SolidGate::generateSignature($json)``paymentIntent`AES-256-CBC encrypted JSON (see helper below)**App helper** — copy to `app/Services/SolidgatePaymentForm.php` (no extra Composer package):

```
