PHP code example of slowbeardigger / xmr-pay-laravel

1. Go to this page and download the library: Download slowbeardigger/xmr-pay-laravel 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/ */

    

slowbeardigger / xmr-pay-laravel example snippets


use XmrPay\Laravel\Facades\XmrPay;

// when an order is created: derive its own subaddress from your address + view key
$index   = $order->id;                                  // any unique integer per order
$address = XmrPay::subaddressFor($index);
$uri     = XmrPay::paymentUri($address, '0.25', "Order #{$order->id}");

// Do not present a payable order until its birthday height is known and stored.
$height = XmrPay::tipHeight();
if ($height === null) {
    throw new \RuntimeException('Payment node unavailable');
}
$order->update(['xmr_index' => $index, 'xmr_from' => $height]);

// later: in a scheduled command, a queued job, or a poll route: ask if it is paid
$r = XmrPay::checkOrder($order->xmr_index, '0.25', $order->xmr_from);
if (! empty($r['paid'])) {
    $order->markPaid();   // funds are already in your wallet
}

$r = XmrPay::verifyPayment($txid, $address);
// Evidence only: compare amount and enforce confirmations, locks and replay protection.
// A found transaction alone does not authorize fulfillment.
sh
XMRPAY_LARAVEL_APP=/path/to/app php tests/framework.test.php