A node wrapper for the Internetmarke web service of the Deutsche Post
npm install internetmarke
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.
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'
});
const Internetmarke = require('internetmarke');
const internermarke = new Internetmarke(partner);
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
});
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
});
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)
});
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 ... **/
});