xenon / multicourier
该软件包已被废弃,不再维护。未建议替代软件包。
这是一个用于与快递服务如e-courier、pathao、paperfly等进行交互的快递API端点库。
v1.0.3
2022-06-14 19:47 UTC
Requires
- guzzlehttp/guzzle: ^6.3|^7.3
README
这是一个用于与快递服务如e-courier等进行交互的快递API端点库。
安装
步骤 1
composer require xenon/multicourier
步骤 2
然后,发布软件包
php artisan vendor:publish --provider=Xenon\MultiCourier\MultiCourierServiceProvider
步骤 3
为单个快递服务设置 .env 配置
PATHAO_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
PATHAO_USERNAME="xxxx@example.com"
PATHAO_PASSWORD="xxxxxx"
PATHAO_GRANT_TYPE="password"
ECOURIER_API_KEY='xxx'
ECOURIER_API_SECRET='xxx'
ECOURIER_USER_ID='xxxx'
ECOURIER_ENVIRONMENT='xxxx'
否则,如果您想有更多控制权,您可以使用底层发送对象。这将不会触及任何laravel门面或服务提供者。
请求E-courier的示例代码
use Xenon\MultiCourier\Provider\ECourier; use Xenon\MultiCourier\Courier; $courier = Courier::getInstance(); $courier->setProvider(ECourier::class, 'local'); /* local/production */ $courier->setConfig([ 'API-KEY' => 'xxx', 'API-SECRET' => 'xxxx', 'USER-ID' => 'xxxx', ]); $courier->setParams(['city'=>'Dhaka']); $thanas = $courier->getThanas(); //get thana $cities = $courier->getCities(); //get city
//place order use Xenon\MultiCourier\Provider\ECourier; use Xenon\MultiCourier\Courier; $courier = Courier::getInstance(); $courier->setProvider(ECourier::class, 'local'); /* local/production */ $courier->setConfig([ 'API-KEY' => 'xxx', 'API-SECRET' => 'xxx', 'USER-ID' => 'xxx', ]); $orderData = array( 'recipient_name' => 'XXXXX', 'recipient_mobile' => '017XXXXX', 'recipient_city' => 'Dhaka', 'recipient_area' => 'Badda', 'recipient_thana' => 'Badda', 'recipient_address' => 'Full Address', 'package_code' => '#XXXX', 'product_price' => '1500', 'payment_method' => 'COD', 'recipient_landmark' => 'DBBL ATM', 'parcel_type' => 'BOX', 'requested_delivery_time' => '2019-07-05', 'delivery_hour' => 'any', 'recipient_zip' => '1212', 'pick_hub' => '18490', 'product_id' => 'DAFS', 'pick_address' => 'Gudaraghat new mobile', 'comments' => 'Please handle carefully', 'number_of_item' => '3', 'actual_product_price' => '1200', 'pgwid' => 'XXX', 'pgwtxn_id' => 'XXXXXX' ); $courier->setParams($orderData); $response = $courier->placeOrder();
请求Pathao的示例代码
use Xenon\MultiCourier\Courier; use Xenon\MultiCourier\Provider\Pathao; $courier = Courier::getInstance(); $courier->setProvider(Pathao::class, 'local'); /* local/production */ $courier->setMethod('get'); $courier->setRequestEndpoint('cities/1/zone-list', []); //second param should be array. its optional. you should form params here $response = $courier->send();
与提供商API交互的可用方法
getInstance()
getConfig()
setConfig()
getParams()
setParams()
getProvider()
setProvider()
getCities()
getThanas()
trackOrder()
trackChildOrder()
getPackages()
placeOrder()
cancelOrder()
cancelChildOrder()
fraudStatusCheck()
getAreas()
getPostCodes()
getBranches()
printLabel()
boostSms()
topupSms()
topTransactionStatus()
topupOtp()
目前支持的快递网关
- ECourier
- Pathao
我们正在这个开源库中不断努力添加更多的孟加拉国快递公司。如果您觉得缺少什么,请就此事提出问题。您可以将拉取请求发送到 dev 分支。如果您想为此库做出贡献,那么您非常受欢迎,请这样做……从这里阅读博客
https://dev.to/arif98741/bangladeshi-courier-company-api-integration-in-laravel-using-xenon-multicourier-package-4m12