PHP code example of xpayr / xpayr-php

1. Go to this page and download the library: Download xpayr/xpayr-php 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/ */

    

xpayr / xpayr-php example snippets




use XPayr\Webhook;
use XPayr\XPayrClient;

$xpayr = new XPayrClient($_ENV['XPAYR_SECRET_KEY']);
$session = $xpayr->createPayment([
    'amount' => '49.90',
    'currency' => 'USDC',
    'network' => 'bsc-testnet',
    'order_id' => 'ORDER-1001',
]);

// In the webhook route, verify the untouched request body.
$event = Webhook::constructEvent(
    file_get_contents('php://input'),
    $_SERVER['HTTP_X_XPAYR_SIGNATURE'] ?? '',
    $_ENV['XPAYR_WEBHOOK_SECRET'],
);
bash
composer