PHP code example of yunzhanghuopen / sdk-php

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

    

yunzhanghuopen / sdk-php example snippets


composer 


   define('TEST_PATH', dirname(__FILE__));
     use Yzh\Config;
   use Yzh\Model\Payment\CreateBankpayOrderRequest;
   use Yzh\PaymentClient;
   
   $config = Config::newFromArray(array(
       'app_dealer_id' => $test_var['app_dealer_id'],
       'app_broker_id' => $test_var['app_broker_id'],
       'app_key' => $test_var['app_key'],
       'app_des3_key' => $test_var['app_des3_key'],
       'app_private_key' => $test_var['app_private_key'],
       'yzh_public_key' => $test_var['yzh_public_key'],
   ));
   
   try {
       $paymentClient = new PaymentClient($config);
       $paymentClient->setEnv(PaymentClient::ENV_PROD);
   } catch (\Exception $e) {
       die($e->getMessage());
   }
   
   // 银行卡实时支付
   $request = new CreateBankpayOrderRequest(array(
       'order_id' => 'bank12345678901111',                
       'dealer_id' => $test_var['app_dealer_id'],        
       'broker_id' => $test_var['app_broker_id'],        
       'real_name' => '张三',                             
       'card_no' => '6228888888888888888',                   
       'id_card' => '11010519491231002X',               
       'phone_no' => '188****8888',                       
       'pay' => '0.1',                                    
       'pay_remark' => '测试订单',                           
       'notify_url' => 'https://www.example.com',   
       'project_id' => ''              
   ));

   /*
    * request-id:请求 ID,请求的唯一标识
    * 建议平台企业自定义 request-id,并记录在日志中,便于问题发现及排查
    * 如未自定义 request-id,将使用 SDK 中的 random 方法自动生成。注意:random 方法生成的 request-id 不能保证全局唯一,推荐自定义 request-id
    */
   // $request->setRequestID("reqtest001");   
   $response = $paymentClient->createBankpayOrder($request);
   var_dump(array('request'=>$request, 'response'=>$response));