bernhardk / laravel-dpd
Laravel 包,用于使用 DPD Webservices 提交运单,并获取其标签和跟踪信息。
v1.8.0
2024-09-15 10:56 UTC
Requires
- php: >=8.0.2
- ext-soap: *
- illuminate/support: ^6|^7|^8|^9|^10|^11
README
这是一个基于 Michiel Meertens 的 "DPD Webservice" (https://github.com/meertensm/DPD) 的 Laravel 包。
安装
您可以通过 composer 命令在现有的 Laravel 项目中安装此包。请注意以下要求。
$ composer require bernhardk/laravel-dpd
之后,您需要使用以下命令发布配置文件
$ php artisan vendor:publish --provider="BernhardK\Dpd\DpdServiceProvider" --tag="config"
一旦您在 /config/dpd.php 中配置了凭证,您就可以按照以下说明使用此包。
功能
- 将运单提交到 dpd webservice 并获取其标签和跟踪信息
- 获取包裹状态信息
要求
- PHP SOAP 扩展需要安装 (https://stackoverflow.com/questions/2509143/how-do-i-install-soap-extension/41518256)
- 在 /config/dpd.php 中编辑配置参数。所有参数都有说明。
DPD Webservice 版本
基本运单使用
此包注册了一个可以直接使用的类
app()->dpdShipment
以下代码描述了示例用法并返回一个 PDF 文件。
// Enable DPD B2C delivery method app()->dpdShipment->setPredict([ 'channel' => 'email', 'value' => 'someone@mail.com', 'language' => 'EN' ]); // ATTENTION: Cause of privacy reasons transmitting clients email address is only allowed if client agreed. // Set the general shipmentdata app()->dpdShipment->setGeneralShipmentData([ 'product' => 'CL', 'mpsCustomerReferenceNumber1' => 'Test shipment' ]); // Set the sender's address app()->dpdShipment->setSender([ 'name1' => 'Your Company', 'street' => 'Street 12', 'country' => 'NL', 'zipCode' => '1234AB', 'city' => 'Amsterdam', 'email' => 'contact@yourcompany.com', 'phone' => '1234567645' ]); // Set the receiver's address app()->dpdShipment->setReceiver([ 'name1' => 'Joh Doe', 'name2' => null, 'street' => 'Street', 'houseNo' => '12', 'zipCode' => '1234AB', 'city' => 'Amsterdam', 'country' => 'NL', 'contact' => null, 'phone' => null, 'email' => null, 'comment' => null ]); // Add as many parcels as you want app()->dpdShipment->addParcel([ 'weight' => 3000, // In gram 'height' => 10, // In centimeters 'width' => 10, 'length' => 10 ]); app()->dpdShipment->addParcel([ 'weight' => 5000, 'height' => 0, // In centimeters 'width' => 0, 'length' => 0 // All parameters need to be given. Enter 0 if you have no value ]); // Submit the shipment app()->dpdShipment->submit(); // Get the trackingdata $trackinglinks = app()->dpdShipment->getParcelResponses(); // Show the pdf label header('Content-Type: application/pdf'); echo app()->dpdShipment->getLabels();
基本跟踪使用
此包注册了一个可以直接使用的类
app()->dpdTracking
以下代码描述了示例用法并返回跟踪状态。
// Retrieve the parcel's status by it's awb number $parcelStatus = app()->dpdTracking->getStatus('09981122330100');
支持
如果您有任何问题或问题,请创建一个新的问题。
许可证
此包根据 MIT 许可证授权。此包基于 Michiel Meertens 的 "DPD Webservice" (https://github.com/meertensm/DPD),它也根据 MIT 许可证授权。