Xenon Multicourier 패키지를 사용하여 Laravel에서 Bangladeshi Courier Company Api 통합
여기에서 API는 다르지만 모든 공급자의 코딩 구조를 고정해야 하는 번거로움을 해결하기 위해 Xenon/MultiCourier를 개발했습니다. 귀하의 의무는 E-courier, Pathao, Steadfast, Paperfly, Redx와 같은 택배 회사에서 제공한 api 자격 증명을 변경하는 것입니다. 이 패키지를 프로젝트에 쉽게 통합하려면 아래 단계를 따르십시오.
1 단계:
composer require xenon/multicourier
2 단계:
그런 다음 패키지를 게시합니다.
php artisan vendor:publish --provider=Xenon\MultiCourier\MultiCourierServiceProvider
3단계:
개별 택배에 대한 .env 구성을 설정합니다. 예를 들어 E-courier 및 Pathao
PATHAO_CLIENT_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" PATHAO_USERNAME="[email protected]" PATHAO_PASSWORD="xxxxxx" PATHAO_GRANT_TYPE="password" ECOURIER_API_KEY='xxx' ECOURIER_API_SECRET='xxx' ECOURIER_USER_ID='xxxx' ECOURIER_ENVIRONMENT='xxxx'
그렇지 않고 더 많은 제어가 필요한 경우 기본 발신자 개체를 사용할 수 있습니다. 이것은 laravel 파사드 또는 서비스 공급자를 건드리지 않습니다.
다음은 공급자의 API와 상호 작용하기 위한 샘플 코드입니다.
위치 가져오기
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
//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();
저장소 및 모든 방법 목록에 액세스하려면 여기에서 github 링크를 방문하십시오https://github.com/arif98741/multicourier.
Reference
이 문제에 관하여(Xenon Multicourier 패키지를 사용하여 Laravel에서 Bangladeshi Courier Company Api 통합), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/arif98741/bangladeshi-courier-company-api-integration-in-laravel-using-xenon-multicourier-package-4m12텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)