wegetfinancing / php-sdk
WeGetFinancing PHP SDK 提供了方便的方式,从使用 PHP 语言编写的应用程序中访问 WeGetFinancing API。
4.0.0
2024-02-27 10:25 UTC
Requires
- php: >=8.2
- ext-json: *
- doctrine/annotations: ^1.14.3
- guzzlehttp/guzzle: ^7.0
- symfony/cache: 7.*
- symfony/serializer: 7.*.*
- symfony/validator: 7.0.*
Requires (Dev)
README
PHP-SDK
PHP 的 WeGetFinancing SDK 让开发者可以轻松地在 PHP 代码中访问 WeGetFinancing API,并将我们的支付网关集成到电子商务、CRM、ERP 及任何相关网络应用程序中。您可以通过Composer安装SDK或从我们的最新版本下载单个ZIP文件来开始使用,整个过程只需几分钟。
索引
最低要求
要运行SDK,您的系统需要满足最低要求,即 PHP >= 7.4 并安装 ext-json 扩展。
安装
使用 Composer 是安装 WeGetFinancing PHP-SDK 的推荐方式。SDK 通过 Packagist 提供的 wegetfinancing/php-sdk
包可用。如果Composer已在全球范围内安装,您可以在项目的根目录中运行以下命令来将SDK添加为依赖项
composer require `wegetfinancing/php-sdk`
如何使用
- 需要 composer 自动加载和包。
<?php require 'vendor/autoload.php'; use WeGetFinancing\SDK\Client; use WeGetFinancing\SDK\Entity\Request\AuthRequestEntity; use WeGetFinancing\SDK\Entity\Request\LoanRequestEntity;
- 创建一个 AuthResponseEntity 并使用它来初始化客户端
$auth = AuthRequestEntity::make([ 'username' => '***', 'password' => '***', 'merchantId' => '***', 'url' => 'https://***' ]); $client = Client::Make($auth);
- 创建一个 LoanRequestEntity,有关要使用的参数的更多信息,请参阅官方文档。
$request = LoanRequestEntity::make([ 'first_name' => '***', 'last_name' => '***', 'shipping_amount' => 1.2, 'version' => '1.9', 'email' => '***@example.com', 'phone' => '0123456789', 'merchant_transaction_id' => '***', 'success_url' => 'https://yoururl.com/successurl', // this is facultative 'failure_url' => 'https://yoururl.com/failureurl', // this is facultative 'postback_url' => 'https://yoururl.com/postbackurl', // this is facultative 'billing_address' => [ 'street1' => '***', 'city' => '***', 'state' => '***', 'zipcode' => '***', ], 'shipping_address' => [ 'street1' => '***', 'city' => '***', 'state' => '***', 'zipcode' => '***', ], 'cart_items' => [ [ 'sku' => '***', 'display_name' => '***', 'unit_price' => '***', 'quantity' => ***, 'unit_tax' => **.*, 'category' => '***', // Facultative ] ] ]);
- 使用 LoanRequestEntity 提交申请,并接收包含结果的 LoanResponseEntity。
$response = $client->requestNewLoan($request);