yenepay / php-client-sdk
PHP版的YenePay客户端SDK
dev-master
2022-07-25 07:03 UTC
Requires
- php: >=7.0
- rmccue/requests: >=1.8.0
This package is auto-updated.
Last update: 2024-09-25 11:28:36 UTC
README
YenePay客户端PHP SDK,让商家能够从其余额中自动发送货币。
安装
步骤1:在您的composer.json文件中包含yenepay/php-client-sdk
{
"require": {
"yenepay/php-client-sdk": "dev-master"
}
}
步骤2:运行composer install --no-dev
以下载并安装yenepay/php-client-sdk的最新版本。这将在vendor文件夹中下载并放置库。
步骤3:打开您的支付处理器PHP类,并导入SDK的辅助类和命名空间。
require_once (__DIR__ . '/../library/YenePayClient.php');
require_once (__DIR__ . '/../library/Models/MoneyRecipient.php');
require_once (__DIR__ . '/../library/Config/YenePaySettings.php');
注意:根据您的目录结构,库目录的路径可能略有不同。
先决条件
创建客户端令牌和签名密钥
如果您还没有创建客户端应用的访问令牌和签名密钥,请转到您的YenePay账户设置页面 https://www.yenepay.com/account/#/settings
然后通过访问商家应用菜单创建一个新的客户端。创建新客户端后,复制并保存该客户端的访问令牌和生成的私钥。
注意:请谨慎存放您的令牌和密钥,因为它们是非常敏感的信息。
发送货币
要发送货币,可以使用以下PHP代码
//Get your access token from the enviroment $token = $_ENV['YenePayToken']; //Get your merchant code from the enviroment $merchantCode = $_ENV['YenePayMerchantCode']; //Get your request signing key from the enviroment $signingKey = $_ENV['YenePaySigningKey']; //Create new setting object $settings = new YenePaySettings($merchantCode, $token, $signingKey); //Create recipients array with customerCode, amount $recipients = array( new MoneyRecipient('9358', 8) ); //Create YenePay client with the setting $client = new YenePayClient($settings); //Create a signed request with message to recipients $request = $client->createSignedRequest('Your bonus money', $recipients); //Send the money $response = $client->sendMoney($request); //Check if payment completed if($response->getIsPaymentCompleted()){ //The payment is completed }
响应对象是SendMoneyResponse.php类的实例
示例
您可以在本存储库的example目录中找到一个工作示例。请查看send_money.php以了解如何发送请求。send.php将详细显示解析请求和响应,以供调试。
更多
更多信息请访问