relaypay-official / merchant-php-client
1.0.3
2023-12-11 10:58 UTC
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ~1.12
- phpunit/phpunit: ^4.8
- squizlabs/php_codesniffer: ~2.6
README
Relay Pay API 文档。使用 api.sandbox.relaypay.io
进行沙箱环境测试,使用 api.relaypay.io
进行生产环境测试。一些有用的链接:- 官方文档
此 PHP 包是由 Swagger Codegen 项目自动生成的
- API 版本:0.0.2
- 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen
要求
PHP 5.5 及以上版本
安装与使用
Composer
要通过 Composer 安装绑定,请将以下内容添加到 composer.json
{
"repositories": [
{
"type": "git",
"url": "https://github.com/relaypay-public/merchant-php-client.git"
}
],
"require": {
"relaypay-public/merchant-php-client": "*@dev"
}
}
然后运行 composer install
手动安装
下载文件并包含 autoload.php
require_once('/path/to/./vendor/autoload.php');
测试
要运行单元测试
composer install
./vendor/bin/phpunit
入门指南
请按照 安装过程 进行操作,然后运行以下命令
<?php require_once(__DIR__ . '/vendor/autoload.php'); // Configure API key authorization: authorization $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer'); $apiInstance = new RelayPay\Api\ECommerceApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $merchant_id = "merchant_id_example"; // string | merchantID obtained from Relaypay $order_id = "order_id_example"; // string | Your unique reference for this payment. i.e. id of the current shopping cart try { $result = $apiInstance->getMerchantTransaction($merchant_id, $order_id); print_r($result); } catch (Exception $e) { echo 'Exception when calling ECommerceApi->getMerchantTransaction: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: authorization $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'Bearer'); $apiInstance = new RelayPay\Api\ECommerceApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $merchant_id = "merchant_id_example"; // string | merchantID obtained from Relaypay $page = 56; // int | Starts from 0 $size = 56; // int | how many records to be returned try { $result = $apiInstance->getMerchantTxs($merchant_id, $page, $size); print_r($result); } catch (Exception $e) { echo 'Exception when calling ECommerceApi->getMerchantTxs: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: sign $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKey('Sign', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Sign', 'Bearer'); $apiInstance = new RelayPay\Api\ECommerceApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = new \RelayPay\Model\EcommerceIncomingRequest(); // \RelayPay\Model\EcommerceIncomingRequest | try { $result = $apiInstance->setEcommerceRequest($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling ECommerceApi->setEcommerceRequest: ', $e->getMessage(), PHP_EOL; } // Configure API key authorization: sign $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKey('Sign', 'YOUR_API_KEY'); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed // $config = RelayPay\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Sign', 'Bearer'); $apiInstance = new RelayPay\Api\ECommerceApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. new GuzzleHttp\Client(), $config ); $body = new \RelayPay\Model\MerchantSalesforcePlugin(); // \RelayPay\Model\MerchantSalesforcePlugin | try { $apiInstance->setEcommerceSalesforce($body); } catch (Exception $e) { echo 'Exception when calling ECommerceApi->setEcommerceSalesforce: ', $e->getMessage(), PHP_EOL; } ?>
API 端点文档
所有 URI 都是相对于 https://{environment}.relaypay.io
模型文档
- EcommerceIncomingRequest
- EcommerceMerchantTransaction
- EcommerceResponse
- MerchantSalesforcePlugin
- PageEcommerceMerchantTransaction
- Pageable
- Sort
授权文档
authorization
- 类型: API 密钥
- API 密钥参数名: Authorization
- 位置: HTTP 头部
sign
- 类型: API 密钥
- API 密钥参数名: Sign
- 位置: HTTP 头部