PHPackages                             yuansfertest/yuansfer-php-test-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. yuansfertest/yuansfer-php-test-sdk

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

yuansfertest/yuansfer-php-test-sdk
==================================

Yuansfer PHP SDK

v3.1(5y ago)013Apache-2.0PHPPHP &gt;=5.3

Since Apr 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/xuehao712/test1)[ Packagist](https://packagist.org/packages/yuansfertest/yuansfer-php-test-sdk)[ Docs](https://www.yuansfer.com/)[ RSS](/packages/yuansfertest-yuansfer-php-test-sdk/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (3)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.yuansfer.com/)

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

[](#requirements)

- PHP &gt;= 5.3
- CURL extension

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

[](#installation)

### With Composer (recommended)

[](#with-composer-recommended)

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');
    ```

### PHAR with bundled dependencies

[](#phar-with-bundled-dependencies)

**This is not recommended! Use [Composer](http://getcomposer.org) as modern way of working with PHP packages.**

1. Download [PHAR file](https://github.com/yuansfer/yuansfer-php-sdk/releases/latest)
2. Require files:

    ```
    require('path-to-sdk/yuansfer-php-sdk.phar');
    ```

Please keep in mind that bundled dependencies may interfere with your other dependencies.

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 = 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.
    ->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.yuansfer.com/)

### Payments

[](#payments)

#### Online Payment

[](#online-payment)

##### Yuansfer Checkout

[](#yuansfer-checkout)

APICallDescription[secure-pay()](https://docs.yuansfer.com/api-reference-v3/payments/online-payment/secure-pay)`$yuansfer->createSecurePay()`This is used to pay for an order.##### Yuansfer Integrated Payment

[](#yuansfer-integrated-payment)

APICallDescription[process()](https://docs.yuansfer.com/api-reference-v3/payments/online-payment/yuansfer-integrated-payment/braintree-payments)`$yuansfer->createProcess()`Braintree Payments[prepay()](https://docs.yuansfer.com/api-reference-v3/payments/online-payment/prepay)`$yuansfer->createPrepay()`This API does the mobile payment for the POS system.#### Point of Sale Payment

[](#point-of-sale-payment)

##### Scan QR Code

[](#scan-qr-code)

APICallDescription[add()](https://docs.yuansfer.com/api-reference-v3/payments/in-store-payment/scan-qrcode/add)`$yuansfer->createAdd()`This API initiates a **Barcode/QR Code Payment** request and creates a transaction order.[pay()](https://docs.yuansfer.com/api-reference-v3/payments/in-store-payment/scan-qrcode/pay)`$yuansfer->createPay()`This API places an order in the **Barcode/QR Code Payment**.#### Create QR Code

[](#create-qr-code)

APICallDescription[create-trans-qrcode()](https://docs.yuansfer.com/api-reference-v3/payments/in-store-payment/create-qrcode)`$yuansfer->createTransQrcode()`This API creates a transaction and get a QR code for customers to scan to pay in the **Transaction QR Code Payment** process. Customers scan this QR code using the wallet app to checkout.### Transaction Revert

[](#transaction-revert)

APICallDescription[refund()](https://docs.yuansfer.com/#refund)`$yuansfer->createRefund()`This API refunds the payment of a transaction.[cancel()](https://docs.yuansfer.com/api-reference-v3/transaction-revert/cancel)`$yuansfer->createCancel()`This API cancels the payment of a transaction.### Transaction Data Search

[](#transaction-data-search)

APICallDescription[tran-query()](https://docs.yuansfer.com/api-reference-v3/transaction-data-search/tran-query)`$yuansfer->createTranQuery()`This API gets the transaction details by ID of a transaction in the merchant's system.[trans-list()](https://docs.yuansfer.com/api-reference-v3/transaction-data-search/trans-list)`$yuansfer->createTransList()`This API gets all transaction details for a given time period.[settle-list()](https://docs.yuansfer.com/api-reference-v3/transaction-data-search/settle-list)`$yuansfer->createSettleList()`This API gets all settlement details for a given time period.[withdrawal-list()](https://docs.yuansfer.com/api-reference-v3/transaction-data-search/withdrawal-list)`$yuansfer->createWithdrawalList()`This API gets all withdrawal details for a given time period.[data-status()](https://docs.yuansfer.com/api-reference-v3/transaction-data-search/data-status)`$yuansfer->createDataStatus()`This API gets the settlement status for a given date.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Total

2

Last Release

1890d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/52e74c7309ac925d33e9febb5d681eae1eed3269a45e48a76cf258ed03be287d?d=identicon)[shawn.yuansfer](/maintainers/shawn.yuansfer)

---

Tags

sdkyuansfer

### Embed Badge

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

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

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

423329.7M10](/packages/aws-aws-crt-php)[shetabit/visitor

Laravel visitor

567637.9k14](/packages/shetabit-visitor)[yuansfer/yuansfer-php-sdk

Yuansfer PHP SDK

118.9k](/packages/yuansfer-yuansfer-php-sdk)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[bedita/manager

BEdita Manager - official admin webapp for BEdita4 API

131.2k](/packages/bedita-manager)

PHPackages © 2026

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