PHPackages                             asciisd/cashier-paytiko - 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. asciisd/cashier-paytiko

ActiveLibrary[Payment Processing](/categories/payments)

asciisd/cashier-paytiko
=======================

Paytiko payment processor for Laravel Cashier Core

1.4.1(3mo ago)0723↓89.3%MITPHPPHP ^8.3

Since Sep 29Pushed 3mo agoCompare

[ Source](https://github.com/asciisd/cashier-paytiko)[ Packagist](https://packagist.org/packages/asciisd/cashier-paytiko)[ RSS](/packages/asciisd-cashier-paytiko/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (24)Versions (11)Used By (0)

Cashier Paytiko
===============

[](#cashier-paytiko)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4c6e9b03ec876c44352e9a60fb5e9f977e94f53d246c146ea50ece73669533cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617363696973642f636173686965722d70617974696b6f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/cashier-paytiko)[![Total Downloads](https://camo.githubusercontent.com/d528694440017a592c3159d2fe1715d65713200d05302526f3d436c4e4807071/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617363696973642f636173686965722d70617974696b6f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/cashier-paytiko)[![License](https://camo.githubusercontent.com/f919526781725db22d536ba5c17ff61cb9a44d064d43c72ce342348d316290e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617363696973642f636173686965722d70617974696b6f2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/cashier-paytiko)

A Laravel package that integrates Paytiko payment processor with [Cashier Core](https://github.com/asciisd/cashier-core). This package provides a clean, scalable implementation of Paytiko's Hosted Page solution with comprehensive webhook handling.

Features
--------

[](#features)

- **Simplified Payment API**: Easy-to-use `simpleCharge(amount, params)` method with automatic configuration
- **Hosted Page Integration**: Seamless integration with Paytiko's hosted payment pages
- **Automatic Configuration**: URLs, order IDs, and descriptions auto-generated from config
- **Webhook Handling**: Automatic webhook processing with signature verification
- **Event System**: Laravel events for payment status updates
- **DTO Architecture**: Clean data transfer objects for type safety
- **Comprehensive Testing**: Full test suite with Pest
- **Scalable Design**: Easy to extend for additional Paytiko features
- **Laravel Integration**: Native Laravel package with service provider
- **Signature Security**: Automatic signature generation and verification

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

[](#installation)

Install the package via Composer:

```
composer require asciisd/cashier-paytiko
```

Publish the configuration file:

```
php artisan vendor:publish --provider="Asciisd\CashierPaytiko\CashierPaytikoServiceProvider" --tag="cashier-paytiko-config"
```

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

[](#configuration)

Add the following environment variables to your `.env` file:

```
# Paytiko Configuration
PAYTIKO_MERCHANT_SECRET_KEY=your_merchant_secret_key
PAYTIKO_CORE_URL=https://your-paytiko-core-url.com
PAYTIKO_WEBHOOK_URL=https://yoursite.com/api/webhooks/paytiko
PAYTIKO_SUCCESS_REDIRECT_URL=https://yoursite.com/payment/success
PAYTIKO_FAILED_REDIRECT_URL=https://yoursite.com/payment/failed
PAYTIKO_DEFAULT_CURRENCY=USD

# Optional Settings
PAYTIKO_VERIFY_WEBHOOK_SIGNATURE=true
PAYTIKO_WEBHOOK_TOLERANCE=300
PAYTIKO_HTTP_TIMEOUT=30
PAYTIKO_LOGGING_ENABLED=true
```

Usage
-----

[](#usage)

### Simplified Payment Processing (Recommended)

[](#simplified-payment-processing-recommended)

The new `simpleCharge` method provides a streamlined way to process payments with minimal configuration:

```
use Asciisd\CashierCore\Facades\PaymentFactory;

// Create Paytiko processor
$processor = PaymentFactory::create('paytiko', [
    'merchant_secret_key' => config('cashier-paytiko.merchant_secret_key'),
    'core_url' => config('cashier-paytiko.core_url'),
]);

// 1. Minimal payment - only amount and billing details required
$result = $processor->simpleCharge(100.00, [
    'billing_details' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'email' => 'john@example.com',
        'country' => 'US',
        'phone' => '+1234567890',
    ]
]);

// 2. With custom parameters
$result = $processor->simpleCharge(250.50, [
    'currency' => 'EUR',
    'description' => 'Custom deposit for trading account',
    'billing_details' => [
        'first_name' => 'Jane',
        'last_name' => 'Smith',
        'email' => 'jane@example.com',
        'country' => 'CA',
        'phone' => '+1555123456',
    ],
    'metadata' => ['campaign_id' => 'xyz123'],
]);

// 3. Override default URLs
$result = $processor->simpleCharge(75.00, [
    'billing_details' => [
        'first_name' => 'Alice',
        'last_name' => 'Brown',
        'email' => 'alice@example.com',
        'country' => 'GB',
        'phone' => '+447123456789',
    ],
    'webhook_url' => 'https://my-app.com/custom-webhook',
    'success_redirect_url' => 'https://my-app.com/custom-success',
]);

if ($result->isSuccessful()) {
    $redirectUrl = $result->metadata['redirect_url'];
    // Redirect user to Paytiko hosted page
    return redirect($redirectUrl);
} else {
    // Handle error
    echo "Payment failed: {$result->message}";
}
```

#### What `simpleCharge` Auto-Generates

[](#what-simplecharge-auto-generates)

When using `simpleCharge`, the following are automatically handled:

- **Order ID**: Generated using `deposit-{timestamp}-{random}`
- **Description**: Auto-generated based on amount (e.g., "Deposit $100.00")
- **Webhook URL**: Uses config value or falls back to Laravel route
- **Success/Failed URLs**: Uses config values or falls back to Laravel routes
- **Currency**: Uses config default (USD) if not specified
- **Timestamp**: Automatically generated for signature creation

### Basic Payment Processing (Legacy)

[](#basic-payment-processing-legacy)

```
use Asciisd\CashierCore\Facades\PaymentFactory;

// Create Paytiko processor
$processor = PaymentFactory::create('paytiko', [
    'merchant_secret_key' => config('cashier-paytiko.merchant_secret_key'),
    'core_url' => config('cashier-paytiko.core_url'),
]);

// Process payment (creates hosted page)
$result = $processor->charge([
    'amount' => 20, // $20.00
    'currency' => 'USD',
    'order_id' => 'order_12345',
    'description' => 'Product purchase',
    'billing_details' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'email' => 'john@example.com',
        'country' => 'US',
        'phone' => '+1234567890',
        'street' => '123 Main St',
        'city' => 'New York',
        'region' => 'NY',
        'zip_code' => '10001',
        'date_of_birth' => '1990-01-01',
        'gender' => 'Male',
        'currency' => 'USD',
    ],
    'webhook_url' => 'https://yoursite.com/api/webhooks/paytiko',
    'success_redirect_url' => 'https://yoursite.com/success',
    'failed_redirect_url' => 'https://yoursite.com/failed',
]);

if ($result->isSuccessful()) {
    $redirectUrl = $result->metadata['redirect_url'];
    // Redirect user to Paytiko hosted page
    return redirect($redirectUrl);
} else {
    // Handle error
    echo "Payment failed: {$result->message}";
}
```

### Registering with Cashier Core

[](#registering-with-cashier-core)

Add Paytiko to your `config/cashier-core.php`:

```
'processors' => [
    'paytiko' => [
        'class' => \Asciisd\CashierPaytiko\PaytikoProcessor::class,
        'config' => [
            'merchant_secret_key' => config('cashier-paytiko.merchant_secret_key'),
            'core_url' => config('cashier-paytiko.core_url'),
        ],
    ],
],
```

### Webhook Handling

[](#webhook-handling)

The package automatically registers a webhook endpoint at `/api/webhooks/paytiko`. Configure this URL in your Paytiko dashboard.

#### Listening to Events

[](#listening-to-events)

```
use Asciisd\CashierPaytiko\Events\PaytikoPaymentSuccessful;
use Asciisd\CashierPaytiko\Events\PaytikoPaymentFailed;
use Asciisd\CashierPaytiko\Events\PaytikoRefundProcessed;
use Asciisd\CashierPaytiko\Events\PaytikoWebhookReceived;

// Listen to successful payments
Event::listen(PaytikoPaymentSuccessful::class, function ($event) {
    $webhookData = $event->webhookData;

    // Update your order status
    $order = Order::where('id', $webhookData->orderId)->first();
    $order->update(['status' => 'paid']);

    // Send confirmation email, etc.
});

// Listen to failed payments
Event::listen(PaytikoPaymentFailed::class, function ($event) {
    $webhookData = $event->webhookData;

    // Handle failed payment
    $order = Order::where('id', $webhookData->orderId)->first();
    $order->update(['status' => 'failed']);
});

// Listen to all webhook events
Event::listen(PaytikoWebhookReceived::class, function ($event) {
    $webhookData = $event->webhookData;
    $rawPayload = $event->rawPayload;

    // Log webhook for debugging
    Log::info('Paytiko webhook received', [
        'order_id' => $webhookData->orderId,
        'status' => $webhookData->transactionStatus,
    ]);
});
```

### Advanced Configuration

[](#advanced-configuration)

#### Custom Webhook URL per Payment

[](#custom-webhook-url-per-payment)

```
$result = $processor->charge([
    // ... other data
    'webhook_url' => 'https://yoursite.com/custom/webhook/endpoint',
]);
```

#### Credit Card Only Mode

[](#credit-card-only-mode)

```
$result = $processor->charge([
    // ... other data
    'credit_card_only' => true,
]);
```

#### Disable Specific Payment Processors

[](#disable-specific-payment-processors)

```
$result = $processor->charge([
    // ... other data
    'disabled_psp_ids' => [12321, 54455, 34212],
]);
```

#### Payout Mode

[](#payout-mode)

```
$result = $processor->charge([
    // ... other data
    'is_pay_out' => true,
]);
```

Data Transfer Objects
---------------------

[](#data-transfer-objects)

The package uses DTOs for type safety and clean data handling:

### PaytikoHostedPageRequest

[](#paytikohostedpagerequest)

```
use Asciisd\CashierPaytiko\DataObjects\PaytikoHostedPageRequest;
use Asciisd\CashierPaytiko\DataObjects\PaytikoBillingDetails;

$billingDetails = new PaytikoBillingDetails(
    firstName: 'John',
    email: 'john@example.com',
    country: 'US',
    phone: '+1234567890',
    currency: 'USD'
);

$request = new PaytikoHostedPageRequest(
    timestamp: (string) time(),
    orderId: 'order_123',
    signature: $signature,
    billingDetails: $billingDetails
);
```

### PaytikoWebhookData

[](#paytikowebhookdata)

```
use Asciisd\CashierPaytiko\DataObjects\PaytikoWebhookData;

// Webhook data is automatically parsed from incoming webhooks
$webhookData = $event->webhookData;

// Check payment status
if ($webhookData->isSuccessful()) {
    // Payment succeeded
}

if ($webhookData->isPayIn()) {
    // This is a payment
}

if ($webhookData->isRefund()) {
    // This is a refund
}
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

### Example Tests

[](#example-tests)

#### Testing the Simplified Method

[](#testing-the-simplified-method)

```
use Asciisd\CashierPaytiko\PaytikoProcessor;

it('processes payment with simpleCharge successfully', function () {
    $processor = new PaytikoProcessor([
        'merchant_secret_key' => 'test_secret',
        'core_url' => 'https://test.paytiko.com',
    ]);

    $result = $processor->simpleCharge(100.00, [
        'billing_details' => [
            'first_name' => 'John',
            'email' => 'john@example.com',
            'country' => 'US',
            'phone' => '+1234567890',
        ],
    ]);

    expect($result->isSuccessful())->toBeTrue();
});
```

#### Testing the Legacy Method

[](#testing-the-legacy-method)

```
it('processes payment successfully', function () {
    $processor = new PaytikoProcessor([
        'merchant_secret_key' => 'test_secret',
        'core_url' => 'https://test.paytiko.com',
    ]);

    $paymentData = [
        'amount' => 2000,
        'order_id' => 'test_order',
        'billing_details' => [
            'first_name' => 'John',
            'email' => 'john@example.com',
            'country' => 'US',
            'phone' => '+1234567890',
        ],
    ];

    $result = $processor->charge($paymentData);

    expect($result->isSuccessful())->toBeTrue();
});
```

Security
--------

[](#security)

- **Signature Verification**: All webhooks are verified using SHA256 signatures
- **HTTPS Required**: All API communications use HTTPS
- **Input Validation**: Comprehensive validation of all input data
- **Error Handling**: Secure error handling without exposing sensitive data

Extending the Package
---------------------

[](#extending-the-package)

The package is designed to be easily extensible. You can add new Paytiko features by:

1. Creating new DTOs for request/response data
2. Adding new methods to the `PaytikoProcessor`
3. Creating new events for additional webhook types
4. Extending the service classes for new API endpoints

### Example: Adding Direct Payment API

[](#example-adding-direct-payment-api)

```
// Add to PaytikoProcessor
public function directPayment(array $data): PaymentResult
{
    // Implement direct payment API integration
}

// Create new DTO
class PaytikoDirectPaymentRequest
{
    // Define direct payment request structure
}
```

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

[](#contributing)

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

License
-------

[](#license)

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

Support
-------

[](#support)

For support, please open an issue on GitHub or contact us at .

Changelog
---------

[](#changelog)

### v1.2.0 (dev-main)

[](#v120-dev-main)

- **NEW**: Added `simpleCharge(amount, params)` method for simplified payment processing
- **NEW**: Automatic order ID generation with `deposit-{timestamp}-{random}` format
- **NEW**: Auto-generated descriptions based on payment amount
- **NEW**: Automatic URL handling with config fallbacks and Laravel route support
- **NEW**: Comprehensive test suite for simplified payment method
- **NEW**: Example usage documentation and code samples
- **IMPROVED**: Better separation between simplified and legacy payment methods
- **IMPROVED**: Enhanced error handling and validation for simplified API

### v1.0.0

[](#v100)

- Initial release
- Hosted Page integration
- Webhook handling with events
- Comprehensive test suite
- Full documentation

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance82

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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

Every ~20 days

Recently: every ~42 days

Total

10

Last Release

95d ago

PHP version history (2 changes)1.0.0PHP ^8.2

1.4.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77636067?v=4)[ASCII SD](/maintainers/asciisd)[@asciisd](https://github.com/asciisd)

---

Top Contributors

[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (15 commits)")

---

Tags

laravelpaymentgatewaycashierpaytiko

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/asciisd-cashier-paytiko/health.svg)

```
[![Health](https://phpackages.com/badges/asciisd-cashier-paytiko/health.svg)](https://phpackages.com/packages/asciisd-cashier-paytiko)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M992](/packages/statamic-cms)[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M223](/packages/backpack-crud)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4851.0k](/packages/sebdesign-laravel-viva-payments)[bitpay/sdk

Complete version of the PHP library for the new cryptographically secure BitPay API

42361.9k4](/packages/bitpay-sdk)[evryn/laravel-toman

A simple stable Laravel package to handle popular payment gateways in Iran including ZarinPal and IDPay.

10710.5k](/packages/evryn-laravel-toman)

PHPackages © 2026

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