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}");

// store the index and the current height on the order, then render $uri as a QR
$order->update(['xmr_index' => $index, 'xmr_from' => XmrPay::tipHeight()]);

// 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);
// $r['found'], $r['commitment_ok'], $r['confirmations'], $r['amount_atomic']