PHP code example of sadi01 / yii2-post-ecommerce

1. Go to this page and download the library: Download sadi01/yii2-post-ecommerce 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/ */

    

sadi01 / yii2-post-ecommerce example snippets


return [
    //....
    'components' => [
        'PostEcommerce' => [
            'class' => 'sadi01\postecommerce\components\PostService',
            'username' => 'your username',
            'password' => 'your password',
            'secretKey' => 'your secretKey',
        ],
    ]
];

return [
    //....
    'components' => [
        'PostEcommerce' => [
            'class' => 'sadi01\postecommerce\components\PostServiceRest',
            'oauth_client' => 'Your oauth2 client ID',
            'oauth_user' => 123 // User ID
        ],
    ]
];

use sadi01\postecommerce\components\PostService;
use sadi01\postecommerce\components\Shop;

$shop = new Shop([
'city_id' => 752,
'username' => 'test',
'name' => 'test',
'phone' => '0213410002',
'mobile' => '09379373737',
'email' => '[email protected]',
'postal_code' => '7612458965',
'website_url' => 'https://test.test',
'manager_name' => 'test',
'manager_family' => 'test',
'manager_birth_date' => '1368/01/01',
'manager_national_id' => '2982561020',
'manager_national_id_serial' => '12G526713',
'start_date' => '1401/03/16',
'end_date' => '1402/03/16',
'need_to_collect' => 1,
]);

/** @var $postService PostService */
$postService = Yii::$app->PostEcommerce;
$postService->createShop($shop);

use sadi01\postecommerce\components\PostService;
use sadi01\postecommerce\components\Shop;

$price = new Price([
    'shop_id' => 565656,
    'weight' => 1000,
    'service_type' => 1,
    'destination_city_id' => 1,
    'value' => 2000000,
    'payment_type' => 88,
    'non_standard_package' => 0,
    'sms_service' => 0,
]);
$packet = new Packet([
    'price' => $price,
    'order_id' => '1234',
    'customer_nid' => '1233456789',
    'customer_name' => 'test',
    'customer_family' => 'test',
    'customer_mobile' => '09379373737',
    'customer_email' => '[email protected]',
    'customer_postal_code' => '7894561230',
    'customer_address' => 'test',
    'content' => 'test',
]);

/** @var $postService PostService */
$postService = Yii::$app->PostEcommerce;
$postService->createPacket($packet);

use sadi01\postecommerce\components\PostService;

/** @var $postService PostService */
$postService = Yii::$app->PostEcommerce;
$postService->barcodeInfo("683690107800039750895121");