PHP code example of paylinksa / php

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

    

paylinksa / php example snippets


use Paylink\Paylink;

$paylink = Paylink::test();

use Paylink\Paylink;

$paylink = Paylink::production('API_ID_xxxxxxxxxx', 'SECRET_KEY_xxxxxxxxxx');

      use Paylink\Models\PaylinkProduct;

      $invoiceDetails = $paylink->addInvoice(
         amount: 250.0,
         clientMobile: '0512345678',
         clientName: 'Mohammed Ali',
         orderNumber: '123456789',
         products: [
            new PaylinkProduct(title: 'item1', price: 5.0, qty: 10),
            new PaylinkProduct(title: 'item2', price: 20.0, qty: 10)
         ],
         callBackUrl: 'https://example.com',
      );
   

      $invoiceDetails = $paylink->getInvoice(transactionNo: '1714289084591');

      // $invoiceDetails->orderStatus;
      // $invoiceDetails->transactionNo;
      // $invoiceDetails->url;
      // ...
   

      $paylink->cancelInvoice(transactionNo: '1714289084591'); // true-false
   
bash
composer