PHP code example of manarch / crossborder

1. Go to this page and download the library: Download manarch/crossborder 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/ */

    

manarch / crossborder example snippets




use Yjpay\Yht\Application\RealName;

$globalDeveloperInfo = [
  # 开发者ID
  'partnerId'=>'2014092*********8373',
  # 开发者密钥
  'secretKey'=>'2af0376a*********1ab889384a8ade9',
  #开启调试模式
  'debug'=>true,
  # 日志记录地址,默认为'/logs/',linux系统请先创建你的目录并保证目录有读写全下,不传此参数默认为'/logs/'
  'logPath'=>'/logs/'
];

$RealName = new RealName($globalDeveloperInfo,
  [
    'merchOrderNo'=>date('YmdHis').mt_rand(1111,9999),
    'realName'=>'王麻子',
    'certNo'=>'500100198301253212'
  ]
);

$result = $RealName->run();


use Yjpay\Yht\Payment\AggregatePay;

$guoNeiDeveloperInfo = [
  # 开发者ID
  'partnerId'=>'2016061*********8575',
  # 开发者密钥
  'secretKey'=>'6592639b*********8c2bd2500778c45',
  # 开启调试模式
  'debug'=>true,
  # 日志记录地址,默认为'/logs/',linux系统请先创建你的目录并保证目录有读写全下
  'logPath'=>'/logs/'
];

// $AggregatePay = new AggregatePay(array $DeveloperInfo ,array $parameter [, string $payType]);

// array $DeveloperInfo : [ 'partnerId','secretKey','debug' ] 开发者信息
// array $parameter : 参数
// string $payType : PC , Mobile , MobileWechat 支付终端


$AggregatePay = new AggregatePay($guoNeiDeveloperInfo,[
  'merchOrderNo'=>date('YmdHis').mt_rand(1111,9999),
  // 通常 sellerUserId 和 partnerId是相等的
  'sellerUserId'=>$guoNeiDeveloperInfo['partnerId'],
  ...
  ],
  'PC'
  );

  $result = $AggregatePay->run();

// $FastPayTradeMergePay = new FastPayTradeMergePay(array $DeveloperInfo ,array $parameter [, string $payType]);

// array $DeveloperInfo : [ 'partnerId','secretKey','debug' ] 开发者信息
// array $parameter : 参数
// string $payType : pc , mobile 支付终端

$tradeInfoData = [
  [
    'merchOrderNo'=>date('YmdHis').mt_rand(111111,999999),
    'sellerUserId'=>'20160617020000748575',
    'tradeAmount'=>mt_rand(10,101),
    'currency'=>'CNY',
    'goodsName'=>'test name'
  ],
  [
    'merchOrderNo'=>date('YmdHis').mt_rand(111111,999999),
    'sellerUserId'=>'20160617020000748575',
    'tradeAmount'=>mt_rand(10,101),
    'currency'=>'CNY',
    'goodsName'=>'test name'
  ]
];

$FastPayTradeMergePay = new FastPayTradeMergePay($guoNeiDeveloperInfo,
  [
    'merchOrderNo'=>date('YmdHis').mt_rand(111111,999999),
    'tradeInfo'=>json_encode($tradeInfoData),
    'returnUrl'=>'http://exdomain.com/returnUrl.php',
    'notifyUrl'=>'http://exdomain.com/notifyUrl.php',
    ...
  ]
);

$res = $FastPayTradeMergePay->run();

use Yjpay\Yht\Application\SinglePaymentUpload;

// $SinglePaymentUpload = new SinglePaymentUpload(array $DeveloperInfo ,array $parameter);

// array $developerInfo : [ 'partnerId','secretKey','debug' ] 开发者信息
// array $parameter : 参数

$SinglePaymentUpload = new SinglePaymentUpload($guoNeiDeveloperInfo,[
  'merchOrderNo'=>date('YmdHis').mt_rand(111111,999999),
  ...
  ]);

$result = $SinglePaymentUpload->run();



use Yjpay\Yht\Application\Signature;

$signature = new Signature;
$res = $signature->signature('6592639bb*********c2bd2500778c45',filter_input_array(INPUT_POST));

// $signature->signature(string $secretKey, string $parameter);

// string $secretKey 密钥
// string $parameter 系统通知的数据