PHP code example of tu6ge / ysepay-sdk

1. Go to this page and download the library: Download tu6ge/ysepay-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tu6ge / ysepay-sdk example snippets



$config = [
              'business_gate_cert'    => 'xxx',    //公钥路径
              'private_cert'          => 'xxx',           //私钥路径
              'partner_id'            => '',
              'seller_id'             => '',
              'seller_name'           => '',
          
              'pfxpassword'           => '',
              'merchant_code'         => '',
          
              'business_code'         => '',
              'log'   => [
                  'path' => __DIR__.'/info.log',
                  'name'  => 'ysepay',
              ]
$app = \YsepaySdk\Client($config);

//创建一个支付宝app支付的订单
$html = $app->alipay->create([
   'notify_url'            => 'http://www.xxx.com/return.php',
   'return_url'            => 'http://www.xxx.com/return.php',
   'out_trade_no'          => time(),
   'subject'               => 'test composer',
   'total_amount'          => 0.01,
], 'html');
echo $html;

//查询账户余额
$rs = $app->order->getBalance([
    'user_code'     => 'xxx',
    'user_name'     => 'xxx',
]);
print_r($rs);

//查询订单
$rs = $app->order->getOrder([
    "out_trade_no"  => '5998636703390937407',
    "trade_no"      => '01O190703750273951'
]);
print_r($rs);