PHPackages                             aratkruglik/wayforpay-laravel - 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. aratkruglik/wayforpay-laravel

ActiveLibrary[Payment Processing](/categories/payments)

aratkruglik/wayforpay-laravel
=============================

Native Laravel integration for WayForPay payment gateway.

1.2.1(1mo ago)04MITPHPPHP ^8.2

Since Jan 12Pushed 1mo agoCompare

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

READMEChangelog (6)Dependencies (12)Versions (8)Used By (0)

WayForPay Laravel Package
=========================

[](#wayforpay-laravel-package)

[![Tests](https://github.com/AratKruglik/wayforpay-laravel/actions/workflows/tests.yml/badge.svg)](https://github.com/AratKruglik/wayforpay-laravel/actions/workflows/tests.yml/badge.svg)[![License](https://camo.githubusercontent.com/c20a343084d3de38b1b20438e29a26a1f4ede98cb730fe24986ee413287c3912/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617261746b7275676c696b2f776179666f727061792d6c61726176656c)](https://camo.githubusercontent.com/c20a343084d3de38b1b20438e29a26a1f4ede98cb730fe24986ee413287c3912/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617261746b7275676c696b2f776179666f727061792d6c61726176656c)[![Version](https://camo.githubusercontent.com/581332d519f3c8e8dd5287d61678f2166c213b20b3733dce4fb6c1742d26d201/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617261746b7275676c696b2f776179666f727061792d6c61726176656c)](https://camo.githubusercontent.com/581332d519f3c8e8dd5287d61678f2166c213b20b3733dce4fb6c1742d26d201/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617261746b7275676c696b2f776179666f727061792d6c61726176656c)

Native Laravel integration for the [WayForPay](https://wayforpay.com) payment gateway. Built on `Illuminate\Http\Client` with no external SDK dependencies. Provides strict DTOs, automatic HMAC\_MD5 signature handling, and built-in webhook support.

Supports **Laravel 11.x-13.x** and **PHP 8.2+**.

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

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Purchase (Widget)](#1-purchase-widget)
    - [Invoices](#2-invoices)
    - [Direct Charge (Host-to-Host)](#3-direct-charge-host-to-host)
    - [Recurring Payments](#4-recurring-payments)
    - [Refunds](#5-refunds)
    - [Holds (Two-Phase Payments)](#6-holds-two-phase-payments)
    - [P2P Credit (Payouts)](#7-p2p-credit-payouts)
    - [P2P Account Transfer](#8-p2p-account-transfer)
    - [Card Verification](#9-card-verification)
    - [Check Status](#10-check-status)
- [Webhooks](#webhooks)
- [Marketplace Integration (MMS API)](#marketplace-integration-mms-api)
    - [Partner Management](#partner-management)
    - [Merchant Management](#merchant-management)
    - [Balance and Reporting](#balance-and-reporting)
- [Testing](#testing)
- [License](#license)

---

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

[](#installation)

```
composer require aratkruglik/wayforpay-laravel
```

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

[](#configuration)

Publish the configuration file:

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

Add credentials to `.env`:

```
WAYFORPAY_MERCHANT_ACCOUNT=your_merchant_login
WAYFORPAY_SECRET_KEY=your_secret_key
WAYFORPAY_MERCHANT_DOMAIN=your_domain.com
```

---

Usage
-----

[](#usage)

### 1. Purchase (Widget)

[](#1-purchase-widget)

Generate a self-submitting HTML form that redirects the user to the WayForPay checkout page.

```
use AratKruglik\WayForPay\Facades\WayForPay;
use AratKruglik\WayForPay\Domain\Transaction;
use AratKruglik\WayForPay\Domain\Product;
use AratKruglik\WayForPay\Domain\Client;

$client = new Client(
    nameFirst: 'John',
    nameLast: 'Doe',
    email: 'john@example.com',
    phone: '+380501234567'
);

$transaction = new Transaction(
    orderReference: 'ORDER_' . time(),
    amount: 100.50,
    currency: 'UAH',
    orderDate: time(),
    client: $client,
    paymentSystems: 'card;googlePay;applePay'
);

$transaction->addProduct(new Product('T-Shirt', 100.50, 1));

$html = WayForPay::purchase(
    $transaction,
    returnUrl: 'https://myshop.com/payment/success',
    serviceUrl: 'https://myshop.com/api/wayforpay/callback'
);

return response($html);
```

#### Custom Form Rendering

[](#custom-form-rendering)

For SPA or custom frontend integration, use `getPurchaseFormData` to get raw form fields:

```
$formData = WayForPay::getPurchaseFormData($transaction, $returnUrl, $serviceUrl);

return response()->json([
    'form_action' => 'https://secure.wayforpay.com/pay',
    'form_data' => $formData,
]);
```

Submit the form programmatically on the client side:

```
const form = document.createElement('form');
form.method = 'POST';
form.action = data.form_action;

Object.entries(data.form_data).forEach(([key, value]) => {
    if (Array.isArray(value)) {
        value.forEach(item => {
            const input = document.createElement('input');
            input.type = 'hidden';
            input.name = `${key}[]`;
            input.value = item;
            form.appendChild(input);
        });
    } else {
        const input = document.createElement('input');
        input.type = 'hidden';
        input.name = key;
        input.value = value;
        form.appendChild(input);
    }
});

document.body.appendChild(form);
form.submit();
```

### 2. Invoices

[](#2-invoices)

Generate a payment link to send via email or messenger.

```
$response = WayForPay::createInvoice($transaction, returnUrl: 'https://myshop.com/success');
$invoiceUrl = $response['invoiceUrl'];

WayForPay::removeInvoice('ORDER_123');
```

### 3. Direct Charge (Host-to-Host)

[](#3-direct-charge-host-to-host)

> **Warning:** Requires PCI DSS compliance when handling raw card data server-side.

```
use AratKruglik\WayForPay\Domain\Card;
use AratKruglik\WayForPay\Enums\ReasonCode;

$card = new Card(
    cardNumber: '4111111111111111',
    expMonth: '12',
    expYear: '25',
    cvv: '123',
    holderName: 'JOHN DOE'
);

$response = WayForPay::charge($transaction, $card);

$code = ReasonCode::tryFrom((int) $response['reasonCode']);
if ($code?->isSuccess()) {
    // Payment successful
}
```

### 4. Recurring Payments

[](#4-recurring-payments)

Create a subscription by passing regular payment parameters during the initial purchase:

```
$transaction = new Transaction(
    orderReference: 'SUB_123',
    amount: 100.00,
    currency: 'UAH',
    orderDate: time(),
    regularMode: 'monthly',
    regularAmount: 100.00,
    dateNext: '25.05.2025',
    dateEnd: '25.05.2026'
);

$html = WayForPay::purchase($transaction);
```

Manage existing subscriptions:

```
WayForPay::suspendRecurring('SUB_123');
WayForPay::resumeRecurring('SUB_123');
WayForPay::removeRecurring('SUB_123');
```

### 5. Refunds

[](#5-refunds)

```
WayForPay::refund('ORDER_123', 50.00, 'UAH', 'Customer return');
```

### 6. Holds (Two-Phase Payments)

[](#6-holds-two-phase-payments)

Settle a previously authorized hold:

```
WayForPay::settle('ORDER_123', 100.50, 'UAH');
```

### 7. P2P Credit (Payouts)

[](#7-p2p-credit-payouts)

Send funds from the merchant account to a recipient card:

```
WayForPay::p2pCredit(
    orderReference: 'PAYOUT_001',
    amount: 500.00,
    currency: 'UAH',
    cardBeneficiary: '4111111111111111'
);
```

### 8. P2P Account Transfer

[](#8-p2p-account-transfer)

Transfer funds to a bank account (UAH only):

```
use AratKruglik\WayForPay\Domain\AccountTransfer;

$transfer = new AccountTransfer(
    orderReference: 'TRANSFER_001',
    amount: 1500.00,
    currency: 'UAH',
    iban: 'UA213223130000026007233566001',
    okpo: '12345678',
    accountName: 'FOP Ivanov I.I.',
    description: 'Payout for services',
    serviceUrl: 'https://myshop.com/api/wayforpay/callback',
    recipientEmail: 'recipient@example.com'
);

$response = WayForPay::p2pAccount($transfer);
```

### 9. Card Verification

[](#9-card-verification)

Verify a card by blocking a small amount that is automatically reversed:

```
$url = WayForPay::verifyCard('VERIFY_ORDER_001');
return redirect($url);
```

### 10. Check Status

[](#10-check-status)

```
$status = WayForPay::checkStatus('ORDER_123');
// $status['transactionStatus']
```

---

Webhooks
--------

[](#webhooks)

The package handles signature verification automatically.

**Option A: Built-in controller with event dispatching**

Register the route in `routes/api.php`:

```
Route::post('wayforpay/callback', \AratKruglik\WayForPay\Http\Controllers\WebhookController::class);
```

Listen for the event:

```
use AratKruglik\WayForPay\Events\WayForPayCallbackReceived;

Event::listen(WayForPayCallbackReceived::class, function ($event) {
    $data = $event->data;

    if ($data['transactionStatus'] === 'Approved') {
        // Update order status
    }
});
```

**Option B: Manual handling in a custom controller**

```
use AratKruglik\WayForPay\Services\WayForPayService;
use AratKruglik\WayForPay\Exceptions\WayForPayException;

public function handle(Request $request, WayForPayService $service)
{
    try {
        $response = $service->handleWebhook($request->all());

        // Process order logic...

        return response()->json($response);
    } catch (WayForPayException $e) {
        return response()->json(['status' => 'error'], 400);
    }
}
```

---

Marketplace Integration (MMS API)
---------------------------------

[](#marketplace-integration-mms-api)

The MMS (Merchant Management System) API enables marketplace platforms to programmatically manage sub-merchants and partners, configure compensation (payout) methods, and query balances.

Available via the `Mms` facade or constructor injection:

```
use AratKruglik\WayForPay\Facades\Mms;

// Facade
Mms::addPartner($partner);

// Constructor injection
use AratKruglik\WayForPay\Contracts\MmsServiceInterface;

class PartnerController extends Controller
{
    public function __construct(
        private readonly MmsServiceInterface $mms
    ) {}
}
```

### Partner Management

[](#partner-management)

#### Register a new partner

[](#register-a-new-partner)

```
use AratKruglik\WayForPay\Facades\Mms;
use AratKruglik\WayForPay\Domain\Partner;
use AratKruglik\WayForPay\Domain\CompensationCard;
use AratKruglik\WayForPay\Domain\CompensationAccount;

// Option 1: Compensation via card
$partner = new Partner(
    partnerCode: 'PARTNER_001',
    site: 'https://partner-shop.com',
    phone: '+380501234567',
    email: 'partner@example.com',
    description: 'Partner shop description',
    compensationCard: new CompensationCard(
        cardNumber: '4111111111111111',
        expMonth: '12',
        expYear: '25',
        cvv: '123',
        holderName: 'PARTNER NAME'
    )
);

// Option 2: Compensation via bank account
$partner = new Partner(
    partnerCode: 'PARTNER_002',
    site: 'https://partner-shop.com',
    phone: '+380501234567',
    email: 'partner@example.com',
    compensationAccount: new CompensationAccount(
        iban: 'UA213223130000026007233566001',
        okpo: '12345678',
        name: 'FOP Partner Name'
    )
);

// Option 3: Compensation via tokenized card
$partner = new Partner(
    partnerCode: 'PARTNER_003',
    site: 'https://partner-shop.com',
    phone: '+380501234567',
    email: 'partner@example.com',
    compensationCardToken: 'card_token_from_wayforpay'
);

$response = Mms::addPartner($partner);
```

#### Query partner info

[](#query-partner-info)

```
$info = Mms::partnerInfo('PARTNER_001');
```

#### Update partner details

[](#update-partner-details)

```
Mms::updatePartner('PARTNER_001', [
    'phone' => '+380509876543',
    'email' => 'new-email@example.com',
    'compensationCardToken' => 'new_token',
]);
```

### Merchant Management

[](#merchant-management)

#### Register a sub-merchant

[](#register-a-sub-merchant)

```
use AratKruglik\WayForPay\Facades\Mms;
use AratKruglik\WayForPay\Domain\Merchant;
use AratKruglik\WayForPay\Domain\CompensationCard;

$merchant = new Merchant(
    site: 'https://sub-merchant.com',
    phone: '+380501234567',
    email: 'merchant@example.com',
    description: 'Sub-merchant description',
    compensationCard: new CompensationCard(
        cardNumber: '4111111111111111'
    )
);

$response = Mms::addMerchant($merchant);
```

#### Query merchant info

[](#query-merchant-info)

Requires the sub-merchant's account ID and secret key:

```
$info = Mms::merchantInfo('sub_merchant_account', 'sub_merchant_secret_key');
```

### Balance and Reporting

[](#balance-and-reporting)

```
use AratKruglik\WayForPay\Facades\Mms;

$balance = Mms::merchantBalance();

// With date filter (dd.mm.yyyy format)
$balance = Mms::merchantBalance('01.01.2026');
```

---

Testing
-------

[](#testing)

```
vendor/bin/pest
```

---

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE.md) for details.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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 ~15 days

Total

6

Last Release

44d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39ffbf2120ff3a5e2e691d8ac2fa18f95d1f27cbfe318043f233e3d081bfa37e?d=identicon)[AratKruglik](/maintainers/AratKruglik)

---

Top Contributors

[![AratKruglik](https://avatars.githubusercontent.com/u/9255774?v=4)](https://github.com/AratKruglik "AratKruglik (14 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/aratkruglik-wayforpay-laravel/health.svg)

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

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[asciisd/knet

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

141.1k](/packages/asciisd-knet)

PHPackages © 2026

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