Additional features

These are examples of use cases that allow you to customize the buying experience with Klarna Checkout for your needs.


Extra merchant data

Providing Klarna with extra merchant data

In some cases, Klarna requires additional information regarding the customer and the purchase in order to make a correct risk assessment. 
In this tutorial you will learn what information Klarna requires, and how you can send it to Klarna.

 

Use cases

  • Airline Tickets - when creating an order to sell an airline ticket, information about the passenger and itinerary to be booked should be provided to Klarna.
  • Event sales merchant - when creating an order for selling a ticket to an event, information about the event should be provided to Klarna.
  • Recurring orders - when creating an order for subscriptions or recurring payments, subscription and customer account information should be provided to Klarna.

 

1. Create the extra merchant data

Add the relevant data, based on the specification and your product vertical. To know which product vertical is right for you, please contact your integration sales representative.

The example below relates to recurring orders, which requires the subscription and customer_account_info details.

const EMD_FORMAT = 'Y-m-d\TH:m:s\Z';

$emd = [
    "subscription" => [
        [
            "subscription_name" => "Test Testperson",
            "start_time" => (new DateTime())->format(EMD_FORMAT),
            "end_time" => (new DateTime())->modify('+12 months')->format(EMD_FORMAT),
            "auto_renewal_of_subscription" => false
        ]
    ],
    "customer_account_info" => [
        [
            "unique_account_identifier" => "user@example.com",
            "account_registration_date" => (new DateTime())->format(EMD_FORMAT),
            "account_last_modified" => (new DateTime())->format(EMD_FORMAT)
        ]
    ]
];
final List<Subscription> subscription = new ArrayList<Subscription>() {
    {
        add(new Subscription()
                .setSubscriptionName("One year monthly recurring payments")
                .setStartTime(DateTime.now())
                .setEndTime(DateTime.now().plusMonths(12))
                .setAutoRenewalOfSubscription(false));
    }
};

final List<CustomerAccountInformation> customerInfo = new ArrayList<CustomerAccountInformation>() {
    {
        add(new CustomerAccountInformation()
                .setUniqueAccountIdentifier("user@example.com")
                .setAccountRegistrationDate(DateTime.now())
                .setAccountLastModified(DateTime.now()));
    }
};

final ExtraMerchantDataBody extraMerchantDataBody = new ExtraMerchantDataBody() {
    {
        setSubscription(subscription);
        setCustomerAccountInfo(customerInfo);
    }
};

final ExtraMerchantData extraMerchantData = new ExtraMerchantData() {
    {
        setBody(extraMerchantDataBody);
    }
};
List<Subscription> subscription = new List<Subscription>
{
    new Subscription
    {
        SubscriptionName = "One year monthly recurring payments",
        StartTime = DateTime.Now,
        EndTime = DateTime.Now.AddMonths(12),
        AutoRenewalOfSubscription  = False
    }
};

List<CustomerAccountInformation> customerInfo = new List<CustomerAccountInformation>
{
    new CustomerAccountInformation
    {
        UniqueAccountIdentifier = "user@example",
        AccountRegistrationDate = DateTime.Now,
        AccountLastModified = DateTime.Now
    }
};

ExtraMerchantData extraMerchantData = new ExtraMerchantData
{
    Body = new ExtraMerchantDataBody
    {
        Subscription = subscription,
        CustomerAccountInfo = customerInfo
    }
};

2. Attach the data to the order

Once the data is created, you would need to include it under the attachment property. Once it is populated simply send the data as you learned in the Embed the checkout tutorial.

$orderData['attachment'] = [
    "content_type" => "application/vnd.klarna.internal.emd-v2+json",
    "body" => json_encode($emd)
];
orderData.setAttachment(extraMerchantData.toAttachment());
orderData.Attachment = extraMerchantData;

Note: Find out more about the different data fields by checking the attachments specification.


 

Remarketing with Klarna Checkout

Using remarketing on abandoned carts is a good way to get more customers to complete their purchases. If customers have started to enter their contact details but then decide to cancel their purchase, the merchant can email the customer, prompting them to return to the abandoned cart.

Klarna Checkout together with abandoned cart software is an effective way of increasing sales. It allows you to pre-fill email addresses and postcodes when customers return. Klarna uses the pre-filled information to identify customers and provide a one-click buying experience.

 

1. Obtain customer details

With Klarna Checkout Javascript API, merchants receive notifications when a customer enters data in the Checkout form. This is done by registering a callback function that receives the customer's email address, postcode, given name, and family name. 

It’s important that the callback function is registered after Klarna Checkout in the HTML code, or after Klarna Checkout has been rendered. 

This is how the callback function is registered

window._klarnaCheckout(function(api) {
     api.on({
         'change': function(data) {
             // Do something
         }
     });
});

The data object contains the consumer’s email address, postcode, given name, and last name. Fields that have not been filled are sent as empty strings.

An example of a data object:

{
     "email": "klara.joyce@klarna.com",
     "postal_code": "N5 1AW",
     "given_name": "Klara",
     "family_name": "Joyce"
}

2. Filter out completed purchases

To ensure abandoned cart emails are only sent to customers that have not completed purchases, the merchant must filter out orders that have been completed. This is done by removing matching email addresses from the remarketing email list. The best place to do this is on the order confirmation page where purchases are completed.

 

