2017 © Pedro Peláez
 

library yuansfer-php-sdk

Yuansfer PHP SDK

image

yuansfer/yuansfer-php-sdk

Yuansfer PHP SDK

  • Tuesday, July 17, 2018
  • by flyinghail
  • Repository
  • 3 Watchers
  • 2 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 73 % Grown

The README.md

Yuansfer PHP SDK

Latest Stable Version Total Downloads Monthly Downloads License, (*1)

Yuansfer Online API, (*2)

Requirements

  • PHP >= 5.3
  • CURL extension

Installation

  1. Install composer:, (*3)

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

    More info about installation on Linux / Unix / OSX and Windows., (*4)

  2. Run the Composer command to install the latest version of SDK:, (*5)

    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):, (*6)

    php require('vendor/autoload.php');, (*7)

PHAR with bundled dependencies

This is not recommended! Use Composer as modern way of working with PHP packages., (*8)

  1. Download PHAR file, (*9)

  2. Require files:, (*10)

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

Please keep in mind that bundled dependencies may interfere with your other dependencies., (*11)

Usage

Please see examples, (*12)

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

$api = $yuansfer->createSecurePay();

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

$response = $api->send();

4.2. Use Test Mode

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

5. API return JSON, already decoded as array

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

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

Official Documents, (*13)

Payments

Online Payment

Yuansfer Checkout
API Call Description
secure-pay() $yuansfer->createSecurePay() This is used to pay for an order.
Yuansfer Integrated Payment
API Call Description
process() $yuansfer->createProcess() Braintree Payments
prepay() $yuansfer->createPrepay() This API does the mobile payment for the POS system.

Point of Sale Payment

Scan QR Code
API Call Description
add() $yuansfer->createAdd() This API initiates a Barcode/QR Code Payment request and creates a transaction order.
pay() $yuansfer->createPay() This API places an order in the Barcode/QR Code Payment.

Create QR Code

API Call Description
create-trans-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

API Call Description
refund() $yuansfer->createRefund() This API refunds the payment of a transaction.
cancel() $yuansfer->createCancel() This API cancels the payment of a transaction.
API Call Description
tran-query() $yuansfer->createTranQuery() This API gets the transaction details by ID of a transaction in the merchant's system.
trans-list() $yuansfer->createTransList() This API gets all transaction details for a given time period.
settle-list() $yuansfer->createSettleList() This API gets all settlement details for a given time period.
withdrawal-list() $yuansfer->createWithdrawalList() This API gets all withdrawal details for a given time period.
data-status() $yuansfer->createDataStatus() This API gets the settlement status for a given date.

The Versions

17/07 2018

1.x-dev

1.9999999.9999999.9999999-dev https://www.yuansfer.com/

Yuansfer PHP SDK

  Sources   Download

Apache-2.0

The Requires

 

by Feng Hao

sdk yuansfer

17/07 2018

v1.0.1

1.0.1.0 https://www.yuansfer.com/

Yuansfer PHP SDK

  Sources   Download

Apache-2.0

The Requires

 

by Feng Hao

sdk yuansfer

17/07 2018

dev-master

9999999-dev https://www.yuansfer.com/

Yuansfer PHP SDK

  Sources   Download

Apache-2.0

The Requires

 

by Feng Hao

sdk yuansfer

15/01 2018

v1.0.0

1.0.0.0 https://www.yuansfer.com/

Yuansfer PHP SDK

  Sources   Download

Apache-2.0

The Requires

 

by Feng Hao

sdk yuansfer