PHPackages                             longswipe/longswipe-php-sdk - 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. [Payment Processing](/categories/payments)
4. /
5. longswipe/longswipe-php-sdk

ActiveLibrary[Payment Processing](/categories/payments)

longswipe/longswipe-php-sdk
===========================

Official PHP plugin for Longswipe payment integration

1.0.0(1y ago)05MITPHPPHP &gt;=7.4

Since Mar 1Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Telktia-LTD/longswipe-php-sdk)[ Packagist](https://packagist.org/packages/longswipe/longswipe-php-sdk)[ Docs](https://github.com/Telktia-LTD/longswipe-php-sdk)[ RSS](/packages/longswipe-longswipe-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Longswipe Payment PHP Integration
=================================

[](#longswipe-payment-php-integration)

A PHP plugin for integrating Longswipe payment voucher system into your application. This plugin provides simple methods to validate and process voucher payments.

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

[](#requirements)

- PHP 7.4 or higher
- curl extension
- json extension

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

[](#installation)

Install the package via composer:

```
composer require longswipe/longswipe-payment
```

### Quick Start

[](#quick-start)

### Accepted Currency Abbreviation

[](#accepted-currency-abbreviation)

| Enum | | :--- | :--------- | | USD | US Dollar | | EUR | Euro | | NGN | Naira | | GBP | Pounds | | USDC | USD Coin | | USDT | USD Tether |

### Expected Params for fetching currency details and process payment

[](#expected-params-for-fetching-currency-details-and-process-payment)

ParamsvoucherCodeVoucher codelockPinVoucher lock pin (optional)amountAmount to redeemtoCurrencyAbbreviationCurrency to redeem towalletAddressCrypto wallet address (optional)```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

// Example parameters
$params = [
    'voucherCode' => 'VOUCHER123',
    'amount' => 1000,
    'toCurrencyAbbreviation' => 'USD', // USD, EUR, NGN, GBP, USDC, USDT
    'lockPin' => '1234', // Optional
    'walletAddress' => '0x123...' // Optional
];

try {
    // Fetch voucher details
    $voucherDetails = $client->fetchVoucherDetails($params);

    // If details are okay, process the payment
    $paymentResult = $client->processVoucherPayment($params);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Detailed Usage

[](#detailed-usage)

- Initialize the Client

```
// For sandbox environment
$client = new LongswipeClient('your-api-key', true);

// For production environment
$client = new LongswipeClient('your-api-key', false);
```

- Verify voucher (Use Public API Key)

```
try {
    $params = [
        'voucherCode' => 'VOUCHER123'
    ];

    $voucherDetails = $client->verifyVoucher($params);

    if ($voucherDetails['status'] === 'success') {
        // Process voucher details
        $voucher = $voucherDetails['data'];
    }
} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    if ($e->getErrorData()) {
        print_r($e->getErrorData());
    }
}
```

- Fetch supported crypto networks (Use Public API Key)

```
try {
    $networks = $client->fetchSupportedCryptoNetworks();

    if ($networks['status'] === 'success') {
        $networkList = $networks['data'];
    }
} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    if ($e->getErrorData()) {
        print_r($e->getErrorData());
    }
}
```

- Fetch supported currencies (Use Public API Key)

```
try {

    $currencies = $client->fetchSupportedCurrencies();

    if ($currencies['status'] === 'success') {
        $currencyList = $currencies['data'];
    }
} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    if ($e->getErrorData()) {
        print_r($e->getErrorData());
    }
}
```

- Fetch Voucher Details and Charges (Use Public API Key)

```
try {
    $params = [
        'voucherCode' => 'VOUCHER123',
        'amount' => 1000,
        'toCurrencyAbbreviation' => 'USD', // USD, EUR, NGN, GBP, USDC, USDT
        'lockPin' => '1234', // Optional
        'walletAddress' => '0x123...' // Optional
    ];

    $voucherDetails = $client->fetchVoucherDetails($params);

    if ($voucherDetails['status'] === 'success') {
        // Process voucher details
        $charges = $voucherDetails['data']['charges'];
        $voucher = $voucherDetails['data']['voucher'];
    }
} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    if ($e->getErrorData()) {
        print_r($e->getErrorData());
    }
}
```

- Process Payment (Use Public API Key)

```
try {
    $params = [
        'voucherCode' => 'VOUCHER123',
        'amount' => 1000,
        'toCurrencyAbbreviation' => 'USD', // USD, EUR, NGN, GBP, USDC, USDT
        'lockPin' => '1234', // Optional
        'walletAddress' => '0x123...' // Optional
    ];

    $paymentResult = $client->processVoucherPayment($params);

    if ($paymentResult['status'] === 'success') {
        // Payment successful
        echo "Payment processed successfully!";
    }
} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    if ($e->getErrorData()) {
        print_r($e->getErrorData());
    }
}
```

### Create new customer (Use Secret API Key)

[](#create-new-customer-use-secret-api-key)

ParamsemailCustomer emailnameCustomer name```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

// Example parameters
$params = [
    'email' => 'johndoe@email.com',
    'name' => 'John Doe',
];

try {

    $newCustomer = $client->createCustomer($customerParams);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Create an invoice (Use Secret API Key)

[](#create-an-invoice-use-secret-api-key)

```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

// Example parameters
$invoiceParams = [
        'blockchainNetworkId' => 'network-123',
        'currencyId' => 'USD',
        'dueDate' => '2025-03-26',
        'invoiceDate' => '2025-02-26',
        'invoiceItems' => [
            [
                'description' => 'Service payment',
                'quantity' => 1,
                'unitPrice' => 100.00
            ]
        ],
        'merchantUserId' => 'merchant-123'
    ];

try {

    $newInvoice = $client->createInvoice($invoiceParams);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Update customer (Use Secret API Key)

[](#update-customer-use-secret-api-key)

```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

// Example parameters
$updateParams = [
        'id' => 'customer-123',
        'name' => 'John Updated Doe',
        'email' => 'john.updated@example.com'
    ];

try {

    $updatedCustomer = $client->updateCustomer($updateParams);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Fetch customers (Use Secret API Key)

[](#fetch-customers-use-secret-api-key)

```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

try {

    $customers = $client->fetchCustomers([
        'page' => 1,
        'limit' => 20,
        'search' => 'john'
    ]);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Fetch customer by email (Use Secret API Key)

[](#fetch-customer-by-email-use-secret-api-key)

```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

try {

    $customerByEmail = $client->fetchCustomerByEmail([
        'email' => 'john.doe@example.com'
    ]);

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

### Delete customer (Use Secret API Key)

[](#delete-customer-use-secret-api-key)

```
// PHP code block
use Longswipe\Payment\LongswipeClient;
use Longswipe\Payment\Exceptions\LongswipeException;

// Initialize the client
$client = new LongswipeClient('your-api-key', true); // true for sandbox, false for production

try {

    $customerByEmail = $client->deleteCustomer('customer-123');

} catch (LongswipeException $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
    var_dump($e->getErrorData());
}
```

API Response Models
-------------------

[](#api-response-models)

### Fetch Voucher Details Response

[](#fetch-voucher-details-response)

```
{
  "code": 0,
  "data": {
    "charges": {
      "amount": 0,
      "amountInWei": 0,
      "balanceAfterCharges": 0,
      "balanceAfterChargesInWei": 0,
      "gasLimitInWei": 0,
      "gasPriceInWei": 0,
      "processingFee": 0,
      "processingFeeInWei": 0,
      "totalGasCost": 0,
      "totalGasCostAndProcessingFee": 0,
      "totalGasCostAndProcessingFeeInWei": 0,
      "totalGasCostInWei": 0
    },
    "voucher": {
      "amount": 0,
      "balance": 0,
      "code": "string",
      "createdAt": "string",
      "createdForExistingUser": true,
      "createdForMerchant": true,
      "createdForNonExistingUser": true,
      "cryptoVoucherDetails": {
        "balance": "string",
        "codeHash": "string",
        "creator": "string",
        "isRedeemed": true,
        "transactionHash": "string",
        "value": "string"
      },
      "generatedCurrency": {
        "abbrev": "string",
        "currencyType": "string",
        "id": "string",
        "image": "string",
        "isActive": true,
        "name": "string",
        "symbol": "string"
      }
    }
  },
  "message": "string",
  "status": "string"
}
```

### Fetch customers response

[](#fetch-customers-response)

```
{
  "code": 0,
  "data": {
    "customer": [
      {
        "email": "string",
        "id": "string",
        "merchantID": "string",
        "name": "string"
      }
    ],
    "limit": 0,
    "page": 0,
    "total": 0
  },
  "message": "string",
  "status": "string"
}
```

### Fetch customer response

[](#fetch-customer-response)

```
{
  "code": 0,
  "customer": {
    "email": "string",
    "id": "string",
    "merchantID": "string",
    "name": "string"
  },
  "message": "string",
  "status": "string"
}
```

### Fetch supported crypto network response

[](#fetch-supported-crypto-network-response)

```
{
  "code": 0,
  "data": [
    {
      "blockExplorerUrl": "string",
      "chainID": "string",
      "cryptocurrencies": [
        {
          "currencyAddress": "string",
          "currencyData": {
            "abbrev": "string",
            "currencyType": "string",
            "id": "string",
            "image": "string",
            "isActive": true,
            "name": "string",
            "symbol": "string"
          },
          "currencyDecimals": "string",
          "currencyName": "string",
          "id": "string",
          "longswipeContractAddress": "string",
          "networkID": "string",
          "status": true
        }
      ],
      "id": "string",
      "networkName": "string",
      "networkType": "EVM",
      "rpcUrl": "string"
    }
  ],
  "message": "string",
  "status": "string"
}
```

### Fetch supported currency response

[](#fetch-supported-currency-response)

```
{
  "code": 0,
  "data": {
    "currencies": [
      {
        "abbreviation": "string",
        "createdAt": "string",
        "currency": "string",
        "currencyType": "string",
        "id": "string",
        "image": "string",
        "isActive": true,
        "symbol": "string"
      }
    ]
  },
  "message": "string",
  "status": "string"
}
```

### Other Response

[](#other-response)

```
{
  "code": 0,
  "message": "string",
  "status": "string"
}
```

Error Handling
--------------

[](#error-handling)

The plugin uses the `LongswipeException` class for error handling. Always wrap your API calls in try-catch blocks:

```
try {
    // Your API call here
} catch (LongswipeException $e) {
    echo "Error Code: " . $e->getCode() . "\n";
    echo "Error Message: " . $e->getMessage() . "\n";
    if ($e->getErrorData()) {
        echo "Additional Error Data: ";
        print_r($e->getErrorData());
    }
}
```

Support
-------

[](#support)

For support, please contact:

- Email:
- GitHub Issues: [Create an issue](https://github.com/ndenisj/longswipe-payment/issues)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance44

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/85155d4b07ec44b20a3b4b7d8b516b464b03ce4ca0663b5b099e29b74b25547d?d=identicon)[denisjn](/maintainers/denisjn)

---

Top Contributors

[![ndenisj](https://avatars.githubusercontent.com/u/45005671?v=4)](https://github.com/ndenisj "ndenisj (8 commits)")

---

Tags

phppaymentvoucherlongswipe

### Embed Badge

![Health badge](/badges/longswipe-longswipe-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/longswipe-longswipe-php-sdk/health.svg)](https://phpackages.com/packages/longswipe-longswipe-php-sdk)
```

###  Alternatives

[yandex-money/yandex-money-sdk-php

Yandex.Money API SDK for PHP

105167.4k2](/packages/yandex-money-yandex-money-sdk-php)[cryptonator/merchant-php-sdk

Cryptonator.com Merchant API SDK for PHP

2713.7k](/packages/cryptonator-merchant-php-sdk)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[miracode/stripe-bundle

Symfony bundle to integrate Stripe PHP SDK. Ability to save Stripe objects in database using Doctrine.

1016.1k](/packages/miracode-stripe-bundle)[luyadev/luya-module-payment

LUYA Payment allows you to integrate payments in a safe and fast way. The module take care of all the provider required steps (call, create, success, abort, etc.) and provides all the informations for your store.

1012.1k](/packages/luyadev-luya-module-payment)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
