Skip to content

A node wrapper for the Internetmarke web service of the Deutsche Post

License

Notifications You must be signed in to change notification settings

Vilango/internetmarke

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

internetmarke

Build Status Build Status NPM version

License Dependencies

A node wrapper for the Internetmarke web service of the Deutsche Post

Installation

npm install internetmarke

Required accounts

To use the module you have to request a partner account. You can get one from the website of the Deutsche Post or via mail.

Second, an account is required that is used to pay the vouchers.

Basic usage

Declare partner

Init the internetmarke object with your partner credentials. You can request them on the page of the Deutsche Post.

const Partner = require('internetmarke').Partner;

const partner = new Partner({
  id: 'PARTNER_ID',
  secret: 'SCHLUESSEL_DPWN_MARKTPLATZ'
});

Create internetmarke instance

const Internetmarke = require('internetmarke');

const internermarke = new Internetmarke(partner);

Authenticate user

Once the partner credentials have been set, you can login with your account that should be used for the payment.

const User = require('internetmarke').User;

const user = new User({
  username: '[email protected]',
  password: '*****'
});
internetmarke.authenticateUser(user)
  .then(() => {
    // user is authenticated
  });

Order vouchers

As soon as the user has been authenticated you can start ordering vouchers. You can set the productCode and the voucherLayout (Default is Address Zone) for every single voucher.

To determine the right voucher, you can use the product list.

internetmarke.orderVoucher({
  productCode: 1,
  price: 70
});

Checkout

Once done, you can proceed with the checkout which will buy the vouchers and return the information including a link to the zip file.

internetmarke.checkout()
  .then(shoppingcart => {
    // shoppingcart.orderId
    // shoppingcart.link - contains the link to the zip archive
    // shoppingcart.vouchers[].id - used to regenerate the voucher
    // shoppingcart.vouchers[].trackingCode (depending on product)
  });

Add addresses to a voucher

Vouchers that are in AddressZone Layout can handle addresses. You can add a pair of sender / receiver addresses with the AddressFactory.

const AddressFactory = require('internetmarke').AddressFactory;

const sender = AddressFactory.create({
  firstname: 'Max',
  lastname: 'Mustermann',
  street: 'Marienplatz',
  houseNo: 1,
  zip: 80331,
  city: 'München'
});
const receiver = AddressFactory.create({
  company: 'Studio 42',
  firstname: 'John',
  lastname: 'Doe',
  street: 'Morningside Road',
  houseNo: 44,
  zip: 'EH10 4BF'
  city: 'Edinburgh'
  country: 'GBR'
});
const addressBinding = AddressFactory.bind({ receiver, sender});

internetmarke.orderVoucher({
  addressBinding
  /** further voucher info ... **/
});

About

A node wrapper for the Internetmarke web service of the Deutsche Post

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%