sadi01 / yii2-post-ecommerce
Electronic Commerce Service of National Iranian Post Company For Yii2 Framework
Installs: 102
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- ext-curl: *
- ext-json: *
- filsh/yii2-oauth2-server: ^2.0
- yiisoft/yii2: ~2.0.14
- yiisoft/yii2-httpclient: ~2.0.0
README
Electronic Commerce Service of National Iranian Post Company for Yii 2
This extension provides the Post E-Commerce Service integration for the Yii framework 2.0.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer:
composer require --prefer-dist sadi01/yii2-post-ecommerce:"*"
Configuration
To use this extension, you have to configure the PostService class in your application configuration:
return [ //.... 'components' => [ 'PostEcommerce' => [ 'class' => 'sadi01\postecommerce\components\PostService', 'username' => 'your username', 'password' => 'your password', 'secretKey' => 'your secretKey', ], ] ];
To use this extension by Rest Api version, you have to configure the PostService class in your application configuration as below:
return [ //.... 'components' => [ 'PostEcommerce' => [ 'class' => 'sadi01\postecommerce\components\PostServiceRest', 'oauth_client' => 'Your oauth2 client ID', 'oauth_user' => 123 // User ID ], ] ];
How To Use
Create shop:
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' => 'test@test.test', '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);
Create barcode:
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' => 'test@test.test', 'customer_postal_code' => '7894561230', 'customer_address' => 'test', 'content' => 'test', ]); /** @var $postService PostService */ $postService = Yii::$app->PostEcommerce; $postService->createPacket($packet);
Tracking barcode:
use sadi01\postecommerce\components\PostService; /** @var $postService PostService */ $postService = Yii::$app->PostEcommerce; $postService->barcodeInfo("683690107800039750895121");