PHPackages                             yousefkadah/laravel-pelecard - 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. yousefkadah/laravel-pelecard

ActiveLibrary[Payment Processing](/categories/payments)

yousefkadah/laravel-pelecard
============================

Laravel package for Pelecard payment gateway integration with Cashier-compatible subscription billing and multi-tenancy support

1.0.1(4mo ago)10MITPHPPHP ^8.1|^8.2|^8.3

Since Dec 27Pushed 4mo agoCompare

[ Source](https://github.com/yousefkadah/laravel-pelecard-package)[ Packagist](https://packagist.org/packages/yousefkadah/laravel-pelecard)[ RSS](/packages/yousefkadah-laravel-pelecard/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Pelecard Payment Gateway
================================

[](#laravel-pelecard-payment-gateway)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2a9a3ee18a2dac8c9620e7933cac3c4a714bc9958e32a43ca82f7ae51547fc00/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f757365666b616461682f6c61726176656c2d70656c65636172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yousefkadah/laravel-pelecard)[![Total Downloads](https://camo.githubusercontent.com/0f13c17bcb7b4aa40f53cf2f3a848710dafc5a72a64d414795fa822985523eba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f757365666b616461682f6c61726176656c2d70656c65636172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yousefkadah/laravel-pelecard)

A comprehensive Laravel package for integrating with the Pelecard payment gateway. Built with **Laravel Cashier-level code quality**, featuring subscription billing, multi-tenancy support, and a familiar Billable trait interface.

Features
--------

[](#features)

- 🔐 **Multi-Tenancy Support** - Multiple Pelecard accounts in one application
- 💳 **Cashier-Compatible** - Familiar `Billable` trait interface
- 📦 **Subscription Management** - Create, cancel, resume, and swap subscriptions
- 🔄 **Recurring Payments** - Tokenization and automated billing
- 💰 **One-Time Payments** - Authorize, charge, refund, and void transactions
- 🖼️ **iFrame Integration** - Hosted payment pages with full customization
- 🔒 **3D Secure** - Enhanced security authentication
- 📱 **Google Pay** - Digital wallet support
- 🎯 **Type-Safe DTOs** - Request objects with validation and IDE autocomplete
- 🪝 **Webhook Support** - Automated payment notifications
- 📊 **Transaction Logging** - Complete payment history
- 🎯 **Events** - Listen to payment lifecycle events
- 🔒 **Secure** - Encrypted credential storage

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

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- Pelecard merchant account

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

[](#installation)

Install the package via Composer:

```
composer require yousefkadah/laravel-pelecard
```

Publish the configuration file:

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

Run the migrations:

```
php artisan migrate
```

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

[](#configuration)

Add your Pelecard credentials to your `.env` file:

```
PELECARD_TERMINAL=your_terminal_number
PELECARD_USER=your_api_user
PELECARD_PASSWORD=your_api_password
PELECARD_ENV=sandbox  # or 'production'
```

### Multi-Tenancy Configuration

[](#multi-tenancy-configuration)

For multi-tenant applications, enable multi-tenancy in `config/pelecard.php`:

```
'multi_tenant' => true,
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

Add the `Billable` trait to your User model:

```
use Yousefkadah\Pelecard\Billable;

class User extends Authenticatable
{
    use Billable;
}
```

### One-Time Payments

[](#one-time-payments)

**Security Note:** Always use tokens for payments. Only collect card details for the initial tokenization.

#### Charge a Customer (Using Token)

[](#charge-a-customer-using-token)

```
// Recommended: Use saved token
$user->charge(10000, 'Product purchase', [
    'token' => $user->pelecard_token,
]);
```

#### First-Time Payment (Tokenize Card)

[](#first-time-payment-tokenize-card)

```
// Only for first payment: tokenize the card
$response = Pelecard::convertToToken([
    'card_number' => '4580000000000000',
    'expiry_month' => '12',
    'expiry_year' => '2025',
]);

$token = $response->get('Token');
$user->update(['pelecard_token' => $token]);

// Then charge using the token
$user->charge(10000, 'Product purchase', [
    'token' => $token,
]);
```

#### Automatic Card Saving (Recommended)

[](#automatic-card-saving-recommended)

The package automatically extracts tokens from payment responses (J2/J4/J5):

```
// Option 1: Charge and save card in one step
$response = $user->chargeAndSaveCard(10000, 'Product purchase', [
    'card_number' => '4580000000000000',
    'expiry_month' => '12',
    'expiry_year' => '2025',
    'cvv' => '123',
]);

// Token is automatically extracted and saved!
// Future payments can now use: $user->charge(amount, desc)

// Option 2: Save card from any payment response
$response = Pelecard::charge([
    'amount' => 10000,
    'currency' => 'ILS',
    'card_number' => '4580000000000000',
    'expiry_month' => '12',
    'expiry_year' => '2025',
    'cvv' => '123',
]);

if ($response->isSuccessful()) {
    // Automatically extract and save token
    $user->updateDefaultPaymentMethodFromResponse($response);
}

// Option 3: Manual token extraction
use Yousefkadah\Pelecard\Helpers\TokenExtractor;

$token = TokenExtractor::extractToken($response);
$cardDetails = TokenExtractor::extractCardDetails($response);

if ($token) {
    $user->updateDefaultPaymentMethod($token, $cardDetails);
}
```

#### Authorize (Hold Funds)

[](#authorize-hold-funds)

```
// Use token for authorization
$response = Pelecard::authorize([
    'amount' => 5000,
    'currency' => 'ILS',
    'token' => $user->pelecard_token,
]);

$transactionId = $response->getTransactionId();
```

#### Capture Authorization

[](#capture-authorization)

```
Pelecard::capture($transactionId, 5000);
```

#### Refund a Transaction

[](#refund-a-transaction)

```
$user->refund($transactionId, 5000);
```

### Using DTOs (Type-Safe Requests)

[](#using-dtos-type-safe-requests)

The package provides Data Transfer Objects for type-safe API requests with IDE autocomplete:

```
use Yousefkadah\Pelecard\DTO\ChargeRequestDTO;
use Yousefkadah\Pelecard\DTO\AuthorizeRequestDTO;
### Custom Parameters (ParamX & ParamZ)

Pelecard supports custom parameters that are returned in callbacks and webhooks for tracking:

#### API Calls (ParamX & ParamZ)

Both ParamX and ParamZ are supported in direct API calls:

```php
// Using ParamX and ParamZ for order tracking
$response = Pelecard::charge([
    'amount' => 10000,
    'currency' => 'ILS',
    'token' => $user->pelecard_token,
    'param_x' => 'order_12345',      // Order ID
    'param_z' => json_encode([        // Additional metadata
        'customer_id' => $user->id,
        'source' => 'mobile_app',
    ]),
]);

// In webhook callback, retrieve the parameters
$paramX = $request->input('ParamX'); // 'order_12345'
$paramZ = $request->input('ParamZ'); // JSON data

// With DTOs
$charge = new ChargeRequestDTO(
    amount: 10000,
    currency: 'ILS',
    token: $user->pelecard_token,
);
$charge->paramX = 'order_12345';
$charge->paramZ = json_encode(['user_id' => $user->id]);

$response = Pelecard::charge($charge->toArray());
```

#### iFrame (ParamX Only)

[](#iframe-paramx-only)

**Note:** iFrame only supports **ParamX**, not ParamZ:

```
{{-- Only ParamX is supported in iframe --}}

```

use Yousefkadah\\Pelecard\\DTO\\ThreeDSRequestDTO;

// Charge with token (recommended for security) $chargeRequest = new ChargeRequestDTO( amount: 10000, currency: 'ILS', token: $user-&gt;pelecardToken, // Use saved token email: '', payments: 1 );

$response = Pelecard::charge($chargeRequest-&gt;toArray());

// Or charge with card details (for first-time payments) $chargeRequest = new ChargeRequestDTO( amount: 10000, currency: 'ILS', cardNumber: '4580000000000000', expiryMonth: '12', expiryYear: '2025', cvv: '123', email: '' );

$response = Pelecard::charge($chargeRequest-&gt;toArray());

// Authorize with token $authorizeRequest = new AuthorizeRequestDTO( amount: 5000, currency: 'ILS', cardNumber: '4580000000000000', expiryMonth: '12', expiryYear: '2025', cvv: '123' );

$response = Pelecard::authorize($authorizeRequest-&gt;toArray());

// 3DS with DTO $threeDSRequest = new ThreeDSRequestDTO( amount: 10000, currency: 'ILS', cardNumber: '4580000000000000', expiryMonth: '12', expiryYear: '2025', email: '' );

$response = Pelecard::initiate3DS($threeDSRequest-&gt;toArray());

```

### 3D Secure Authentication

3D Secure provides an additional layer of security for online card transactions.

#### Using 3DS with Saved Token

```php
// Use saved token with 3DS authentication
$response = Pelecard::initiate3DS([
    'amount' => 10000,
    'currency' => 'ILS',
    'token' => $user->pelecard_token,
]);

// Redirect user to 3DS authentication page
$redirectUrl = $response->get('RedirectUrl');
return redirect($redirectUrl);

```

#### 3DS with iFrame (Recommended)

[](#3ds-with-iframe-recommended)

Enable 3DS in the iframe payment page:

```

```

Or programmatically:

```
$iframeHelper = Pelecard::for($user)->iframe();

$url = $iframeHelper->generatePaymentUrl([
    'amount' => 10000,
    'currency' => 'ILS',
    'success_url' => route('payment.success'),
    'use_3ds' => true, // Enable 3DS
    'token' => $user->pelecard_token, // Use saved token
]);
```

#### Get 3DS Data After Authentication

[](#get-3ds-data-after-authentication)

```
// After 3DS authentication completes
$data = Pelecard::get3DSData($transactionId);

// The response contains the token
if ($data->isSuccessful()) {
    $token = $data->get('Token');
    if ($token) {
        $user->updateDefaultPaymentMethodFromResponse($data);
    }
}
```

### Google Pay

[](#google-pay)

```
$response = Pelecard::debitByGooglePay([
    'amount' => 10000,
    'currency' => 'ILS',
    'google_pay_token' => $googlePayToken,
]);
```

### Advanced Token Management

[](#advanced-token-management)

**Best Practice:** Always tokenize cards and use tokens for recurring payments to comply with PCI-DSS.

#### Convert Card to Token

[](#convert-card-to-token)

```
// First time: convert card to token
$response = Pelecard::convertToToken([
    'card_number' => '4580000000000000',
    'expiry_month' => '12',
    'expiry_year' => '2025',
]);

$token = $response->get('Token');

// Save token to user
$user->update(['pelecard_token' => $token]);
```

#### Charge Using Token

[](#charge-using-token)

```
// Subsequent payments: use token (no card details needed)
$response = Pelecard::charge([
    'amount' => 10000,
    'currency' => 'ILS',
    'token' => $user->pelecard_token,
]);
```

#### Retrieve Token Details

[](#retrieve-token-details)

```
$tokenDetails = Pelecard::retrieveToken($user->pelecard_token);
```

#### Update Token

[](#update-token)

```
// Update expiry date when card is renewed
Pelecard::updateToken($user->pelecard_token, [
    'expiry_month' => '01',
    'expiry_year' => '2026',
]);
```

### Transaction Retrieval

[](#transaction-retrieval)

```
// Get complete transaction data
$transactions = Pelecard::getCompleteTransData([
    'from_date' => '2025-01-01',
    'to_date' => '2025-01-31',
]);

// Get specific transaction
$transaction = Pelecard::getTransaction($uniqueId);
```

### Invoice Creation

[](#invoice-creation)

The package provides a flexible invoice builder with customizable templates.

#### Creating an Invoice

[](#creating-an-invoice)

```
use Yousefkadah\Pelecard\Helpers\InvoiceBuilder;

$invoice = (new InvoiceBuilder())
    ->number('INV-2025-001')
    ->date(now())
    ->dueDate(now()->addDays(30))
    ->vendor([
        'name' => 'Your Company',
        'address' => '123 Main St, City',
        'phone' => '+972-50-1234567',
        'email' => 'billing@company.com',
    ])
    ->customer([
        'name' => $user->name,
        'email' => $user->email,
        'address' => $user->address,
    ])
    ->addItem('Premium Subscription', 1, 10000)
    ->addItem('Setup Fee', 1, 5000)
    ->taxRate(17) // 17% VAT
    ->notes('Thank you for your business!')
    ->terms('Payment due within 30 days')
    ->currency('ILS')
    ->build();

// Render as HTML
$html = $invoice->render();

// Or use the builder directly
$html = (new InvoiceBuilder())
    ->number('INV-001')
    ->customer(['name' => 'John Doe'])
    ->addItem('Service', 1, 10000)
    ->render();
```

#### Customizing Invoice Template

[](#customizing-invoice-template)

Publish the invoice templates:

```
php artisan vendor:publish --tag=pelecard-invoices
```

This creates `resources/views/vendor/pelecard/invoices/default.blade.php` which you can customize:

```
{{-- resources/views/vendor/pelecard/invoices/default.blade.php --}}

    Invoice #{{ $invoice->number() }}

        /* Your custom styles */
        .invoice-header {
            background: #your-brand-color;
        }

        Invoice #{{ $invoice->number() }}

        @foreach($invoice->items() as $item)
            {{ $item['description'] }}
        @endforeach

        Total: {{ $invoice->formatAmount($invoice->total()) }}

```

#### Using Custom Template

[](#using-custom-template)

```
$html = (new InvoiceBuilder())
    ->template('invoices.custom') // Use your custom template
    ->number('INV-001')
    ->build()
    ->render();
```

### Error Messages

[](#error-messages)

```
// Get error message in Hebrew
$errorMessage = Pelecard::getErrorMessageHe('001');

// Get error message in English
$errorMessage = Pelecard::getErrorMessageEn('001');

// Auto-detect language from config
$errorMessage = Pelecard::getErrorMessage('001');
```

### Invoice Creation

[](#invoice-creation-1)

```
// Create ICount invoice
Pelecard::createICountInvoice([
    'customer_name' => 'John Doe',
    'amount' => 10000,
    'items' => [...],
]);
```

### iFrame Payment Integration

[](#iframe-payment-integration)

Pelecard's iframe integration allows customers to complete payments directly on your website without being redirected to an external payment page.

#### Using the Blade Component

[](#using-the-blade-component)

```

```

#### Using the Helper Directly

[](#using-the-helper-directly)

```
$client = Pelecard::for($user);
$iframeHelper = $client->iframe();

// Generate iframe URL
$url = $iframeHelper->generatePaymentUrl([
    'amount' => 10000,
    'currency' => 'ILS',
    'success_url' => route('payment.success'),
    'error_url' => route('payment.error'),
    'cancel_url' => route('payment.cancel'),
    'language' => 'he',
    'param_x' => 'order_123',
]);

// Generate iframe HTML
$iframeHtml = $iframeHelper->generateIframe([
    'amount' => 10000,
    'currency' => 'ILS',
    'success_url' => route('payment.success'),
], [
    'width' => '100%',
    'height' => '600',
]);

// Or generate a payment form (redirect method)
$formHtml = $iframeHelper->generatePaymentForm([
    'amount' => 10000,
    'currency' => 'ILS',
]);
```

#### Customization Options

[](#customization-options)

- `top_text` - Text displayed at the top of the payment page
- `bottom_text` - Text displayed at the bottom
- `logo_url` - Your company logo URL
- `hide_pelecard_logo` - Hide Pelecard branding (boolean)
- `show_confirmation` - Show confirmation checkbox (boolean)
- `min_payments` - Minimum number of installments
- `max_payments` - Maximum number of installments
- `param_x` - Custom parameter to track the transaction

### Subscriptions

[](#subscriptions)

#### Create a Subscription

[](#create-a-subscription)

```
$user->newSubscription('default', 'plan_123')
    ->trialDays(14)
    ->create($paymentMethod);
```

#### Check Subscription Status

[](#check-subscription-status)

```
if ($user->subscribed('default')) {
    // User has an active subscription
}

if ($user->onTrial('default')) {
    // User is on trial
}
```

#### Cancel a Subscription

[](#cancel-a-subscription)

```
// Cancel at end of billing period
$user->subscription('default')->cancel();

// Cancel immediately
$user->subscription('default')->cancelNow();
```

#### Resume a Cancelled Subscription

[](#resume-a-cancelled-subscription)

```
$user->subscription('default')->resume();
```

#### Swap Plans

[](#swap-plans)

```
$user->subscription('default')->swap('plan_456');
```

#### Update Quantity

[](#update-quantity)

```
$subscription = $user->subscription('default');

$subscription->incrementQuantity();
$subscription->decrementQuantity();
$subscription->updateQuantity(5);
```

### Multi-Tenancy

[](#multi-tenancy)

#### Per-Team Credentials (SaaS Applications)

[](#per-team-credentials-saas-applications)

```
// Team model
use Yousefkadah\Pelecard\Concerns\ManagesPelecardCredentials;

class Team extends Model
{
    use ManagesPelecardCredentials;
}

// Setup team credentials
$team->createPelecardCredentials(
    terminal: '1234567',
    user: 'api_user',
    password: 'api_password'
);

// User model
class User extends Model
{
    use Billable;

    public function pelecardCredentials()
    {
        return $this->team->pelecardCredentials;
    }
}

// Usage - automatically uses team's credentials
$user->charge(10000, 'Payment');
```

#### Direct Client Usage

[](#direct-client-usage)

```
// Create client for specific tenant
$client = PelecardClient::for($user);
$client = PelecardClient::for($team);

// Use client
$response = $client->charge([
    'amount' => 10000,
    'currency' => 'ILS',
    'token' => 'payment_token',
]);
```

### Webhooks

[](#webhooks)

Display webhook URL:

```
php artisan pelecard:webhook
```

Configure the webhook URL in your Pelecard dashboard to receive payment notifications.

#### Listen to Webhook Events

[](#listen-to-webhook-events)

```
use Yousefkadah\Pelecard\Events\PaymentSucceeded;
use Yousefkadah\Pelecard\Events\PaymentFailed;

// In EventServiceProvider
protected $listen = [
    PaymentSucceeded::class => [
        SendPaymentConfirmation::class,
    ],
    PaymentFailed::class => [
        NotifyPaymentFailure::class,
    ],
];
```

### Payment Methods

[](#payment-methods)

#### Update Default Payment Method

[](#update-default-payment-method)

```
$user->updateDefaultPaymentMethod($token, [
    'type' => 'card',
    'last_four' => '4242',
]);
```

#### Check for Payment Method

[](#check-for-payment-method)

```
if ($user->hasDefaultPaymentMethod()) {
    // User has a payment method on file
}
```

### Transaction History

[](#transaction-history)

```
// Get all transactions for a user
$transactions = $user->pelecardTransactions;

// Get successful transactions
$successful = $user->pelecardTransactions()->successful()->get();

// Get transactions of specific type
$charges = $user->pelecardTransactions()->ofType('charge')->get();
```

Artisan Commands
----------------

[](#artisan-commands)

### Display Webhook URL

[](#display-webhook-url)

```
php artisan pelecard:webhook
```

### Sync Subscriptions

[](#sync-subscriptions)

```
# Sync all subscriptions
php artisan pelecard:sync-subscriptions

# Sync for specific user
php artisan pelecard:sync-subscriptions --user=1
```

Events
------

[](#events)

The package dispatches the following events:

- `PaymentSucceeded` - When a payment is successful
- `PaymentFailed` - When a payment fails
- `SubscriptionCreated` - When a subscription is created
- `SubscriptionCancelled` - When a subscription is cancelled
- `SubscriptionUpdated` - When a subscription is updated

Code Quality Tools
------------------

[](#code-quality-tools)

This package uses industry-standard code quality tools to maintain high code standards:

### Laravel Pint (Code Formatting)

[](#laravel-pint-code-formatting)

```
# Format code automatically
composer format

# Check formatting without making changes
composer format-check
```

### Rector (Automated Refactoring)

[](#rector-automated-refactoring)

```
# Apply automated refactoring
composer refactor

# Preview changes without applying
composer refactor-dry
```

### PHPStan (Static Analysis)

[](#phpstan-static-analysis)

```
# Run static analysis
composer analyse
```

### Run All Quality Checks

[](#run-all-quality-checks)

```
# Run formatting, refactoring check, analysis, and tests
composer quality
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Yousef Kadah](https://github.com/yousefkadah)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance75

Regular maintenance activity

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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

137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2104aeba724305b26d85387f776693e3c4c57205fe5aa320b59da59e211bc030?d=identicon)[yousefkadah](/maintainers/yousefkadah)

---

Top Contributors

[![yousefkadah](https://avatars.githubusercontent.com/u/5706681?v=4)](https://github.com/yousefkadah "yousefkadah (3 commits)")[![FullnessYousef](https://avatars.githubusercontent.com/u/238999611?v=4)](https://github.com/FullnessYousef "FullnessYousef (1 commits)")

---

Tags

laravelbillingpaymentgatewaysubscriptionmulti-tenantcashierpelecard

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yousefkadah-laravel-pelecard/health.svg)

```
[![Health](https://phpackages.com/badges/yousefkadah-laravel-pelecard/health.svg)](https://phpackages.com/packages/yousefkadah-laravel-pelecard)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[omalizadeh/laravel-multi-payment

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

491.1k](/packages/omalizadeh-laravel-multi-payment)[asciisd/knet

Knet package is provides an expressive, fluent interface to KNet's payment services.

141.1k](/packages/asciisd-knet)[parsisolution/gateway

A Laravel package for connecting to all Iraninan payment gateways

231.7k](/packages/parsisolution-gateway)

PHPackages © 2026

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