DHL Shipping Label PDF Creation for Solidus Shop.
Create a Shipping Label for each completed order using the DHL "Parcel DE Shipping (Post & Parcel Germany)" API.
Tested for solidus 3.4 and above.
Add solidus_dhl_label to your Gemfile:
gem 'solidus_dhl_label', github: "hefan/solidus_dhl_label"
Bundle your dependencies:
bundle install
Install the Extension:
bundle exec rails g solidus_dhl_label:install
Configure your Settings in config/initializers/solidus_dhl_label_rb
SolidusDhlLabel.configure do |config|
config.endpoint = ""
config.bcs_user = ""
config.bcs_password = ""
config.ekp = ""
config.procedure_id = ""
config.participation_id = ""
config.api_key = ""
config.consignor = {
name1: "",
name2: "",
addressStreet: "",
postalCode: "",
city: "",
country: "",
email: ""
}
config.default_unit_weight = 1.0 # default weight if weight for variant is not given
config.debug_output = false # log request and response output for debugging
end
-
endpoint: URL Endpoint of the Service
-
bcs_user and bcs_password your credentials as Business Consumer at DHL Business Consumer Portal https://geschaeftskunden.dhl.de/
- For Sandbox you can use "sandy_sandbox" and "pass"
-
ekp: "uniform customer and product number" from your Business Consumer Profile.
- For Sandbox you can use "3333333333"
-
procedure_id: "Contract Procedure" ID, does als stand for selected DHL Product.
- More detailed description in https://developer.dhl.com/api-reference/parcel-de-shipping-post-parcel-germany-v2?lang=en#get-started-section/ Section "Products and services via the web service interface"
- For example "01" for "V01PAK" (germany only) product, "53" for "V53WPAK" (worldwide) product
- "auto" does select "01" or "53" based on orders ship address
-
participation_id: "contract participation" ID, you will get it from your Business Consumer Profile.
- For Sandbox you can just use "01"
-
api_key: Your API Key from the credentials of your created app at the developer portal https://developer.dhl.com/
- The app needs to have the API of type Parcel DE Shipping (Post & Parcel Germany) assigned. Watch for the environment: test(sandbox) or production.
- the api_secret seems not to be needed!
-
consignor: The Sender Address for the Label. Normally the Address of your Business
- name1
- name2: optional second name
- addressStreet
- postalCode
- city
- country: in iso3 format, like "DEU" for germany
-
default_unit_weight: Weight is needed for the package, at least 0.01 kg, max 31.5 kg.
- if your variants doesn't have weight (or have 0.0, which isn't sufficient for being able to print the label), the weight given here will be used
- the weight for the label request will be the sum from the orders line items and their quantity.
- You can als add dimensions to the request. if you need to do that, you have to override the get_shipments function in Spree::DhlLabelService, see also https://developer.dhl.com/api-reference/parcel-de-shipping-post-parcel-germany-v2?lang=en#get-started-section/ Section "Dimensions"
-
debug_output: true or false. if true the request and response will be logged.
Usage of the DHL Parcel DE Shipping API, description of services and postman collection to test: https://developer.dhl.com/api-reference/parcel-de-shipping-post-parcel-germany-v2?lang=en#get-started-section/
DHL Developer Portal https://developer.dhl.com/
DHL Busines Consumer Portal https://geschaeftskunden.dhl.de/
Push the "DHL Label" Button on the orders detail page in shipments tab to send the label request and to get either redirected to the label url or to get a flash with the error message from the response.
First bundle your dependencies, then run bin/rake
. bin/rake
will default to building the dummy
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
bin/rake extension:test_app
.
bin/rake
To run Rubocop static code analysis run
bundle exec rubocop
When testing your application's integration with this extension you may use its factories. You can load Solidus core factories along with this extension's factories using this statement:
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusDhlLabel::Engine)
To run this extension in a sandboxed Solidus application, you can run bin/sandbox
. The path for
the sandbox app is ./sandbox
and bin/rails
will forward any Rails commands to
sandbox/bin/rails
.
Here's an example:
$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp:https://127.0.0.1:3000
Use Ctrl-C to stop
Please refer to the dedicated page in the Solidus wiki.
Copyright (c) 2024 stefan hartmann, released under the New BSD License.