企业 / 支付SDK
企业支付SDK
1.0
2022-11-25 07:12 UTC
Requires
- php: >=7.0
- ext-ctype: *
- ext-curl: *
- ext-dom: *
- ext-fileinfo: *
- ext-json: *
- ext-mbstring: *
- ext-openssl: *
- guzzlehttp/guzzle: >=6.3
This package is not auto-updated.
Last update: 2024-09-28 15:39:28 UTC
README
欢迎使用企业钱包SDK for PHP。
环境要求
-
企业钱包SDK for PHP 需要 PHP 5.5 以上的开发环境。
-
在使用企业钱包SDK for PHP之前,您需要先联系企业钱包管理员完成接入的一些准备工作,包括创建应用、为应用设置接口相关配置等。
-
准备工作完成后,注意保存如下信息,后续将作为使用SDK的输入。
- 加签模式为公私钥证书模式
AppID
、应用的私钥
、应用公钥
快速使用
- Composer 安装
composer require corporate/paysdk
- 示例代码
<?php require 'vendor/autoload.php'; use Corporate\PaySDK\Base\CorporateClient; use Corporate\PaySDK\Base\Config; //加载配置文件 $corporateClient = new CorporateClient(getOptions()); //付款請求接口 $params = [ "out_trade_no" => "20200326235526001", "public_chain" => "TRON", "digital_coin" => "USDT", "amount" => 1, "protocol" => "TRC-20", "receipt_address" => "TWK3vomsDgKNSwdvezcGGs24jztNjmKK99", "timestamp" => 1666245173, "note" => "test" ]; $result = $corporateClient->execute("/api/wallet/goPay",$params); if($result->isSuccess()){ if($result->verify()){ print_r($result->dataMap()); }else{ throw new \Exception("驗簽失敗,請檢查Corporate應用公鑰或應用私鑰是否配置正確。"); } }else{ throw new \Exception($result->ret() .":".$result->msg()); } //异步回调通知處理示例 $json_string = '{"ret":1000,"msg":"\u8bf7\u6c42\u6210\u529f","data":"WDlwdnBoSkFDeS96bVdIYjg4WUNaaXVuV3NTQ......."}'; $result = $corporateClient->getApiResponse($json_string); if($result->isSuccess()){ if($result->verify()){ print_r($result->dataMap()); }else{ throw new \Exception("驗簽失敗,請檢查Corporate應用公鑰或應用私鑰是否配置正確。"); } } function getOptions() { $options = new Config(); $options->apiUrl = "<-- 請填寫應用分配的接口域名,例如:https://xxx.corporate.com/ -->"; $options->appToken = "<-- 請填寫您的appToken,例如:377b26eb8c25bd... -->"; //語系(參考文檔中最下方語系表,如:TC) $options->lang = "TC"; $options->corporatePrivateCertPath = "<-- 請填寫您的應用私鑰路徑,例如:/foo/MyPrivateKey.pem -->"; $options->corporatePublicCertPath = "<-- 請填寫Corporate應用公鑰證書文件路徑,例如:/foo/CorporatePublicKey.pem -->"; return $options; }