Klarna checkout v3 B2C and B2B in same channel

Anyone that have successfully implemented klarna checkout V3 in a channel that is hosting both B2B and B2C customers?

For us the checkout isn’t behaving in a consistent manner and the setting that we apply in KlarnaCondigv3 isn’t always applied. Sometimes it works if you reload the checkout page and sometimes not.

We have added AllowedCustomerTypes = new List { CustomerTypePerson, CustomerTypeOrganization}

But if logged in we want only organization or person to be available depending on the customer.
We also want to populate organization number for B2B customers automatically in the klarna checkout.

So if logged in and b2b customer we apply below code to set customer type to organization and remove the person option from allowed.

First of OrganizationId is never applied in the klarna checkout and secondly you usually have to select organization and enter a organization number before the klarna checkout removes the option to select person.

If i look at what is logged by klarna plugin i see 3 klarna snippets logged each time I reload the checkout page.

  1. Looks lite cart fetched from klarna
  2. Looks like our setting applied to klarna cart
  3. Response from applying options

the 3. response usually don’t include any of the changes we set in the klarnaconfig3v file unless we reload the checkout page.

  1. Sometimes include settings we set in 2. if we reload the checkout page.

Since the behaviour of the klarna checkout is some what random we haven been able to pinpoint where to start troubleshooting this. Only thing that are really consistent is that organization number is never applied in klarna checkout.

Anyone the tried to implemented B2C and B2B in same channel and had similar problems that you solved?

For me it feels like first time you visit the checkout the foundation for the klarna checkout is set and after that it is hard to apply other rules to that cart unless you clear cookies and start over.

if (orderCarrier.CustomerInfo != null && orderCarrier.CustomerInfo.PersonID != Guid.Empty)
            {
                klarnaCheckoutOrder.CheckoutCustomer = new CheckoutCustomer();
                if (orderCarrier.CustomerInfo.OrganizationID != Guid.Empty)
                {
                    // Customer is B2B customer
                    var organization = _organizationService.Get(orderCarrier.CustomerInfo.OrganizationID);
                    if (organization != null)
                    {
                        klarnaCheckoutOrder.CheckoutCustomer.OrganizationRegistrationId = organization.Fields.GetValue<string>(CustomerFieldNames.LegalRegistrationNumber);
                    }
                    klarnaCheckoutOrder.CheckoutCustomer.Type = CustomerTypeOrganization;
                    klarnaCheckoutOrder.CheckoutOptions.AllowedCustomerTypes.Remove(CustomerTypePerson);
                }
                else
                {
                    // Customer is B2C customer
                    klarnaCheckoutOrder.CheckoutCustomer.Type = CustomerTypePerson;
                    klarnaCheckoutOrder.CheckoutOptions.AllowedCustomerTypes.Remove(CustomerTypeOrganization);
                }
            }

Litium version: 7.6.1

Without testing I think the info are set when the Klarna first are initiated for the cart. If you clear out the payment info’s on the cart then next visit on the checkout should make a new initialization and I hope you get the new settings persisted.

Thanks Patric yes it looks like we need to clear the cart in some manner switching between B2B och B2C but our main issue was that the checkout didn’t behaving consistently seems to have been related to that klarna had not enabled B2B entirely in out test environment. No when klarna says it is enabled we have no problem setting current session customertype on the klarna checkout or populating the checkout with a organization number.

So before some one try B2B make sure it is fully enabled in you klarna playground environment because if not enabled it still works but just not as expected.

1 Like

Clearing PaymentInfo on the order carrier works for resetting the cart when switching between channels on the same domain, so it should work for this use case as well.

We have added clear cart to logout witch also made the checkout work better. The problem i see with clearing paymentinfo in our case is to know when we should clear it except for the more obvious before login or after logout.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.