Re-send invoice

This functionality enables you ask Klarna to re-send an invoice. You have the option of choosing email (emailInvoice) or postal service (sendInvoice).

Use case

A consumer places an order. A little bit later, the consumer contacts your customer service center and wants to add or remove items from the order. You update the order in your system and trigger an invoice send-out.

Prerequisites


1. Initialize the Klarna object

Each Klarna library function requires a basic setup of the Klarna object. This configuration specifies how the library communicates with Klarna’s servers.

Follow the code examples below to see how to do this with our different libraries:

use Klarna\XMLRPC\Klarna;
use Klarna\XMLRPC\Country;
use Klarna\XMLRPC\Language;
use Klarna\XMLRPC\Currency;

$k = new Klarna();

$k->config(
    0,              // Merchant ID
    'sharedSecret', // Shared secret
    Country::SE,    // Purchase country
    Language::SV,   // Purchase language
    Currency::SEK,  // Purchase currency
    Klarna::BETA,   // Server
);
Klarna k = new Klarna(
        0,
        "sharedSecret",
        KlarnaCountry.SE,
        KlarnaCurrency.SEK,
        new JsonStorage("/srv/data/pclasses.json"),
        Klarna.BETA
);
config = klarna.Config(
    eid=0,
    secret='sharedSecret',
    country='DE',
    language='DE',
    currency='EUR',
    mode='beta',
    pcstorage='json',
    pcuri='/srv/pclasses.json',
    scheme='https',
    candice=True)

k = klarna.Klarna(config)
k.init()
Configuration configuration = new Configuration(
    Country.Code.SE, Language.Code.SV, Currency.Code.SEK,
    Encoding.Sweden)
{
    Eid = 0,
    Secret = "sharedsecret",
    IsLiveMode = false
};

Api api = new Api(configuration);
Dim kAPI
Set kAPI = GetKlarna(0, "sharedsecret", "SE", "SV", "SEK")
kAPI.SetPort(HTTPS_PORT) ' or HTTP_PORT
kAPI.SetHost(BETA_HOST) ' or LIVE_HOST
kAPI.SetPClassesStorageUri(Server.MapPath("pclasses.xml"))

2. Make the API call to Klarna

Set the invoice number for which you want to trigger the send-out and choose the appropriate API call. To re-send the invoice via email, use emailInvoice.

$k->emailInvoice("123456");
k.emailInvoice("123456");
k.email_invoice("123456")
api.EmailInvoice("123456");
Call kAPI.EmailInvoice("123456")

To re-send the invoice by postal service, please use the sendInvoice API call.

$k->sendInvoice("123456");
k.sendInvoice("123456");
k.send_invoice("123456")
api.SendInvoice("123456");
Call kAPI.SendInvoice("123456"),

Klarna will then respond with a string with the invoice number for the emailed invoice.

An exception with error code and error message will be thrown if the API request was malformed.

Note: If you process more than one refund or update on the same invoice, please make sure that you send only one emailInovice or sendInvoice call when you complete the order update. This will ensure that Klarna sends an invoice once the order is completely finished.