PHPackages                             yedpay/php-library - 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. yedpay/php-library

ActiveLibrary[Payment Processing](/categories/payments)

yedpay/php-library
==================

Agnostic Library to use the Yedpay API for Online Payment

1.4.2(2y ago)5655[1 issues](https://github.com/yedpay/php-library/issues)MITPHPPHP &gt;=5.5CI failing

Since Jun 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/yedpay/php-library)[ Packagist](https://packagist.org/packages/yedpay/php-library)[ RSS](/packages/yedpay-php-library/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (20)Used By (0)

[![Build Status](https://camo.githubusercontent.com/e236ae0c9efb6f75aa8eae8d39a9c129cedad1ae9770d85e785ba1252a05124b/68747470733a2f2f7472617669732d63692e636f6d2f7965647061792f7068702d6c6962726172792e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/github/yedpay/php-library)[![Coverage Status](https://camo.githubusercontent.com/5bc7c0ecb5ef29ee237afd54f674ef4c222b002e64fb9b9d22a15883d5505212/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7965647061792f7068702d6c6962726172792f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/yedpay/php-library?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/3d1e96ca2a392e9595d93a391060390b25e45741ef781b4ebc06db59ea17fbc1/68747470733a2f2f706f7365722e707567782e6f72672f7965647061792f7068702d6c6962726172792f762f737461626c65)](https://packagist.org/packages/yedpay/php-library)[![composer.lock](https://camo.githubusercontent.com/7bfc14a91126e278976b557a55db0226b1d3da989d9b0fbd02ad269c987639c0/68747470733a2f2f706f7365722e707567782e6f72672f7965647061792f7068702d6c6962726172792f636f6d706f7365726c6f636b)](https://packagist.org/packages/yedpay/php-library)

Yedpay Transaction PHP Library
==============================

[](#yedpay-transaction-php-library)

Description
-----------

[](#description)

A PHP library for Precreate Transactions and Online Payments Using the Yedpay API

Prerequisites
-------------

[](#prerequisites)

- [Composer](https://getcomposer.org/)
- [Docker](https://www.docker.com/)
- [Yedpay](https://www.yedpay.com/)

In order to start using the API, you need to get Your Personal Access Token or API Key.

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

[](#installation)

### Installing Dependencies

[](#installing-dependencies)

```
composer require yedpay/php-library

```

### Running the test

[](#running-the-test)

```
vendor/bin/phpunit

```

Integration
-----------

[](#integration)

### Request Method

[](#request-method)

- Precreate

ParameterTypeDescriptionaccessTokenStringAccessToken used to access APIenvironmentStringEnvironment ( 'staging' or 'production' )storeIdStringStore ID in the APIamountDoubleamount of the transactioncurrencyIntegertransaction currency (1: HKD)gatewayIntegertransaction gateway (1: Alipay, 4: Alipay Online)walletIntegerAlipay wallet type (1: HK, 2: CN)extraParamJSON(Optional) Extra information of the transactionnotify\_urlUrl(Optional) Notify Url of the transactionreturn\_urlUrl(Optional) Return Url of the transaction- Online Payment

ParameterTypeDescriptionapiKeyStringApi Key used to access APIenvironmentStringEnvironment ( 'staging' or 'production' )customIdStringCustom ID in the APIamountDoubleamount of the transactioncurrencyIntegertransaction currency (1: HKD)notify\_urlUrlNotify Url of the transactionreturn\_urlUrlReturn Url of the transactiongatewayCodeString(Optional) transaction gateway code (4\_1: Alipay Online WAP, 4\_2: Alipay Online PC2Mobile, 8\_2: WeChat Pay Online, 9\_1: UnionPay ExpressPay, 9\_5: UnionPay UPOP, 12\_1: Credit Card Online)walletInteger(Optional) Alipay wallet type (1: HK, 2: CN)subjectString(Optional) Product Name of the transactionexpiryTimeInteger(Optional) Expiry Time in Seconds of the transaction (Range: 900 - 10800)metadataJson(Optional) metadata for plugin informationpaymentDataJson(Optional) Payment Data that will include in the payment page (Card payment only, support `first_name`, `last_name`, `email`, `phone`, `billing_country`, `billing_city`, `billing_address1`, `billing_address2`, `billing_post_code`, `billing_state`)checkoutDomainIdString(Optional) Checkout domain Key- Refund

ParameterTypeDescriptionaccessTokenString(Required without apiKey) AccessToken used to access APIapiKeyString(Required without accessToken) Api Key used to access APIenvironmentStringEnvironment ( `staging` or `production` )transactionIdStringTransaction ID in the APIreasonString(Optional) refund reason of the transaction- Refund by Custom ID

ParameterTypeDescriptionapiKeyString(Required without accessToken) Api Key used to access APIenvironmentStringEnvironment ( 'staging' or 'production' )customIdStringCustom ID in the APIreasonString(Optional) refund reason of the transaction- Query Online Payment

ParameterTypeDescriptionapiKeyString(Required without accessToken) Api Key used to access APIenvironmentStringEnvironment ( 'staging' or 'production' )customIdStringCustom ID in the API### Result

[](#result)

- Success

ParameterTypeDescriptionmessagestringResponse messagedatastring(JSON)Data of the response- Error

ParameterTypeDescriptionmessagestringResponse messageerrorCodeintHTTP standard response codeerrorstringDetail of the error- Example Precreate Transaction Implementation

Input parameters

```
//mandatory parameters
$accessToken = 'J84OFPAN';
$storeId = '8X4LZW2XLG9V';
$amount = 1.0;
//optional parameter: extraParam (JSON)
$extraParam = json_encode([
    'customer_name' => 'Yed Pay',
    'phone' => '12345678',
]);

```

Create instance of Client

```
$client = new Client(Library::STAGING, $accessToken);

```

(Optional) Setting Transaction parameters

```
//changing transaction currency (default: HKD)
$client->setCurrency(Client::INDEX_CURRENCY_HKD);
//changing alipay wallet type (default: HK)
$client->setWallet(Client::INDEX_WALLET_CN);

```

Sending Precreate Request

```
// general
$client->precreate($storeId, $amount);
// with extra parameters
$result = $client->precreate(
        $storeId,
        $amount,
        json_encode($extraParam)
)->getData();

```

- Example Online Payment Implementation

Input parameters

```
//mandatory parameters
$apiKey = 'qPOcLJsNnnI2wzJdIsRULOwC//KZa+KGrarUIs1ZZa8=';
$customId = 'test-001';
$amount = 1.0;
$currency = 1;
$notifyUrl = 'https://www.example.com/notify';
$returnUrl = 'https://www.example.com/return';

```

Create instance of Client

```
$client = new Client(Library::STAGING, $apiKey, false);

```

(Optional) Setting Transaction parameters

```
//changing transaction currency (default: HKD)
$client->setCurrency(Client::INDEX_CURRENCY_HKD);

//set transaction gateway code
$client->setGatewayCode(Client::INDEX_GATEWAY_CODE_ALIPAY_ONLINE_PC2MOBILE);

//set transaction gateway wallet type (default: HK)
$client->setWallet(Client::INDEX_WALLET_CN);

//set production name of transaction
$client->setSubject('Product');

//set expiry time of transaction
$client->setExpiryTime(900);

//set metadata of online payment
$metadata = json_encode([
    'woocommerce' => '1.0',
    'yedpay_for_woocommerce' => '1.0',
    'wordpress' => '1.0',
]);
$client->setMetadata($metadata);

//set payment data of online payment
$paymentData = json_encode([
    'first_name' => 'Yedpay',
    'last_name' => 'Yedpay',
    'email' => 'info@example.com',
    'phone' => '12345678',
    'billing_country' => 'HK',
    'billing_city' => 'Hong Kong',
    'billing_address1' => 'Address1',
    'billing_address2' => 'Address2',
    'billing_post_code' => '000000',
]);
$client->setPaymentData($paymentData);

//set checkout domain key of online payment
$client->setCheckoutDomainId('J84OFPAN');

```

Sending Online Payment Request

```
$client->onlinePayment($customId, $amount)->getData();

```

- Example Refund Transaction Implementation

Input parameters

```
//mandatory parameters
$transactionId = 'J84OFPAN';
//optional parameter: reason (String)
$reason = 'testing';

```

Create instance of Client

```
// with accessToken
$client = new Client(Library::STAGING, $accessToken);
// with apiKey
$client = new Client(Library::STAGING, $apiKey, false);

```

Sending Refund Request

```
// general
$client->refund($transactionId)->getData();
// with reason
$client->refund($transactionId, $reason)->getData();
// with amount
$client->refund($transactionId, $reason, $amount)->getData();

```

- Example Refund by Custom ID Implementation

Input parameters

```
//mandatory parameters
$customId = 'J84OFPAN';
//optional parameter: reason (String)
$reason = 'testing';

```

Create instance of Client

```
// with apiKey
$client = new Client(Library::STAGING, $apiKey, false);

```

Sending Refund by Custom ID Request

```
// general
$client->refundByCustomId($customId)->getData();
// with reason
$client->refundByCustomId($customId, $reason)->getData();
// with amount
$client->refundByCustomId($customId, $reason, $amount)->getData();

```

For the complete Code Check the examples folder

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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 ~114 days

Recently: every ~199 days

Total

19

Last Release

852d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0bf83ff545459af84dd55458f8c690cc09843897276b0b676c9398beb7a18f40?d=identicon)[yedpay](/maintainers/yedpay)

---

Top Contributors

[![beabys](https://avatars.githubusercontent.com/u/7307103?v=4)](https://github.com/beabys "beabys (9 commits)")[![kobeyedpay](https://avatars.githubusercontent.com/u/39042388?v=4)](https://github.com/kobeyedpay "kobeyedpay (7 commits)")[![andrewwongyedpay](https://avatars.githubusercontent.com/u/54163882?v=4)](https://github.com/andrewwongyedpay "andrewwongyedpay (1 commits)")[![k-yedpay](https://avatars.githubusercontent.com/u/129022278?v=4)](https://github.com/k-yedpay "k-yedpay (1 commits)")

---

Tags

alipayhongkongpayment-gatewaypayment-sdkphp-libraryunionpay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/yedpay-php-library/health.svg)

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

###  Alternatives

[omnipay/paypal

PayPal gateway for Omnipay payment processing library

3156.8M53](/packages/omnipay-paypal)[eduardokum/laravel-boleto

Biblioteca com boletos para o laravel

626351.9k2](/packages/eduardokum-laravel-boleto)[tbbc/money-bundle

This is a Symfony bundle that integrates moneyphp/money library (Fowler pattern): https://github.com/moneyphp/money.

1961.9M](/packages/tbbc-money-bundle)[2checkout/2checkout-php

2Checkout PHP Library

83740.3k2](/packages/2checkout-2checkout-php)[smhg/sepa-qr-data

Generate QR code data for SEPA payments

61717.2k5](/packages/smhg-sepa-qr-data)[omnipay/dummy

Dummy driver for the Omnipay payment processing library

271.2M33](/packages/omnipay-dummy)

PHPackages © 2026

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