PHPackages                             yuansfer/yuansfer-php-sdk - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yuansfer/yuansfer-php-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yuansfer/yuansfer-php-sdk
=========================

Yuansfer PHP SDK

v3.0.5(2y ago)117.7k↓41.2%2[1 PRs](https://github.com/yuansfer/yuansfer-php-sdk/pulls)Apache-2.0PHPPHP &gt;=5.3

Since Jan 15Pushed 1y ago4 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

Yuansfer PHP SDK
================

[](#yuansfer-php-sdk)

[![Latest Stable Version](https://camo.githubusercontent.com/09f7266166b77cfa33bb1aa9887526c62ce00bd445b97878969f7007a860cac0/68747470733a2f2f706f7365722e707567782e6f72672f7975616e736665722f7975616e736665722d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/yuansfer/yuansfer-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/5cea77aabb01006cb991069c7c72c32bf60a5b1cdd7717c3a8a18196d29cd307/68747470733a2f2f706f7365722e707567782e6f72672f7975616e736665722f7975616e736665722d7068702d73646b2f646f776e6c6f616473)](https://packagist.org/packages/yuansfer/yuansfer-php-sdk)[![Monthly Downloads](https://camo.githubusercontent.com/3f988f5130d97f266629e3928b3dd9eed934f5f3ee3b28a5a08e34b1f1c5866f/68747470733a2f2f706f7365722e707567782e6f72672f7975616e736665722f7975616e736665722d7068702d73646b2f642f6d6f6e74686c79)](https://packagist.org/packages/yuansfer/yuansfer-php-sdk)[![License](https://camo.githubusercontent.com/aa12ab8d3fac9c2ecd19da9763ca3d0edfdab422ba9a7285131e710f39e2df8b/68747470733a2f2f706f7365722e707567782e6f72672f7975616e736665722f7975616e736665722d7068702d73646b2f6c6963656e7365)](https://packagist.org/packages/yuansfer/yuansfer-php-sdk)

[Yuansfer Online API](https://docs.pockyt.io/)

Requirements
------------

[](#requirements)

- PHP &gt;= 5.3
- CURL extension

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

[](#installation)

1. Install composer:

    ```
    $ curl -sS https://getcomposer.org/installer | php
    ```

    More info about installation on [Linux / Unix / OSX](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)and [Windows](https://getcomposer.org/doc/00-intro.md#installation-windows).
2. Run the Composer command to install the latest version of SDK:

    ```
    $ php composer.phar require yuansfer/yuansfer-php-sdk
    ```
3. Require Composer's autoloader in your PHP script (assuming it is in the same directory where you installed Composer):

    ```
    require('vendor/autoload.php');
    ```

Usage
-----

[](#usage)

Please see [examples](https://github.com/yuansfer/yuansfer-php-sdk/tree/master/example)

### 1. Init

[](#1-init)

```
use Yuansfer\Yuansfer;

$config = array(
    Yuansfer::MERCHANT_NO => 'The merchant NO.',
    Yuansfer::STORE_NO => 'The store NO.',
    Yuansfer::API_TOKEN => 'Yuansfer API token',
    Yuansfer::TEST_API_TOKEN => 'Yuansfer API token for test mode',
    Yuansfer::MER_GROUP_NO => 'The merchant group NO, optional.',
);

$yuansfer = new Yuansfer($config);
```

### 2. Create API

[](#2-create-api)

```
$api = $yuansfer->createSecurePay();
```

### 3. Set API Parameters

[](#3-set-api-parameters)

```
$api
    ->setAmount(9.9) //The amount of the transaction.
    ->setCurrency('USD') // The currency, USD, CAD supported yet.
    ->setSettleCurrency('USD') // When the currency is "GBP", the settlement currency is "GBP". All other currencies settle with "USD"
    ->setVendor('alipay') // The payment channel, alipay, wechatpay, unionpay, enterprisepay are supported yet.
    ->setReference('44444') //The unque ID of client's system.
    ->setIpnUrl('http://domain/example/callback_secure_pay_ipn.php') // The asynchronous callback method.
    ->setCallbackUrl('http://domain/example/callback_secure_pay.php'); // The Synchronous callback method.
```

### 4.1. Send

[](#41-send)

```
$response = $api->send();
```

### 4.2. Use Test Mode

[](#42-use-test-mode)

```
$yuansfer->setTestMode();
$response = $api->send();
```

### 5. API return JSON, already decoded as array

[](#5-api-return-json-already-decoded-as-array)

```
if ($response['ret_code'] === '000100') {
	header('Location: ' . $response['result']['cashierUrl']);
}
```

### 6. Exceptions when sending

[](#6-exceptions-when-sending)

```
try {
    $response = $api->send();
} catch (\Yuansfer\Exception\YuansferException $e) {
    // required param is empty
    if ($e instanceof \Yuansfer\Exception\RequiredEmptyException) {
        $message = 'The param: ' . $e->getParam() . ' is empty, in API: ' . $e->getApi();
    }

    // http connect error
    if ($e instanceof \Yuansfer\Exception\HttpClientException) {
        $message = $e->getMessage();
    }

    // http response status code < 200 or >= 300, 301 and 302 will auto redirect
    if ($e instanceof \Yuansfer\Exception\HttpErrorException) {
        /** @var \Httpful\Response http response */
        $response = $e->getResponse();
    }
}
```

API Documents
-------------

[](#api-documents)

[Official Documents](https://docs.pockyt.io/)

### IN-STORE API'S

[](#in-store-apis)

#### Merchant Presented Workflow

[](#merchant-presented-workflow)

APICallDescription[Create QRC API](https://docs.pockyt.io/in-store-apis/merchant-presented-workflow/create-qrc-api)`$yuansfer->createTransQrcode()`This API generates a QR Code and transaction number for the customer to scan via their digital wallet app, allowing them to initiate the payment process.#### Customer Presented Workflow

[](#customer-presented-workflow)

APICallDescription[Add Transaction API](https://docs.pockyt.io/in-store-apis/customer-presented-workflow/add-transaction-api)`$yuansfer->createAdd()`This API enables the creation of a transaction object and allows the customer to retrieve a transaction number for initiating payment.[Pay Transaction API](https://docs.pockyt.io/in-store-apis/customer-presented-workflow/pay-transaction-api)`$yuansfer->createPrepay()`This will allow customers to make the final confirmation before submitting payment which will process through the digital wallet servers.[Cancel API](https://docs.pockyt.io/in-store-apis/cancel-api)`$yuansfer->createCancel()`This API allows for canceling a payment transaction in either use case when the transaction is abandoned before submission, ensuring that merchants can efficiently manage their transactions.### REFUND AND QUERY API'S

[](#refund-and-query-apis)

APICallDescription[Refund API](https://docs.pockyt.io/refund-and-query-apis/refund-api)`$yuansfer->createRefund()`In the instance where a customer requests a refund, the following request and response objects are initiated to complete the refund workflow.[Query API](https://docs.pockyt.io/refund-and-query-apis/query-api)`$yuansfer->createTranQuery()`This API is used for polling transaction results, researching transactions for refunds, and generating custom reports.### ECOMMERCE API'S

[](#ecommerce-apis)

#### Pockyt Hosted Checkout

[](#pockyt-hosted-checkout)

APICallDescription[SecurePay API](https://docs.pockyt.io/ecommerce-apis/pockyt-hosted-checkout/securepay-api)`$yuansfer->createSecurePay()`By using this API, the merchant website can send customers to Pockyt to receive payments.#### Pockyt Integrated Payments

[](#pockyt-integrated-payments)

APICallDescription[Process API](https://docs.pockyt.io/pockyt-integrated-payments/process-api)`$yuansfer->createProcess()`Utilize our Partner Payment Gateways to accept popular wallets such as PayPal, Venmo, Google Pay, and Apple Pay. When integrating with Partner Payment Gateways, utilize both the 'process' endpoint#### Customer Records

[](#customer-records)

APICallDescription[Register Customer](https://docs.pockyt.io/customer-records/register-customer)`$yuansfer->createCustomerCreate()`Use this API to create a new customer, and receiving the Customer Number from Pockyt, to be invoked during calls to the SecurePay API.[Retrieve Customer](https://docs.pockyt.io/customer-records/retrieve-customer)`$yuansfer->createCustomerRetrieve()`Use this API to retrieve the customer information stored in the record, to be used in calls to the SecurePay API.[Update Customer](https://docs.pockyt.io/customer-records/update-customer)`$yuansfer->createCustomerUpdate()`Use this API to update information related to the customer's record.#### PAYOUTS API'S

[](#payouts-apis)

#### Payouts

[](#payouts)

APICallDescription[Register Payee](https://docs.pockyt.io/payouts-apis/payouts/register-payee)`$yuansfer->createPayeeRegister()`To initiate payments to your payees, you must first register an account with Pockyt. Send a POST request to the Register Customer endpoint, and you'll receive a customerNo in response.[Retrieve Payee](https://docs.pockyt.io/payouts-apis/payouts/retrieve-payee)`$yuansfer->createPayeeRetrieve()`Acquire detailed information about a payee's account by sending a POST request to Pockyt's Retrieve Payee Account API. This enables you to manage and verify payee accounts effectively, maintaining the[Update Payee](https://docs.pockyt.io/payouts-apis/payouts/update-payee)`$yuansfer->createPayeeUpdate()`To update payee details such as name, address, email, and bank info by providing customer No and new details. The API returns a confirmation message upon successful execution[Add Payee Bank](https://docs.pockyt.io/payouts-apis/payouts/add-payee-bank)`$yuansfer->createPayeeAddBank()`Add a new payment method for the payee, such as a bank account. This endpoint requires the user to provide the Merhcnat ID and the payment details in the request payload.[Transfer Payout](https://docs.pockyt.io/payouts-apis/payouts/transfer-payout)`$yuansfer->createPayoutPay()`To execute a payment, send a POST request to the payments endpoint. Upon successful validation, the specified amount will be transferred to the receiver, completing the payment transaction.YIP
---

[](#yip)

[Official Documents](https://bitbucket.org/pockyt-external/yip/src/master/)

### [capture](https://bitbucket.org/pockyt-external/yip/src/master/capture.md)

[](#capture)

APICallDescription/order/v4/capture`$yuansfer->createYipOrderCapture()`To fund a payment with a credit or debit card.### [no\_vaulting](https://bitbucket.org/pockyt-external/yip/src/master/no_vaulting.md)

[](#no_vaulting)

APICallDescription/online/v4/secure-pay`$yuansfer->createYipSecurePay()`PayPal Payment Method`$yuansfer->createYipOrderProcess()`Call this API when the customer approved the payment order, see HTML Sample code at #line 57Card Payment Method`$yuansfer->createYipOrderProcess()`Call this API when the customer approved the payment order, see HTML Sample code at #line 57### [with\_vaulting](https://bitbucket.org/pockyt-external/yip/src/master/with_vaulting.md)

[](#with_vaulting)

APICallDescriptionCapture order and save payment methods`$yuansfer->createYipSecurePayVault()`Complete the payment transaction`$yuansfer->createYipOrderProcess()`Call this API when the customer approved the payment order, see HTML Sample code at #line 57Pay with saved payment methods`$yuansfer->createYipSecurePayVaultSaved()`

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~196 days

Recently: every ~241 days

Total

12

Last Release

881d ago

Major Versions

1.x-dev → v3.0.02020-11-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/157430?v=4)[FENG Hao](/maintainers/flyinghail)[@flyinghail](https://github.com/flyinghail)

---

Top Contributors

[![flyinghail](https://avatars.githubusercontent.com/u/157430?v=4)](https://github.com/flyinghail "flyinghail (43 commits)")[![zk302302](https://avatars.githubusercontent.com/u/26562444?v=4)](https://github.com/zk302302 "zk302302 (4 commits)")[![xbeta](https://avatars.githubusercontent.com/u/975296?v=4)](https://github.com/xbeta "xbeta (2 commits)")[![farry2021](https://avatars.githubusercontent.com/u/87508248?v=4)](https://github.com/farry2021 "farry2021 (1 commits)")

---

Tags

sdksdkyuansfer

### Embed Badge

![Health badge](/badges/yuansfer-yuansfer-php-sdk/health.svg)

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

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

420300.1M4](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

409.5M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29016.1k1](/packages/ennnnny-tbk)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)

PHPackages © 2026

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