rocapayofficial / rocapay-php
RocaPay API 的 PHP 客户端库
2.0.0
2020-05-11 10:04 UTC
Requires
- php: >=5.3
- ext-curl: *
- ext-json: *
This package is auto-updated.
Last update: 2024-09-27 19:34:16 UTC
README
此客户端库提供了一种与RocaPay API通信的简单方式。
安装
Composer
要通过 Composer 获取客户端的最新版本,请运行以下命令:
composer require rocapayofficial/rocapay-php
直接下载
您也可以将客户端作为ZIP 文件下载,并将其提取到您的项目中。
不使用自动加载器的客户端使用示例
<?php require_once 'YOUR_PATH/rocapay-php/Rocapay.php'; $rocapay = new \Rocapay\Rocapay($apiKey);
客户端中的所有文件都符合PSR-4规范,并可以使用您自己的自动加载器使用。
配置
首先,您需要注册一个RocaPay账号。
然后,您需要创建一个小部件并使用实现选项卡下提供的 API 密钥。
用法
创建支付的示例
<?php $rocapay = new \Rocapay\Rocapay($apiKey); $params = array( 'amount' => '12.00', // Amount of the payment 'fiatCurrency' => 'USD', // Symbol used to specify the fiat currency (ISO 4217) 'callbackUrl' => 'https://yoursite.com/callback-url', // URL on which JSON notifications will be received about the payment (Optional if a global one is set from the user dashboard) 'description' => 'Order #0291092', // Description of the payment (Optional) 'cryptoCurrency' => 'BTC', // Symbol used to specify the crypto currency (Optional) 'convertToCurrency' => 'EUR', // Symbol used to specify the currency to which the crypto currency will be converted to. A list of supported convertable currency pairs can be obtained through the `getAutoConvertCurrencyPairs` method (Optional) 'successUrl' => 'https://yoursite.com/success-url', // Redirect URL after a successful payment in the widget (Optional if a global one is set from the user dashboard) 'failUrl' => 'https://yoursite.com/fail-url', // Redirect URL after a failed payment in the widget (Optional if a global one is set from the user dashboard) 'cancelUrl' => 'https://yoursite.com/cancel-url', // Redirect URL after clicking the Return to Merchant button in the widget (Optional if a global one is set from the user dashboard) ); $payment = $rocapay->createPayment($params);
可用方法
getCryptoCurrencies()
:获取支持加密货币的列表。getFiatCurrencies()
:获取支持法定货币的列表。getAutoConvertCurrencyPairs()
:获取支持自动转换货币对的列表。createPayment($params)
:创建支付。checkPayment($paymentId)
:获取支付的状态。