PHPackages                             pilibaba/pilipay-php - 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. pilibaba/pilipay-php

ActiveLibrary[Payment Processing](/categories/payments)

pilibaba/pilipay-php
====================

Pilipay is short for Pilibaba's payment. This library provides pilipay's API (in PHP).

119.6k[2 issues](https://github.com/pilibaba/pilipay/issues)PHP

Since May 10Pushed 10y ago2 watchersCompare

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

READMEChangelog (1)DependenciesVersions (1)Used By (0)

What Is Pilipay?
----------------

[](#what-is-pilipay)

Pilipay is short for Pilibaba's payment. This library provides pilipay's API (in PHP).

API Reference
-------------

[](#api-reference)

Firstly please take a quick look at the [HTTP API reference](http://api.pilibaba.com/doc/pilipay-http-api-reference.html) to get familiar with the basic bussiness logics.

As how to use in PHP, it's pretty simple:

### Checking Requirements

[](#checking-requirements)

First of all, you should check the requirements via `PilipayConfig::check()`. If requirements is not satisfied, there would be some errors when using this library. Example Code:

```
// check requirements:
if (!PilipayConfig::check($errors)) {
	// prompt errors to the merchant or administractor
	echo "Error: Pilipay requirements is not satisfied: \n";
	echo implode("\n", $errors);
}
```

Currently, the following requirements are to be checked:

1. `curl` or `fsockopen` to make requests
2. `openssl` to make HTTPS requests

### Submit an order

[](#submit-an-order)

1. require the `autoload.php` in order to auto load the classes in pilipay.
2. create an order by `$order = new PilipayOrder()`.
3. fill essential fields in the order.
4. create a good by `$good = new PilipayGood()`.
5. fill essential fields in the good.
6. add good to the order by `$order->addGood($good);`.
7. if there are more goods, repeate 4, 5, and 6.
8. submit order by `echo $order->renderSubmitForm(); die;`

Sample code:

```
// autoload
require 'path/to/pilipay/autoload.php';

// create an order
$order = new PilipayOrder();
$order->merchantNo = '1231312';  // a number for a merchant from pilibaba
$order->appSecret = 'abcdefg'; // the secret key from pilibaba
$order->currencyType = 'USD'; // indicates the unit of the following orderAmount, shipper, tax and price
$order->orderNo = '1231231231';
$order->orderAmount = '1.23';
$order->pageUrl = 'https://www.example-shop.com/path/to/some/product';
$order->serverUrl = 'https://www.example-shop.com/path/to/paid/callback';
$order->shipper = '1.23';
$order->tax = '1.23';

// create a good
$good = new PilipayGood();
$good->name = 'Product Name';
$good->pictureUrl = 'https://www.example-shop.com/path/to/product/picture';
$good->price = '1.23';
$good->productUrl = 'https://www.example-shop.com/path/to/product';
$good->productId = '123123';
$good->quantity = 1;
$good->weight = 1.23;
$good->weightUnit = 'kg';

// add the good to order
$order->addGood($good);

// if there are more goods, please add...
//$good  = new PilipayGood();
//...
//$order->addGood($good);

// render submit form, which would auto submit
echo $order->renderSubmitForm();
die;
```

### Get the barcode

[](#get-the-barcode)

1. require the `autoload.php` in order to auto load the classes in pilipay.
2. create an order by `$order = new PilipayOrder();`.
3. fill essential fields into the order.
4. get the barcode's picture URL by `$barcodePicUrl = $order->getBarcodePicUrl();`.

Sample code:

```
// autoload
require 'path/to/pilipay/autoload.php';

// create an order
$order = new PilipayOrder();

// orderNo and merchantNo must be provided:
$order->orderNo = '123123';
$order->merchantNo = '123123';

// get the barcode's picture URL:
$barcodePicUrl = $order->getBarcodePicUrl();

// do whatever you want to with the barcode

```

### Update tracking number

[](#update-tracking-number)

1. require the `autoload.php` in order to auto load the classes in pilipay.
2. create an order by `$order = new PilipayOrder();`.
3. fill essential fields into the order.
4. invoke update by `$order->updateTrackNo($trackNo);`.

Sample code:

```
// autoload
require 'path/to/pilipay/autoload.php';

// create an order
$order = new PilipayOrder();

// orderNo and merchantNo must be provided:
$order->orderNo = '123123';
$order->merchantNo = '123123';

// update
$order->updateTrackNo($trackNo); // $trackNo must be the same with the track number on the package when shipping.
```

### Deal the pay result

[](#deal-the-pay-result)

After the customer has paid, a request to `$order->serverUrl` would be sent. In order to properly deal this request, `PilipayPayResult` can be used. It's pretty simple. So just show the example code:

```
// autoload
require 'path/to/pilipay/autoload.php';

// create an instance from the request
$payResult = PilipayPayResult::fromRequest();

// verify whether the request is valid:
if (!$payResult->verify($appSecret)){ // $appSecret is exactly the same with $order->appSecret
	// error handling...
	die('Invalid request');
}

// judge whether payment is successfully completed:
if (!$payResult->isSuccess()){
	// deal failure
} else {
	// deal success
}
```

### Handle errors

[](#handle-errors)

When setting fields of an order or a good, submiting the order, and updating track number, if an error is encountered, a `PilipayError` will be thrown. So a `try ... catch` block should be used to deal errors. Example code:

```
try{
	// submit order, update track number...
} catch (PilipayError $e) {
	// deal the error
	// $e->getMessage() will be detailed reason.
}
```

### Record logs

[](#record-logs)

`PilipayLogger` provides a extendable logging. `PilipayLogger::setHandler()` can be used to inject a logger handler. For example, logging to a file:

```
PilipayLogger::instance()->setHandler(function($level, $msg){
	file_put_contents('path/to/pilipay/log/file', sprintf('%s %s: %s'.PHP_EOL, date('Y-m-d H:i:s'), $level, $msg));
});
```

### Configurations

[](#configurations)

There are some helpful configurations:

1. `useHttps` defines whether to use HTTPS - although HTTPS is recommend by default, you might want to use HTTP in some circumstances.
2. `useProductionEnv` defines whether to use the production environment. It's default value is `true`. But when you are testing, it is recommend to set `useProductionEnv` to `false`. After that, you will not need to pay real money to complete an order. Orders will be simulated as if be paid.

Example code:

```
// Not recommended: use HTTP interface - maybe openssl on the server cannot work.
PilipayConfig::setUseHttps(false);

// When testing, do not use production environment:
PilipayConfig::setUseProductionEnv(false);
```

Support
-------

[](#support)

1. [Make an issue on github](https://github.com/pilibaba/pilipay/issues/new)
2. [Our official API site](http://api.pilibaba.com/)
3. Send an email: developers(AT)pilibaba.com

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/82d8a739cfa464f5e57f8d7fd9b89b64a61fe788442c6d73e5912a6ba10b19cb?d=identicon)[developer-pilibaba](/maintainers/developer-pilibaba)

---

Top Contributors

[![Clarence-pan](https://avatars.githubusercontent.com/u/8750132?v=4)](https://github.com/Clarence-pan "Clarence-pan (57 commits)")[![developer-pilibaba](https://avatars.githubusercontent.com/u/16659831?v=4)](https://github.com/developer-pilibaba "developer-pilibaba (3 commits)")

### Embed Badge

![Health badge](/badges/pilibaba-pilipay-php/health.svg)

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

###  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)