3. Send abandoned cart email

If a customer has abandoned a cart, an email should be sent, prompting them to return to it. This is a great opportunity to offer the consumer something extra if they complete their purchase. Merchants can, for example, offer customers a discount or free shipping to encourage them to complete their purchase. A popular way of doing this is to send emails in three stages: an email to remind customers about their cart; a second email asking them to complete their purchase; and finally an email offering a discount to complete the purchase.

The link in the email that takes customers back to the web store should at least contain an identifier for the abandoned cart, as well as the customer’s email address and postcode. This is needed to load the abandoned cart and to pre-fill the Checkout with its parameters.

An example of a link:
https://www.store.com/checkout?cartid=1a2b3c4d&email=fornamn.efternamn@klarna.com&postal_code=12345

 

4. Pre-fill Klarna Checkout

When the customer returns to the checkout, the merchant should load the previously abandoned cart. This can for example be done by using the cartid which was included in the link in the e-mail. The merchant should then pre-fill Klarna Checkout with the email address and the postcode provided in the link from the email. Klarna will then take care of the rest: identify the customer and pre-fill the remaining fields.

This is how Klarna Checkout can be pre-filled

$orderData['billing_address']['email'] = 'example-email@example.com';
$orderData['billing_address']['postal_code'] = '12345';
orderData.setBillingAddress(new Address() {
    {
        setEmail("example-email@example.com");
        setPostalCode("12345");
    }
});
orderData.BillingAddress = new Address() {
    Email = "example-email@example.com";
    PostalCode = "12345";
};

The customer is then just one click away from converting to a completed transaction.


Additional payment methods in Klarna Checkout


Note: To use this feature, you will need an agreement that defines what payment methods that you will use.

This feature enable you to use Klarna Checkout for additional payment methods that are currently not offered by Klarna. This means that you will be able to offer one great checkout experience, regardless how the consumer wants to pay.

 

How does it work?

When the Checkout is loaded, you have the option to load additional payment methods. "Wallets" are shown as buttons in the bottom of KCO and available from the moment KCO loads. Clicking the button will make the customer leave KCO and be redirected to an external payment window to complete the purchase, e.g. to PayPal. 

In cases when the customer needs to choose payment method before completing the purchase, all payment methods including wallets will be shown in the payment selection list together with our standard offering. You can use all information the consumer has entered in KCO to complete the purchase with another payment method.

Please note that when a consumer is using a payment method not offered by default, no purchase order is created by Klarna. Klarna doesn’t know whether the consumer eventually finishes the purchase after leaving the checkout. Klarna doesn’t send any kind of confirmation emails or handle any money. All processing of the order is the merchant’s responsibility.

How to implement

The payment methods are classified as either External Payment Methods or External Checkouts. For External Payment Methods, you want to collect address data about the consumer via Klarna Checkout (e.g. Cash on delivery). For External Checkouts, you don’t need Klarna Checkout to collect data about the consumer (e.g. PayPal)

 

Code example

The payment methods are defined when calling the Klarna Checkout. The payment methods will be presented in the checkout in the order they are set in the API call, after the default options provided by Klarna. Go here for the list of parameters.

$create['external_payment_methods'][] = [
    'name' => 'Cash on delivery',
    'redirect_url' => 'https://example.com/payment',
    'image_url' => 'https://example.com/image',
    'fee' => 1450
];

$create['external_checkouts'][] = [
    'name' => 'Non Klarna eWallet',
    'redirect_url' => 'https://example.com/checkout',
    'image_url' => 'https://example.com/image',
    'fee' => 1450
];
final List<ExternalPaymentMethod> externalPaymentMethods = new ArrayList<ExternalPaymentMethod>() {
    {
        add(new ExternalPaymentMethod()
                .setName("Cash on delivery")
                .setRedirectUrl(URI.create("https://example.com/payment"))
                .setImageUrl(URI.create("https://example.com/image"))
                .setFee(1450L));
    }
};

final List<ExternalCheckout> externalCheckouts = new ArrayList<ExternalCheckout>() {
    {
        add(new ExternalCheckout()
                .setName("Non Klarna eWallet")
                .setRedirectUrl(URI.create("https://example.com/checkout"))
                .setImageUrl(URI.create("https://example.com/image"))
                .setFee(1450L));
    }
};

CheckoutOrderData data = new CheckoutOrderData() {
    {
        setExternalPaymentMethods(externalPaymentMethods);
        setExternalCheckouts(externalCheckouts);
    }
};
List<ExternalPaymentMethod> externalPaymentMethods = new List<ExternalPaymentMethod>
{
    new ExternalPaymentMethod()
    {
        Name = "Cash on delivery",
        RedirectUri = new Uri("https://example.com/payment"),
        ImageUri = new Uri("https://example.com/image"),
        Fee = 1450
    }
};

List<ExternalCheckout> externalCheckouts = new List<ExternalCheckout>
{
    new ExternalCheckout()
    {
        Name = "Non Klarna eWallet",
        RedirectUri = new Uri("https://example.com/checkout"),
        ImageUri = new Uri("https://example.com/image"),
        Fee = 1450
    }
};

CheckoutOrderData orderData = new CheckoutOrderData()
{
    ExternalPaymentMethods = externalPaymentMethods,
    ExternalCheckouts = externalCheckouts
};