Copied to clipboard

Flag this post as spam?

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


  • Bo Jacobsen 503 posts 2013 karma points
    17 days ago
    Bo Jacobsen
    0

    Invalid URI: The URI is empty - nets easy

    Hi Matt.

    We are suddenly gettin this error after setting the shop live. So we are tryin to troubleshoot where the error might be and if its a vendr or nets easy payment provider or custom code issue.

    This happens when we get to the creation of the RenderPaymentForm on the last step on checkout. This never happened before on our test servers.

    The weird this is that it says it "401 (Unauthorized)", so we tried to play around with the secret keys and that did not work. Nets tells us that we redirect to the wrong url, but when we ask into it (like, what redirect, the gateway or callback url..), they go silence...

    And it works in test mode!

    The first error message we get is this:

    System.UriFormatException: Invalid URI: The URI is empty.
       at Vendr.Core.Web.HtmlHelperExtensions.RenderPaymentForm(HtmlHelper htmlHelper, OrderReadOnly order, IDictionary`2 htmlAttributes, IOrderService orderService, IPaymentMethodService paymentMethodService, IPaymentProviderService paymentProviderService, ITranslationService translationService, IPaymentProviderUriResolver uriResolver, IOrderNumberGenerator orderNumberGenerator, IHashProvider hashProvider, IUnitOfWorkProvider uowProvider, IMembershipHelper membershipHelper)
    

    The next one is this:

    System.AggregateException: One or more errors occurred. ---> Flurl.Http.FlurlHttpException: Call failed with status code 401 (Unauthorized): POST https://api.dibspayment.eu/v1/payments/
    
  • Matt Brailsford 3288 posts 17388 karma points MVP 8x c-trib
    17 days ago
    Matt Brailsford
    0

    Hi Bo,

    Hmm, that is weird, especially if it works fine in testing.

    For the error to be coming from Flurl I think this highlights it is an issue communicating with nets so for some reason the request isn't being authorized.

    Some quick things to check could be things like rouge spaces in your settings configuration where you have any secret keys etc, but it is indeed kind of weird.

    Matt

  • Bo Jacobsen 503 posts 2013 karma points
    17 days ago
    Bo Jacobsen
    1

    Hi Matt.

    Thanks for a quick reply. I will post more info or a solution when i know more :)

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    17 days ago
    Bjarne Fyrstenborg
    0

    Hi Bo

    Yeah, something in this request isn't valid or the keys are not correct. You have entered the Live keys as well right? https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/v1/main/src/Vendr.Contrib.PaymentProviders.Nets/Easy/NetsEasyOneTimePaymentProvider.cs#L703-L705

    The prefix test-secret-key- or live-secret-key- and any white space at start or end are trimmed.

    Also if the Terms URL is filled ensure its an absolute URL: https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/v1/main/src/Vendr.Contrib.PaymentProviders.Nets/Easy/NetsEasyOneTimePaymentProvider.cs#L345

    Furthermore ensure the toggle in upper right corner in Easy portal is switched from Test to Live, otherwise it probably won't work.

  • Bo Jacobsen 503 posts 2013 karma points
    17 days ago
    Bo Jacobsen
    0

    Hi Bjarne.

    Thanks for a quick answer.

    We are removing test-secret-key- and live-secret-key- from the keys and make sure its trimmed. Because we read on docs they should be removed. But we also tried with them on. (same error).

    I tried to add the absolute path to the terms. But still the same error.

    The portal is switched to live and the test mode check mark in Umbraco is off.

    We got another solution like this, where it only differs from merchant id and keys and that works. (that makes it even more mystical) So i tried to campare everything (i think)..

    Since we copy our dev database when we start a new one. The payment provider and store gets the same id. Do you think that could be an issue?

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    17 days ago
    Bjarne Fyrstenborg
    0

    Hi Bo

    Yes, you can remove the test-secret-key- and live-secret-key- if you want, but they are removed anyway in the payment provider ifself.

    The checkout key isn't specific used yet as it is not required for HostedPaymentPage option, but used for embed checkout. https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/v1/main/src/Vendr.Contrib.PaymentProviders.Nets/Easy/NetsEasyOneTimePaymentProvider.cs#L425

    But in that case the full key need to be used.

    I don't think it should be an issue with same store id and same payment method id.. at least not if the stores use two different Easy accounts.

  • Bo Jacobsen 503 posts 2013 karma points
    17 days ago
    Bo Jacobsen
    0

    The only thing that are different from the 2 sites. besides the merchant id and secret & checkout key are that the site where it do not works have 2 domains associated with it, but www.domain2.dk/domain2.dk and domain1.dk is redirected to www.domain1.dk.

    Maybe thats an issue somehow?

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    17 days ago
    Bjarne Fyrstenborg
    0

    I don't think that would be an issue. Does the payment request fail if this is requested from www.domain1.dk ?

  • Bo Jacobsen 503 posts 2013 karma points
    17 days ago
    Bo Jacobsen
    0

    I don't think either, but its really the only different from the 2 sites, where one is working and the other one is not.

    all the request should come from www.domain1.dk since we redirect everything to that domain. But NETS is on the case, but we know that gonna take ages, but i can't really see anywhere else the error could be at.

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    17 days ago
    Bjarne Fyrstenborg
    0

    Yeah, are you able to see more about the Flurl request in the log file or only 401 (Unauthorized)?

    Not sure if the redirect rules collide with anything, but ensure /umbraco and /umbraco/vendr/ isn't rewrites/redirected.

    There could be issues if the order line amount doesn't match total amount, but in that case I wouldn't expect the 401 (Unauthorized) response.

  • Bo Jacobsen 503 posts 2013 karma points
    16 days ago
    Bo Jacobsen
    0

    Hi Bjarne.

    Yes, /umbraco and /umbraco/vendr/ is not redirectet. I guessed NETS could tell me something and if its total amout that do not match. But still havent heard anything from them.

    Here is the full log:

    System.AggregateException: One or more errors occurred. ---> Flurl.Http.FlurlHttpException: Call failed with status code 401 (Unauthorized): POST https://api.dibspayment.eu/v1/payments/
       at Flurl.Http.FlurlRequest.<HandleExceptionAsync>d__23.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Flurl.Http.HttpResponseMessageExtensions.<ReceiveJson>d__0`1.MoveNext()
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
       at Vendr.Contrib.PaymentProviders.Api.NetsEasyClient.Request[TResult](String url, Func`2 func)
       at Vendr.Contrib.PaymentProviders.Api.NetsEasyClient.CreatePayment(NetsPaymentRequest data)
       at Vendr.Contrib.PaymentProviders.NetsEasyOneTimePaymentProvider.GenerateForm(OrderReadOnly order, String continueUrl, String cancelUrl, String callbackUrl, NetsEasyOneTimeSettings settings)
    ---> (Inner Exception #0) Flurl.Http.FlurlHttpException: Call failed with status code 401 (Unauthorized): POST https://api.dibspayment.eu/v1/payments/
       at Flurl.Http.FlurlRequest.<HandleExceptionAsync>d__23.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at Flurl.Http.HttpResponseMessageExtensions.<ReceiveJson>d__0`1.MoveNext()<---
    
  • Bo Jacobsen 503 posts 2013 karma points
    15 days ago
    Bo Jacobsen
    0

    Hi Bjarne.

    NETS writes that the checkout key is needed and that the checkout key uses live-checkout-key- while the secret key do not use live-secret-key-

    We have both credentials entered. Do the checkout key being used if its sets in config?

    Cause i can see that the checkout key is sent, when you go to the HostedPayment window.

    Do you know of a way we could debug more?

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    15 days ago
    Bjarne Fyrstenborg
    0

    The checkout key is needed in the embed checkout, but not in the hosted payment page. https://developers.nets.eu/nets-easy/en-EU/api/payment-v1/#v1-payments-post

    Currently it is here, but currently not used specific in the payment request: https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/v1/main/src/Vendr.Contrib.PaymentProviders.Nets/Easy/NetsEasyOneTimePaymentProvider.cs#L425

    But you should be able the Authorization in the request: https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/v1/main/src/Vendr.Contrib.PaymentProviders.Nets/Easy/Api/NetsEasyClient.cs#L75

    https://github.com/vendrcontrib/vendr-payment-provider-nets/blob/f5542a1fda2d2a08159b8bdf72b3f84f121a1ae1/src/Vendr.Contrib.PaymentProviders.Nets/Easy/NetsEasyOneTimePaymentProvider.cs#L714

    If you have the site running on local environment, you could try with same settings and product(s) and go through checkout (just to last step where it request a payment and generate a payment link): https://developers.nets.eu/nets-easy/en-EU/api/payment-v1/#v1-payments-post

    or via Postman.

    I think it should give a more detailed error message in response.

  • Bo Jacobsen 503 posts 2013 karma points
    1 week ago
    Bo Jacobsen
    0

    Hi Bjarne.

    In DEBUG mode it gives us the exact same error's. So we tryed with POSTMAN using Interceptor, but we could not intercept the api call. So now we gonna try to replica the data and see if we get a more detailed error message.

    I am just baffled that NETS/DIBS have no intention on tryin to solve this issue.

  • Bo Jacobsen 503 posts 2013 karma points
    1 week ago
    Bo Jacobsen
    0

    Hi Bjarne.

    We found the issue.

    We was able to intercept the api call with Fiddler and see the whole 401 (Unauthorized) reponse with headers and everything. The whole 401 (Unauthorized) response is exactly what is logged in the first place.

    But we noticed that the Secret Key provided in the Authorization header was missing the first letter. We have then tried to replace the key and insert the live-checkout-key- infront of it. But it still removing the first letter from the Secret Key.

    So i will create a bug report here https://github.com/vendrcontrib/vendr-payment-provider-nets/issues

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    1 week ago
    Bjarne Fyrstenborg
    0

    Hi Bo

    Great you was able to narrow down the problem. Does the secret key coincidentally contain any of the following charcters: live-secret-key-?

    I think it may replace/trim one character at the time from start of the string.

    It surprises me that Nets Easy doesn't allow you to generate new keys, which most other payment gateways do.

  • Bo Jacobsen 503 posts 2013 karma points
    1 week ago
    Bo Jacobsen
    0

    Yes, the key starts with 'c', so it will trim it away.

    I made a issue on github :)

  • Bjarne Fyrstenborg 1236 posts 3664 karma points MVP 5x c-trib
    1 week ago
    Bjarne Fyrstenborg
    100

    Hi Bo

    v1.0.1 has now been released on NuGet, which fixes this issue: https://www.nuget.org/packages/Vendr.Contrib.PaymentProviders.Nets/

  • Bo Jacobsen 503 posts 2013 karma points
    1 week ago
    Bo Jacobsen
    0

    For some reason nuget does not show any available updates for Vendr.Contrib.PaymentProviders.Nets in my Visual Studio.

    So for other's who might encounter this problem, use Update-Package Vendr.Contrib.PaymentProviders.Nets -Version 1.0.1 in your Package Manager Console.

Please Sign in or register to post replies

Write your reply to:

Draft