PHP code example of applab / sadad

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

    

applab / sadad example snippets


  $webCheckoutOneReq = new WCORequest();     
  $webCheckoutOneReq->total_amount=100;
  $webCheckoutOneReq->order_id = $webCheckoutReq->getOrderId();
  $webCheckoutOneReq->customer_mobile = "974XXXXXXXX";
  $webCheckoutOneReq->callback_url = url('sadad-purchased/'.$webCheckoutReq->order_id);      
  $products[] = [
    'id' => 123,
    'title' => "product name",
    'quantity' => 1,
    'amount' => 1,
    'type' => 'line_item'
  ];
  $webCheckoutOneReq->setProducts($products);
  return Sadad::webCheckoutOne($webCheckoutOneReq); //default view

  $filters = [];
  Sadad::getTransactions($filter)

  Sadad::getTransaction('SD33XXXXXXXXXX8')

  Sadad::refundTransaction('SD33XXXXXXXXXX8')

  $filters = [];
  Sadad::getInvoices($filter)

  $invoiceData = new InvoiceRequest();
  $invoiceData->countryCode = '974';
  $invoiceData->cellnumber = '66XXXXXX';
  $invoiceData->clientname = 'Client name';
  // Status for Invoice
  // 1 - Draft, 2 - Unpaid, 3 - Paid, 4 - Overdue, 5 - Cancelled
  $invoiceData->status = 2;
  $invoiceData->remarks = 'Invoice test remarks';
  $invoiceData->amount = 100; // Total amount in QR

  // Invoice can have many item
  $invoice_details[] = [
      'description' => 'Testing 123',
      'quantity' => 1,
      'amount' => 100, // Amount for each item
  ];
  $invoiceData->setInvoiceDetails($invoice_details);
  $payload = $invoiceData->preparePayload()->getPayload();

  return Sadad::createInvoice($payload);

  // Share using mobile
  $payload = [
    'sentvia' => 4,
    'invoicenumber' => 'SD66XXXXXXXXX8',
    'receivercellno' => '66XXXXXX',
  ];
  // Share using email
  $payload = [
    'sentvia' => 3,
    'invoicenumber' => 'SD66XXXXXXXXX8',
    'receiverEmail' => '[email protected]',
  ];

  return Sadad::shareInvoice($payload); 
bash
php artisan vendor:publish --provider="Applab\Sadad\SadadServiceProvider"