rocapayofficial / rocapay-php
PHP client library for the RocaPay API
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-04-27 18:40:14 UTC
README
This client library provides an easy way to communicate with the RocaPay API.
Installation
Composer
To get the latest version of the client through Composer, run the command:
composer require rocapayofficial/rocapay-php
Direct Download
You can also download the client as a ZIP File and extract it into your project.
Example of using the client without an autoloader
<?php require_once 'YOUR_PATH/rocapay-php/Rocapay.php'; $rocapay = new \Rocapay\Rocapay($apiKey);
All the files in the client are PSR-4 compliant and can be used with your own autoloader.
Configuration
First you have to sign up for a RocaPay account.
Then you have to create a widget and use the API key provided under the implementation tab.
Usage
Example of creating a payment
<?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);
Available methods
getCryptoCurrencies()
: Gets a list of supported crypto currencies.getFiatCurrencies()
: Gets a list of supported fiat currencies.getAutoConvertCurrencyPairs()
: Gets a list of supported auto convert currency pairs.createPayment($params)
: Creates a payment.checkPayment($paymentId)
: Fetches a payment's status.