PHPackages                             gemfourmedia/omnipay-zalopay - 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. gemfourmedia/omnipay-zalopay

ActiveLibrary[Payment Processing](/categories/payments)

gemfourmedia/omnipay-zalopay
============================

ZaloPay gateway driver for Omnipay.

v1.0.0(3y ago)015MITPHPPHP ^7.1|^8.0

Since Feb 5Pushed 3y ago1 watchersCompare

[ Source](https://github.com/gemfourmedia/omnipay-zalopay)[ Packagist](https://packagist.org/packages/gemfourmedia/omnipay-zalopay)[ Docs](https://github.com/gemfourmedia/omnipay-zalopay)[ RSS](/packages/gemfourmedia-omnipay-zalopay/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

omnipay-zalopay
===============

[](#omnipay-zalopay)

ZaloPay gateway for [Omnipay League](https://github.com/thephpleague/omnipay).

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

[](#installation)

WIP: via [Composer](https://getcomposer.org):

```
composer require gemfourmedia/omnipay-zalopay
```

Usage
-----

[](#usage)

### Init gateway:

[](#init-gateway)

```
use Omnipay\Omnipay;

$gateway = Omnipay::create('ZaloPay');
$gateway->initialize([
    'app_user' => 'Your App Name',
    'app_id' => 'Provided by ZaloPay',
    'key1' => 'Provided by ZaloPay',
    'key2' => 'Provided by ZaloPay',
    'testMode' => true // 'Enable sandbox mode',
]);
```

This gateway object will use to handle request/response from ZaloPay

### Create Purchase:

[](#create-purchase)

```
$appTime = floor(microtime(true) * 1000);
$appTransId = date('ymd').$this->order->order_number.$appTime;

$response =  $gateway->purchase([
    // Required parameters
    'app_trans_id' => $appTransId,
    'app_time' => $appTime,
    'amount' => $order->amount, //Eg: 1000000
    'description' => 'YOUR APP - Payment for order No. #'.$order->order_number,
    'item' => json_encode([]),
    'embed_data' => json_encode((object)['redirecturl' => 'https://your-domain.com/callback_url']),
    'bank_code' => '', //''|CC|ATM|Domestic bank code detail at https://docs.zalopay.vn/v2/docs/gateway/api.html#mo-ta_dac-ta-api
    'returnUrl'    => 'https://your-domain.com/callback_listener', // This will assign to callback_url is use by ZaloPay

    // Optional parameters
    'order_type' => 'GOODS', // can be:GOODS/TRANSPORTATION/HOTEL/FOOD/TELCARD/BILLING
    'title' => 'Order Title',
    'device_info' => json_encode([]),
    'currency' => 'VND',
    'phone' => '0902381299',
    'email' => 'gemfourmedia@gmail.com',
    'address' => '123 Alexandre De Rhodes',
    'sub_app_id' => '',
])->send();

if ($response->isRedirect()) {
    $redirectUrl = $response->getRedirectUrl();

    // TODO: redirect to $redirectUrl for customer can make payment via ZaloPay
}
```

Read more detail [here](https://docs.zalopay.vn/v2/general/overview.html#tao-don-hang_thong-tin-don-hang).

### Validate ZaloPay redirect:

[](#validate-zalopay-redirect)

```
$response = $gateway->completePurchase()->send();

if ($response->isSuccessful()) {
    // TODO: Handle data.
    $data = $response->getData();
    $appTransId = $data['apptransid'];

    // SUGGESTION: do query transaction to make sure transaction is successful:
    // $gateway()->queryTransaction(['app_trans_id' => $appTransId])->send()

} else {

    print $response->getMessage();
}
```

Read more detail [here](https://docs.zalopay.vn/v2/docs/gateway/api.html#redirect).

### Check callback (IPN) from ZaloPay

[](#check-callback-ipn-from-zalopay)

```
$response = $gateway->notification()->send();

if ($response->isSuccessful()) {
	// TODO: Handle data.
	$data = $response->getData();
} else {
	print $response->getMessage();
}
```

Read more detail [here](https://docs.zalopay.vn/v2/general/overview.html#callback_dac-ta-api).

### Query transaction:

[](#query-transaction)

```
$gateway()->queryTransaction(['app_trans_id' => $appTransId])->send()

if ($response->isSuccessful()) {
    // TODO: handle data.
    $data = $response->getData()

} else {
    print $response->getMessage();
}
```

Read more detail [here](https://docs.zalopay.vn/v2/general/overview.html#truy-van-trang-thai-thanh-toan-cua-don-hang_dac-ta-api_du-lieu-truyen-vao-api).

### Refund:

[](#refund)

WIP

### Query Refund:

[](#query-refund)

WIP

### Debug:

[](#debug)

Some general methods use when `isSuccessful()` return `FALSE`:

```
    print $response->getCode(); // Error Code From ZaloPay.
    print $response->getMessage(); // Error Message From ZaloPay.
```

Detail status errors for `getCode()` read [here](https://docs.zalopay.vn/v2/general/errors.html).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

1192d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1444aa14373e6766dfef7b2d081bdf7e8753216020724c1c1a83efa43386881?d=identicon)[gemfourmedia](/maintainers/gemfourmedia)

---

Top Contributors

[![gemfourmedia](https://avatars.githubusercontent.com/u/70109217?v=4)](https://github.com/gemfourmedia "gemfourmedia (11 commits)")

---

Tags

paymentpayment gatewayvietnam-paymentvietnam-payment-gatewayzalopaygemfourmedia

### Embed Badge

![Health badge](/badges/gemfourmedia-omnipay-zalopay/health.svg)

```
[![Health](https://phpackages.com/badges/gemfourmedia-omnipay-zalopay/health.svg)](https://phpackages.com/packages/gemfourmedia-omnipay-zalopay)
```

###  Alternatives

[shetabit/payment

Laravel Payment Gateway Integration Package

944330.1k5](/packages/shetabit-payment)[phpviet/omnipay-momo

Thư viện hổ trợ tích hợp cổng thanh toán MoMo.

318.3k2](/packages/phpviet-omnipay-momo)[phpviet/omnipay-vnpay

Thư viện hổ trợ tích hợp cổng thanh toán VNPay.

178.2k2](/packages/phpviet-omnipay-vnpay)[shetabit/multipay

PHP Payment Gateway Integration Package

291348.2k3](/packages/shetabit-multipay)[cybersource/rest-client-php

Client SDK for CyberSource REST APIs

39881.3k6](/packages/cybersource-rest-client-php)[tzsk/payu

PayU India Payment Gateway Integration with Laravel

47108.8k6](/packages/tzsk-payu)

PHPackages © 2026

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