PHP code example of capitual / cappay-php-sdk

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

    

capitual / cappay-php-sdk example snippets


$invoice = new \Capitual\CapPay;

$invoice->merchant = 1234;

$invoice->wallet = 'CAP-XXXXXXXX-XXXXXX-XX';

$invoice->currency = 'USD';
$invoice->value = '100.00';

$invoice->payee = '[email protected]';

$invoice->description = 'Payment for order 123'; // optional

$invoice->expires = strtotime("+48 hours"); // optional

$invoice->ipn = 'https://mysite.com/ipn.php'; // optional

$invoice->create();

$invoice_id = $invoice->id;
// proceed to save $invoice_id to the database...

$url = $invoice->url;

// or a short link
$url = $invoice->getShortLink();

$url = $invoice->url.'?return_url=http://yoursite.com/thanks.php';

$invoice = new \Capitual\CapPay('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX');

echo $invoice->currency; // "USD"
echo $invoice->amount; // "100.00"

echo $invoice->status; // "pending", "paid", "canceled" or "expired"

if ($invoice->status === \Capitual\CapPay::STATUS_PENDING) {
	// no payment has been received yet
}
elseif ($invoice->status === \Capitual\CapPay::STATUS_PAID) {
	// paid and confirmed
}
elseif ($invoice->status === \Capitual\CapPay::STATUS_CANCELED) {
	// invoice cancelled by its sender
}
elseif ($invoice->status === \Capitual\CapPay::STATUS_EXPIRED) {
	// due date has passed without payment
}
bash
composer