Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Adam Nilsson 27 posts 117 karma points
    Mar 01, 2019 @ 11:05
    Adam Nilsson
    0

    Implement Klarna?

    Hi! Is there someone here that have implemented Klarna with Tea Commerce 3.2.5?

    Shall I update the Klarna.Checkout.dll? It´s version 1.0.1.0 now.

    My problem is to get the Checkout form to display with only test data not form Tea commerce order data yet.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 01, 2019 @ 11:25
    Matt Brailsford
    1

    Hi Adam,

    just to let you know, we've put a tweet out to see if anyone can help with this https://twitter.com/teacommerce/status/1101441731831185408

    We'll see if anyone with experience using it has any advise first before we try and dig into the code for it.

    Matt

  • Tobbe 81 posts 387 karma points c-trib
    Mar 01, 2019 @ 17:33
    Tobbe
    1

    Ive got an OLD site running with TC 2.2.3 and Klarna. Its running Klarna.Checkout.dll 1.0.1.0. This is how we show the klarnaform

    (sorry this code is ooold)

    @using TeaCommerce.Api.Models
    @using TeaCommerce.Umbraco.Web
    @{
        string html = "";
        try {
      Order currentOrder = TC.GetCurrentOrder( long.Parse( Model._store ) );
      WebClient webclient = new WebClient();
      webclient.Headers[ "referer" ] = HttpContext.Current.Request.Url.AbsoluteUri;
            html = webclient.DownloadString( currentOrder.Properties[ "teaCommerceCommunicationUrl" ]+"?communicationType=checkout" );
        }
        catch (Exception ex){@ex.Message}
    }
    

    and this is how we show the confirmation-iframe from klarna:

    @using TeaCommerce.Api.Models
    @using TeaCommerce.Umbraco.Web
    
    @{
      Order currentOrder = TC.GetCurrentFinalizedOrder( long.Parse( Model._store ) );
      string html = new WebClient().DownloadString( currentOrder.Properties[ "teaCommerceCommunicationUrl" ] + "?communicationType=confirmation" );
    }
    
    @Html.Raw( html )
    
  • Tobbe 81 posts 387 karma points c-trib
    Mar 01, 2019 @ 17:39
    Tobbe
    1

    this is our config in TC backend

    enter image description here

  • Adam Nilsson 27 posts 117 karma points
    Mar 04, 2019 @ 11:04
    Adam Nilsson
    0

    Thanks @Tobbe.

    I got the same issue with the url as you had 2014 :)

    Merchant.id and sharedSecret from Klarna is created, but the domain url is http://www.myteststore.com.

    Can you test if your test account still works? id: 200 secret:test?

    It can be that the Tea commerce klarna provider just works with older version of Klarna Checkout, like V2.

  • Tobbe 81 posts 387 karma points c-trib
    Mar 04, 2019 @ 12:15
    Tobbe
    0

    hmm, Ive got 2 sites running Klarna version 1 dll. But I think I might have got a special build of TeaCommerce.PaymentProviders.dll that Ive got from teacommerce support (back in 2014) that fixes some problems..

    what do you mean I should test and whats the issue you are having?

  • Adam Nilsson 27 posts 117 karma points
    Mar 04, 2019 @ 13:02
    Adam Nilsson
    0

    The issue now is that I got credentials for Checkout V3 not V2.

    I did an request here: https://developers.klarna.com/kco-v2/apply-for-test-account

    Or is there an property setting for switching the api call url?

  • Tobbe 81 posts 387 karma points c-trib
    Mar 04, 2019 @ 13:16
    Tobbe
    0

    oh, no you cant change the url for the api call. Here's the source code: https://github.com/TeaCommerce/Payment-Providers/blob/master/Source/TeaCommerce.PaymentProviders/Inline/Klarna.cs#L20

    You might be able to copy that and try to change the api url (and name of the provider at line 17)

  • Adam Nilsson 27 posts 117 karma points
    Mar 05, 2019 @ 07:48
    Adam Nilsson
    0

    I run Klarna.cs now and it throws an exception on this row:

    257 data["locale"] = settings["locale"];

    I have set the site culture to sv-SE and locale settings to sv-se, is this something you have faced to?

  • Tobbe 81 posts 387 karma points c-trib
    Mar 05, 2019 @ 07:50
    Tobbe
    0

    nope, what does the exception say?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 05, 2019 @ 09:03
    Matt Brailsford
    101

    Just to let you know, I started a PR this morning to create an updated version of the Klarna payment provider using the v3 API. It should compile but it is completely un-tested currently. You are welcome to give it a try (you'll have to clone the git repository and compile it):

    https://github.com/TeaCommerce/Payment-Providers/pull/26

    I'll try an get it tested, but it'll probably take a few days fitting around other bits I have on. In the mean time, you can either test it yourself if you are up to it, or continue to see if you can get the current version working (from my research, it appeared the v2 API is still active).

  • Adam Nilsson 27 posts 117 karma points
    Mar 05, 2019 @ 09:55
    Adam Nilsson
    0

    Great! I will try that! I have a account request for the old V2 at Klarna but the customer is running V3 so this code will be good for testing.

    First test did end up here : // If no Klarna order was found to update or the session expired - then create new Klarna order

                    if (klarnaOrder == null)
                    {
                        klarnaOrder = client.NewCheckoutOrder(klarnaOrderId);
                        klarnaOrder.Create(klarnaOrderData);
                        klarnaOrderData = klarnaOrder.Fetch();
    
                        order.TransactionInformation.TransactionId = klarnaOrderData.OrderId;
                        order.TransactionInformation.PaymentState = PaymentState.Authorized;
                        order.Save();
                    }
    

    ex = BadRequest (400)

  • Adam Nilsson 27 posts 117 karma points
    Mar 05, 2019 @ 15:25
    Adam Nilsson
    0

    Finally :) It was "Bad value: purchase_country (must match \"^[A-Za-z]{2,2}$\")" that was set wrong. Thanks Tobbe and Matt

    enter image description here

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 05, 2019 @ 15:29
    Matt Brailsford
    0

    Awesome. Is this using the v2 or v3 provider? If the later, did you need to change any of the code?

  • Adam Nilsson 27 posts 117 karma points
    Mar 05, 2019 @ 15:35
    Adam Nilsson
    0

    It's the V3 provider but the code from the clone didnt work so I copy your code directly and put it in a new Klarna.cs file.

    Sorry I was in a great mode yesterday that I forget that I didnt get this row to work:

    var klarnaOrderId = order.TransactionInformation.TransactionId;
    and this:

    LoggingService.Instance.Error

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 07, 2019 @ 08:43
    Matt Brailsford
    0

    Hmm, I'm not sure why those wouldn't work. I've done some testing and not hit any issues with those.

    I've updated my PR on GitHub if you want to try it. I've run several orders through it and it should all work. I still need to write the docs for it though.

    I will say, I've ultimately made the provider work the same as the previous provider which I think has some specific setup requirements, in that, when using this payment provider I don't think you are meant to collection billing / shipping info yourself, it appears to be built such that the checkout captures these and then the payment provider writes them back to the order so anything you do capture will get overridden.

    Also, this payment provider doesn't itself support capturing / refunding so this will all need to be done via the Klarna UI. As I say though, this is as per the current payment provider.

    I do think a better provider could be produced that supports all of these things, but unfortunately it's not currently high on my priority list.

    Never the less, I hope this helps.

    Matt

  • Adam Nilsson 27 posts 117 karma points
    Mar 07, 2019 @ 12:05
    Adam Nilsson
    0

    It´s works with your latest code!

    Do you planning to implement the new provider in the Tea commerce package or do you need to create one for all the functions that Klarna has?

    Or shall I run with this code for now?

    Regarding the checkout step it feels like the shipping step is abit overkill when you use Klarna, but can you skip that collection of data in checkout for Tea commerce?

    Thanks!

    Adam

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 08, 2019 @ 07:25
    Matt Brailsford
    0

    Hey Adam,

    You can use it for now yea, it won't hurt.

    I don't think you need to collect your shipping info as I think you can tell Klarna to collect it and then like I mentioned above, it is setup to copy all the values back, so when using Klarna you should be able to pretty much go from Cart to Klarna Checkout.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 08, 2019 @ 07:37
    Matt Brailsford
    0

    Oh, the one thing you might want to do is create a TC admin order view that uses the relevant named order properties as fetched from Klarna (I don't think the default one uses the same property aliases)

    enter image description here

  • Adam Nilsson 27 posts 117 karma points
    Mar 14, 2019 @ 08:33
    Adam Nilsson
    0

    Hi Matt,

    Did you get all the products from cart in too Klarna in your testing?

    Only got 1 line in and the total sum correct.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Mar 14, 2019 @ 08:39
    Matt Brailsford
    0

    Hi Adam,

    The Klarna provider only sends through a single item which represents the order as a whole. This is how the original provider was developed so I just replicated the behaviour.

  • Adam Nilsson 27 posts 117 karma points
    Mar 14, 2019 @ 08:43
    Adam Nilsson
    0

    Ok, then it´s not an bug :) Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft