1. Go to this page and download the library: Download coinpay/laravel-integration 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/ */
coinpay / laravel-integration example snippets
use Coinpay\Finance\Services\CoinPay\CoinPayPaymentRequest;
use Coinpay\Finance\Facades\CoinPay;
use Coinpay\Finance\Exceptions\CoinPayException;
$paymentRequest = new CoinPayPaymentRequest(
amount: 100000, // Amount in smallest currency unit
clientRefId: 'INV12345', // Unique reference ID
payerIdentity: '[email protected]', // Payer identity (email/phone)
name: 'John Doe', // Payer name
description: 'Invoice Payment', // Payment description
nationalCode: '1234567890' // National code of payer
);
try {
$response = CoinPay::createPayment($paymentRequest);
$url = $response->url;
// Optionally store $response->transactionId in your database
} catch (CoinPayException $e) {
// $e->getMessage() / $e->getCode() as usual, plus extra context:
$e->getData(); // raw context array (e.g. ['message' => ..., 'code' => ...])
$e->getHttpStatusCode(); // HTTP status returned by the CoinPay API, if known
}