PHP code example of shopia / nowpayments

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

    

shopia / nowpayments example snippets


use App\Models\PaymentSetting;

PaymentSetting::create([
    'sandbox_api_key' => 'your-sandbox-api-key',
    'live_api_key' => 'your-live-api-key',
    'sandbox_mode' => true,
    'default_currency' => 'USD'
]);

use Shopia\Nowpayments\Facades\Nowpayments;

// Create an invoice
$invoice = Nowpayments::createInvoice([
    'price_amount' => 100,
    'price_currency' => 'usd',
    'order_id' => 'ORDER-123',
    'order_description' => 'Test payment',
    'success_url' => 'https://your-site.com/success',
    'cancel_url' => 'https://your-site.com/cancel',
]);
bash
php artisan vendor:publish --provider="Shopia\Nowpayments\NowpaymentsServiceProvider"
bash
php artisan migrate