PHP code example of hasan-22 / tapin

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

    

hasan-22 / tapin example snippets


use Tapin\Tapin;

$authKey = "jwt ***********************************************";
$shopId = "********-****-****-****-***********";

Tapin::setAuthKey($authKey);
$response = Tapin::shopInfo($shopId);
var_dump($response);

$count = 5;
$page = 1;
$response = \Tapin\Tapin::getProvinces($count, $page); 

$count = 5;
$page = 1;
$response = \Tapin\Tapin::getCities($count, $page); 

$response = \Tapin\Tapin::getProvinceAndCity(); 

$response = \Tapin\Tapin::shopList(); 

$count = 5;
$page = 1;
$response = \Tapin\Tapin::shopList($count, $page); 

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";

$response = \Tapin\Tapin::kioskList($shopId, 1, 1);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";

$response = \Tapin\Tapin::shopInfo($shopId);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";

$response = \Tapin\Tapin::shopValidity($shopId);

$count = 10;
$page = 1;
$response = \Tapin\Tapin::categories($count, $page);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$count = 10;
$page = 1;
$response = \Tapin\Tapin::products($shopId, $count, $page);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$title = "My first product";
$price = 250000; // It should be 'rial'
$weight = 500; // It should be 'gram'
$categoryId = "3d65e6eb-ca0d-47b3-9934-6295a355872f";
$description = ''; // It is not 

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$productId = 322;
$title = "update...";
$price = 200000; // It should be 'rial'
$weight = 550; // It should be 'gram'
$categoryId = "3d65e6eb-ca0d-47b3-9934-6295a355872f";
$description = ''; // It is not 

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$productId = 322;
$response = \Tapin\Tapin::deleteProduct($shopId, $productId);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
// نمونه محصولات (دقت کنید این لیست آرایه از آرایه ها میباشد)
$products = [
    [
        "count" => 1,
        "discount" => 0,
        "price" => 5000, // It should be `rial`
        "title" => "my product title",
        "weight" =>500, // It should be `grams` not `kilograms`
        "product_id" => null
    ]
];
$address = "تهیران ...";
$provinceCode = 1;
$cityCode = 1; 
$employeeCode='-1';
$firstName='Hasan';
$lastName="Bahrami";
$mobile="09168963472";
$postalCode="1111111111";
$payType=1;
$orderType=1;
$packageWeight=900; // It should be `grams` not `kilograms`
// This is optional
$kiosk=[
    "kiosk_id"=>101,
    "height"=>101,
    "width"=>101,
    "length"=>101,
    "turning"=>true
];
// This is optional
$email="[email protected]";
// This is optional
$phone="02111111111";
// This is optional
$description="سفارش شکستنی است لطفا در ارسال آن بیشتر دقت کنید";

$response = \Tapin\Tapin::priceInquiry($shopId, $products, $address, $provinceCode, $cityCode, $employeeCode, $firstName, $lastName, $mobile, $postalCode, $payType, $orderType, $packageWeight, $kiosk, $email, $phone, $description);


$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
// نمونه محصولات (دقت کنید این لیست آرایه از آرایه ها میباشد)
$products = [
    [
        "count" => 1,
        "discount" => 0,
        "price" => 5000, // It should be `rial`
        "title" => "my product title",
        "weight" =>500, // It should be `grams` not `kilograms`
        "product_id" => null // This must be null
    ]
];
$address = "تهیران ...";
$provinceCode = 1;
$cityCode = 1; 
$firstName='Hasan';
$lastName="Bahrami";
$mobile="09168963472";
$postalCode="1111111111";
$payType=1;
$orderType=1;
$packageWeight=900; // It should be `grams` not `kilograms`
$presenterCode=999;
$manualId=1;
$contentType=1;
// It is set to `0` by default
$registerType=0;
// It is set to `-1` by default
$employeeCode='-1';
// This is optional
$kiosk=[
    "kiosk_id"=>101,
    "height"=>101,
    "width"=>101,
    "length"=>101,
    "turning"=>true
];
// This is optional
$insuranceId=null,
// This is optional
$email="[email protected]";
// This is optional
$phone="02111111111";
// This is optional
$description="سفارش شکستنی است لطفا در ارسال آن بیشتر دقت کنید";

$response = \Tapin\Tapin::createOrder(
    $shopId,
    $products,
    $address,
    $provinceCode,
    $cityCode,
    $firstName,
    $lastName,
    $mobile,
    $postalCode,
    $payType,
    $orderType,
    $packageWeight,
    $presenterCode,
    $manualId,
    $contentType,
    $registerType,
    $employeeCode,
    $kiosk,
    $insuranceId,
    $email,
    $phone,
    $description
);


$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$orders = [
    [
        "address"=> "tehran-...",
        "city_code"=> "1",
        "province_code"=> "1",
        "first_name"=> "hasan",
        "last_name"=> "bahrami",
        "mobile"=> "09168963472",
        "postal_code"=> "1313131313",
        "pay_type"=> "1",
        "order_type"=> "1",
        "package_weight"=> 10,
        "presenter_code"=>999,
        "content_type"=>1,
        "register_type"=> 0, // It is set to `0` by default
        "employee_code"=> "-1", // It is set to `-1` by default
        "insurance_id"=>null, // This is optional
        "description"=> null, // This is optional
        "email"=> null, // This is optional
        "phone"=> null, // This is optional
        // Products must be an array of arrays
        "products"=> [
            [
                "count"=> 1,
                "discount"=> 0,
                "price"=> 5000,
                "title"=> "my product title",
                "weight"=> 500,
                "product_id"=> null // This must be null
            ]
        ]

    ]
];
$response = \Tapin\Tapin::createBatchOfOrders($shopId, $orders);

$response = \Tapin\Tapin::insuranceAmounts();

$shopId= "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$orderId = 165;
$status = 1
$response = \Tapin\Tapin::changeOrderStatus($shopId, $orderId, $status);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$orders = [
    [
        // این باید آیدی سفارش باشد 
        "id"=>"d95d0f45-6162-4ec3-bd29-09452c148b40" 
    ],
    [
        // این باید آیدی سفارش باشد 
        "id"=>"d95d0f46-6162-4ec3-bd29-09452c148b46" 
    ]
]
$status = 80;
$response = \Tapin\Tapin::changeBatchOfOrderStatus($shopId, $orders, $status);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$count = 10;
$page = 1;
$response = \Tapin\Tapin::orders($shopId, $count, $page);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$orderId = 10;
$response = \Tapin\Tapin::orderDetail($shopId, $orderId);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$price = 500000;
$callback="https://domain.com/callback";
$response = \Tapin\Tapin::paymentLink($shopId, $price, $callback);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$count = 10;
$page = 1;
$response = \Tapin\Tapin::transactions($shopId, $count, $page);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$date = "1402-12-07";
$count = 10;
$page = 1;
$response = \Tapin\Tapin::getOrderStatusByDate($shopId, $date, $count, $page);

$shopId = "fc45949a-921d-4b4f-1ade-ab5180f7dcve";
$fromDate = "2024-02-20";
$toDate = "2024-02-25";
$count = 10;
$page = 1;
$response = \Tapin\Tapin::getOrderStatusBetweenDate($shopId, $fromDate, $toDate, $count, $page);