surajitbasak109 / tciexp-api
TCI Express/ECOM 基于SOAP的API客户端
dev-main
2021-03-24 11:03 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- orchestra/testbench: ^3.6
- phpunit/phpunit: ^7.5|^9.0
- psalm/plugin-laravel: ^1.2
- vimeo/psalm: ^3.11
This package is auto-updated.
Last update: 2024-09-24 18:24:53 UTC
README
需求
- PHP 7.2 或更高版本
- php-soap
- php-json
- php-dom
安装
您可以通过Composer安装此包
composer require surajitbasak109/tciexp-api
您可以使用以下命令发布配置文件
php artisan vendor:publish --provider="surajitbasak109\tciexp\TciExpServiceProvider" --tag="config"
这是已发布配置文件的内容
<?php return [ /* |-------------------------------------------------------------------------- | Default TciExpApi Credentilas |-------------------------------------------------------------------------- | | Here you can set the default TciExpApi credentilas. However, you can pass the credentials while connecting to TciExpApi client | */ 'dev_wsdl' => env('TCI_EXPRESS_DEV_URL', 'https://customerapitesting.tciexpress.in/ServiceEnquire.asmx?WSDL'), 'prod_wsdl' => env('TCI_EXPRESS_PROD_URL', 'https://customerapi.tciexpress.in/ServiceEnquire.asmx?WSDL'), 'credentials' => [ 'username' => env('TCI_EXPRESS_USERNAME', 'username'), 'password' => env('TCI_EXPRESS_PASSWORD', 'secret') ] ];
请将此类路径添加到 config/app.php
文件的 service provider 下方
'providers' => [ ... surajitbasak109\TciExpApi\TciExpServiceProvider::class ];
API集成流程
创建令牌
从以下示例中,您可以为创建新的托运单生成令牌。您可以在Laravel项目中创建一个辅助函数来缩短此代码。
if (session('tci_token')) { $token = session('tci_token'); } else { $token = TciExp::getToken(); // Use API to generate token session('tci_token', $token); }
创建托运单(TCI-Ecom)
以下是如何创建托运单的示例代码
$consignment = new stdClass(); $consignment->barcodes = [ "Barcodes" => ["barcode" => 2378529716], "Barcodes" => ["barcode" => 2378529731], ]; $consignment->CustomerOrderNumber = "211115"; $consignment->OrderReferenceNumber = "211115"; $consignment->BranchCode = ""; $consignment->CustomerCode = ""; $consignment->AWBNumber = "5006600060"; $consignment->AWBDate = "03-11-2017 16:02:54"; $consignment->PlantCode = "A001"; $consignment->PaymentMode = "COD"; $consignment->TotalAmount = 1000; $consignment->PayableAmount = 1000; $consignment->Invoices = [ "InvoiceDetail" => [ "invoiceDate" => "14-07-2017 12:00:00", "invoiceNo" => "5", "invoiceValue" => 1000.00, "numberOfBoxes" => 3, "remarks" => "This is a test consignment" ] ]; $consignment->Volumes = [ "VolumeDetail" => [ "breadth" => 8, "height" => 1, "length" => 2, "numberOfBoxes" => 1, "volume" => 6 ], "VolumeDetail" => [ "breadth" => 34, "height" => 65, "length" => 45, "numberOfBoxes" => 2, "volume" => 60 ] ]; $consignment->CustomerFirstName = "MR K. Ramchandran"; $consignment->CustomerLastName = ""; $consignment->CustomerAddress1 = "House No 435, Sec - 15 , Noida"; $consignment->CustomerAddress2 = ""; $consignment->CustomerCity = "DELHI"; $consignment->CustomerState = "DELHI"; $consignment->CustomerCountry = "IN"; $consignment->CustomerPinCode = "110022"; $consignment->CustomerPhoneNumber = "5005734764"; $consignment->CustomerMobileNumber = "5005734764"; $consignment->CustomerMaskMobileNumber = "7583921266"; $consignment->CustomerEmail = "kunalpramanik3@gmail.com"; $consignment->ShipperCode = "0000W8"; $consignment->ShipperName = "Web World"; $consignment->ShipperAddress1 = "Rajokri Village. New Delhi 110038"; $consignment->ShipperAddress2 = ""; $consignment->ShipperCity = "NEW DELHI"; $consignment->ShipperState = "DELHI"; $consignment->ShipperCountry = "IN"; $consignment->ShipperPinCode = "110038"; $consignment->ShipperPhoneNo = "9873516148"; $consignment->ShipperMobileNo = "9873516148"; $consignment->ShipperEmail = ""; $consignment->ReturnToName = "Web World"; $consignment->ReturnToAddress1 = "Rajokri Village. New Delhi 110038"; $consignment->ReturnToAddress2 = ""; $consignment->ReturnToCity = "NEW DELHI"; $consignment->ReturnToState = "DELHI"; $consignment->ReturnToCountry = "IN"; $consignment->ReturnToPinCode = "110038"; $consignment->ReturnToPhoneNo = "9543516148"; $consignment->ReturnToMobileNo = "9543516148"; $consignment->ReturnToEmail = ""; $consignment->TotalPices = 3; $consignment->ProductWeight = 35; $consignment->VolumetricWeight = "36"; $consignment->VolumetricWeight = "36"; $consignment->ProductCategory = "Fashion"; $consignment->ProductCode = "265478957"; $consignment->ProductDescription = "Product Description goes here"; $consignment->TransportMode = "SURFACE"; $consignment->B2BFlag = "N"; $consignmentData = ['consignment' => $consignment]; $response = TciExp::consignment($token)->createConsignmentEcom($consignmentData);
如果托运单成功,它将返回一个对象作为响应
{ "AWBNumber": "246149120", "error": "SUCCESS", "errorMessage": "Consignment Created Successfully." }
跟踪信息
此服务允许您根据托运单号获取预订、在途中和交付/退货信息。
$consignmentNo = "246149120"; $response = TciExp::consignment()->getConsignmentResponseMessage($consignmentNo);
运费计算
参数详情
此方法可用于估算两个不同地点(邮编)之间的运费以及携带的重量。
$response = TciExp::service()->getShippingCostForProductAndServiceMode( "700055", "734006", "SURFACE", 1000, 9000, 1000, "N", 0.00 );
计算转运时间
此方法可用于根据两个不同的地点估算转运时间。
$response = TciExp::service()->getDomesticTransitTimeForPinCodeAndServiceMode( "700055", "734006", "SURFACE", "16/03/2021", "10:00" );
通过邮编检查服务可用性
使用此服务调用,您可以检查TCI Express是否在此地区提供服务。
$response = TciExp::service()->getPincodeServiceableStatus("734006");
响应
{ "Value": "734006", "Status": "SERVICEABLE", "Type": "", "DestinationCode": "XSLG", "DestinationCity": "SILIGURI", "DestinationGSTIN": "19AADCT0663J1Z5" }