PHP code example of piteurstudio / satim-php

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

    

piteurstudio / satim-php example snippets


use PiteurStudio\Satim;

$satim = new Satim([
    'username' => env('SATIM_USERNAME'),
    'password' => env('SATIM_PASSWORD'),
    'terminal_id' => env('SATIM_TERMINAL_ID'),
]);

$payment = $satim
        ->amount(1000) /* Set payment amount in DZD dinars*/
        ->description('Product purchase') /* Optional: Add a description*/
        ->returnUrl('https://example.com/success')
        ->failUrl('https://example.com/fail') // Optional: Specify a different fail URL
        ->orderNumber(1234567890) // Optional: Use custom order number
        ->testMode(true) // Optional: Enable test mode
        ->language('AR') // Optional: Set payment page language (EN, AR, FR - default is FR)
        ->timeout(600) // Optional: Set payment timeout in seconds
        ->userDefinedFields([
           'customer_id' => '12345',
           'order_type' => 'premium'
       ]) // Optional: Add custom user-defined fields
        ->register();

// Retrieve payment information
$paymentDetails = $payment->getResponse();
$orderId = $payment->getOrderId();
$paymentUrl = $payment->getUrl();

// Redirect user to payment page
$payment->redirect();

$orderConfirmation = $satim->confirm($orderId);

// Retrieve payment status
$orderConfirmation->getResponse();

if ($orderConfirmation->isSuccessful()) {

    echo 'Payment was successful : '.$orderConfirmation->getSuccessMessage();
    
} else {
    // Payment was not successful
    echo 'Payment was not successful' : $orderConfirmation->getErrorMessage();
    
}

$refundOrder = $satim->refund($orderId);

$refundOrder->getResponse();

$orderStatus = $satim->status($orderId);

$orderStatus->getResponse();
bash
composer