PHP code example of ostapovich / radom

1. Go to this page and download the library: Download ostapovich/radom library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ostapovich / radom example snippets


use Ostapovich\Radom;

$apiToken = 'your_api_token';
$prodMode = false; // Set to false for test mode (all cryptocurrencies are displayed in the test mode), true for production mode

$radom = new Radom($apiToken, $prodMode);

$orderNumber = '123';
$amount = 100;
$currency = 'USD';
$successUrl = 'your_successURL';
$cancelUrl = 'cancelUrl';

$paymentLink = $radom->createPaymentLink($orderNumber, $amount, $currency, $successUrl, $cancelUrl);

$paymentMethods = $radom->getPaymentMethods();

use Ostapovich\Radom;

class PaymentController extends Controller
{
    public function createPayment(Request $request)
    {
        $apiToken = env('RADOM_API_TOKEN');
        $prodMode = false;

        $radom = new Radom($apiToken, $prodMode);

        $orderNumber = $request->input('order_number');
        $amount = $request->input('amount');
        $currency = $request->input('currency');
        $successUrl = $request->input('success_url');
        $cancelUrl = $request->input('cancel_url');

        $paymentLink = $radom->createPaymentLink($orderNumber, $amount, $currency, $successUrl, $cancelUrl);

        return redirect($paymentLink['url']);
    }
}

use Ostapovich\Radom;

$apiToken = 'ваш_api_токен';
$prodMode = false; // Встановіть false для тестового режиму (в тестовому режимі виводяться всі криптовалюти), true для режиму продукції

$radom = new Radom($apiToken, $prodMode);

$orderNumber = '123';
$amount = 100;
$currency = 'USD';
$successUrl = 'ваш_успішний_URL';
$cancelUrl = 'ваш_URL_скасування';

$paymentLink = $radom->createPaymentLink($orderNumber, $amount, $currency, $successUrl, $cancelUrl);

$paymentMethods = $radom->getPaymentMethods();

use Ostapovich\Radom;

class PaymentController extends Controller
{
    public function createPayment(Request $request)
    {
        $apiToken = env('RADOM_API_TOKEN');
        $prodMode = false;

        $radom = new Radom($apiToken, $prodMode);

        $orderNumber = $request->input('order_number');
        $amount = $request->input('amount');
        $currency = $request->input('currency');
        $successUrl = $request->input('success_url');
        $cancelUrl = $request->input('cancel_url');

        $paymentLink = $radom->createPaymentLink($orderNumber, $amount, $currency, $successUrl, $cancelUrl);

        return redirect($paymentLink['url']);
    }
}