Skip to content

hefan/solidus_dhl_label

Repository files navigation

Solidus Dhl Label

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.

Extension Installation

Add solidus_dhl_label to your Gemfile:

gem 'solidus_dhl_label'

Bundle your dependencies:

bundle install

Install the Extension:

bundle exec rails g solidus_dhl_label:install

Extension Usage

Configure

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

Explanation of configuration

  • 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.

  • 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
    • email
  • default_unit_weight: Weight is needed for the package, at least 0.01 kg, max 31.5 kg.

  • debug_output: true or false. if true the request and response will be logged.

further info resources

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/

Usage in Backend

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.

Development

Testing the extension

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)

Running the sandbox

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

Releasing new versions

Please refer to the dedicated page in the Solidus wiki.

License

Copyright (c) 2024 stefan hartmann, released under the New BSD License.

About

DHL Shipping Label PDF Creation for Solidus Shop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published