Developer forum

Forum » Development » NETS payments integration issue

NETS payments integration issue

Karol Barkowski
Reply

Hi,

I am trying to integrate NETS/DIBS Easy payments in DW 9. During the checkout i got an error from DibsEasyCheckout:

En feil har oppstått
**Payment request failed with following errors: { "notifications.WebHooks[0].Url": [ "Field is not accepted as a valid URL" ] }**

 

Do someone know why this error appears and what could cause it ? Is it something form our side or NETS ?
Stack trace from logs:
 
-------: Unhandled exception with message: Payment request failed with following errors: {   "notifications.WebHooks[0].Url": [
 "Field is not accepted as a valid URL"   ] }. System.Exception: Payment request failed with following errors: {   "notifications.WebHooks[0].Url": [
 "Field is not accepted as a valid URL"   ] }
at Dynamicweb.Ecommerce.CheckoutHandlers.DibsEasyCheckout.DibsEasyCheckout.ExecuteRequest(WebRequest request)
at Dynamicweb.Ecommerce.CheckoutHandlers.DibsEasyCheckout.DibsEasyCheckout.ExecutePostRequest(String function, Object body, String method)
at Dynamicweb.Ecommerce.CheckoutHandlers.DibsEasyCheckout.DibsEasyCheckout.RenderPaymentForm(Order order, Template formTemplate)
2024-07-04 08:49:48.140: Request headers: [   "Cache-Control",   "Connection",   "Content-Length",   "Content-Type",   "Accept",   "Accept-Encoding",   "Accept-Language",   "Cookie",   "Host",   "Referer",   "User-Agent",   "Upgrade-Insecure-Requests",   "Origin" ]
------: Request item keys: [   "IsWebServiceConnectionAvailable",   "owin.Environment",   {},   "PagePermissionWithInheritanceFrontend6765",   "Neros.LiveIntegration.ShopId",   "UserManagement.GetUserById.18324",   "MS_HttpRequestMessage",   "AspSession",   "PermissionContextStack",   "Neros.LiveIntegration.Settings",   "Dynamicweb.OMC.VisitorEngagementSettings.Config",   "Dynamicweb.OMC.VisitContext",   "Neros.LiveIntegration.Api.Logger",   "AspSessionIDManagerInitializeRequestCalled",   "EcomCart:CustomCartContext",   "alternateUrlKey",   "ExecutionTableMapper",   "PagePermissionWithInheritanceFrontend6861",   "DWPAGEVIEW",   "EcomCartDiscountsAndTaxesAreHandled",   "Dynamicweb.Environment.Web",   "Dynamicweb.Tracking.Tracker",   "IsLazyLoadingForProductInfoEnabled" ]
------: Request form: [   "QuantityOrderLineOL49693",   "CustomCustomerName",   "EcomOrderCustomerName",   "EcomOrderCustomerAddress",   "EcomOrderCustomerZip",   "EcomOrderCustomerCity",   "EcomOrderCustomerCountry",   "EcomOrderCustomerEmail",   "ShippingAddressSelector",   "EcomOrderDeliveryCompany",   "EcomOrderDeliveryName",   "EcomOrderDeliveryPhone",   "EcomOrderDeliveryEmail",   "EcomOrderDeliveryAddress",   "EcomOrderDeliveryZip",   "EcomOrderDeliveryCity",   "EcomOrderDeliveryCountry",   "EcomCartPaymethodId",   "EcomOrderSavedCardName",   "NotificatioOnParcel",   "PoNumber",   "CustomCustomerComment",   "EcomCartShippingmethodId",   "SHIP31_BringSelectedOptionId",   "EcomOrderCustomerAccepted",   "CartV2.GotoStep1" ]

Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Karol

Can you show the setup of the checkouthandler in DW and inside Nets easy?

The error indicates that the callback URL is missing or wrongly defined. It could be that you run locally and the calculated callback URL is like localhost:6000 which NETs would see as an invalid URL.

So a couple of screenshots of your setup would be nice.

BR Nicolai

 
Karol Barkowski
Reply

Hi,

It is running on stage.
The setup in handler look like that:

 

 

 


I am able tor prepare correct Postman call but here it seem like you said DW is not preparing Webhook url properly.
We don't have access to NETS easy setup. We only got required keys.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

The provider generates a URL based on the host you run locally. What host and port do you run locally?

Is it localhost:6000 or similar? That could be rejected by dibs as they will never be able to make a callback to a localhost.

What webhook URL do you add in the POSTMAN?

Also if you are running on a port different from 80 or 443, and the setting /Globalsettings/System/http/DisableBaseHrefPort is set to true, a port is not added to the callback URL passed to NETs. Not that I think that is the issue...

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

When you start the payment locally - have a look in your devtools, network tab, what is being sent to NETS

 
Karol Barkowski
Reply

Hi
I am not testing it locally because based on project specification we run application on stage env and on stage env we get this error.
The url on env looks similar to that: stg_env-stage.cloud.dynamicweb-cms.com
When I was testing it locally on postman, localhost url was accepted by DIBS. Sample call just bear in mind it is prepare for test:

{
 …..
 "notifications": {
    "webHooks": [
      {
        "eventName": "payment.created",
        "url": "https://localhost:7055/Callback",
        "authorization": "authorization_id",
        "headers": null
      }
    ]
 }

DisableBaseHrefPort is set to false

 
Karol Barkowski
Reply

Hi Nicolai


I think we found what is wrong, it silly thing but url is producing with http, not with https as staging don’t have ssl turn on.
I don’t know how we can achieve this yet.

But in meantime I have another question in url we have something like this:
http://ENV-stage.cloud.dynamicweb-cms.com/Default.aspx?ID=6861&CheckoutHandlerOrderID=ORDER1080&action=Approve&callback=true
Can you explain what that url meant?  because it is callback url so NETS will call under this with updates when specific event appears ? or is there something more ? and is there possibility to catch and interfere when this call will happened or maybe we shouldn’t do this ?

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Karol,

The url, as you point out, is meant for having NETS call back to DW with payment updates in the context of the checkout flow. You can intercept and log the request in you own middleware if you want, but you should not manipulate or block it as that most likely will interfere with the registration of payment updates. Be aware that if you log the request, specifically the body, you may run into GDPR issues.

Callback urls, specifically, are used to tell DW with the customer has completed, or has tried to complete, payment. Payment could have succeeded, payment could have been rejected due to suspicion of fraud, and so on. It's not used if you access the merchant account at NETS and make changes there.

Structurally, the url consists of three parts (not counting the scheme and domain): the path to the page where the cart app is located, an indicator to the cart app that the request should be handled by a checkout handler and, finally, the parameters needed by the checkout handler to determine which type of processing it needs to do. In addition, NETS sends information in the body of the request which is also read by the checkout handler. The first two are the same across checkout handlers but the parameters can vary.

There are other types of urls used by checkout handlers. Usually, they are OK and Cancel urls, but some checkout handlers have other urls as well. The OK url is used when the customer has completed payment and needs to be redirected back to the receipt. The Cancel url, as the name suggests, redirects the customer in case they cancel their payment.

I hope that clarifies the purpose and structure of the url, otherwise let me know.

- Jeppe

 
Karol Barkowski
Reply

Hi Jeppe

thanks for that explanation.
We hit another problem with inline form and maybe you know what could be a reason.
When I want to use inline form and I click pay:

It will redirect me to url like this:
Default.aspx?ID=6861&CheckoutHandlerOrderID=ORDER1136&action=Approve&paymentId=…

And this is throwing error:
En feil har oppstått
Object reference not set to an instance of an object.

I also assume that when I have an inline form set in the admin panel, the payment template will be rendered as one of the block of checkout page (one-page checkout). In our case, when we submit form, the next step should be the order summary. However, we are currently moving to the  payment template instead:

Do you think this might be connection with error during payment processing for inline form or maybe this is with something else?
We are using nuget for DW 9 and also older one .

 

 

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Karol,

I'm not too familiar with the intricacies of the Dibs Easy checkout handler, so I can't say for sure what the issue is. There are a couple of things you can check to see if it gives more insights.

Firstly, you can check the event log in Monitoring. The exception might have beed registered there, and in that case, you can get the stack trace. Otherwise, you can check the Order log. Go to the order screen in backend to see it.

It's very unlikely, but maybe the issue is that the order gets deleted or gets a new id after the link is generated but before the payment is submitted. You can check whether the order id in the url still exists and isn't marked as deleted. This can happen if the order is manipulated, e.g. in a different tab/window, after checkout was started.

If this doesn't help, you may have to create a support case wth Care (https://doc.dynamicweb.com/service-desk).

- Jeppe

 
Mateusz Struzik
Reply

Hi Jeppe 

I will take this from Karol here :). When we are using inline form the order is not complete successfuly, but payments are reserved correctly (checked using NETS api). In logs but in cart not order i can notice something like this : 

Order Getting order from Context.Cart: CART2809 (IsCart:True, UserID/name/secondaryid:18324/----/0, Complete:False), (IP:----, Url:/Default.aspx?ID=6788), Thread:10, HashCode:316760)

Order Setting shop id to SHOP1 from paragraph settings on page with id: 6788 (IsCart:True, UserID/name/secondaryid:18324/-----/0, Complete:False), (IP:------- Url:/Default.aspx?ID=6788), Thread:10, HashCode:316760)

Order Order is not complete, next step is the first step: 0 (IsCart:True, UserID/name/secondaryid:18324/-----/0, Complete:False), (IP:------, Url:/Default.aspx?ID=6788), Thread:10, HashCode:316760)

Order Order saved (IsCart:True, UserID/name/secondaryid:18324/-----/0, Complete:False), (IP:------, Url:/Default.aspx?ID=6788), Thread:10, HashCode:316760)


It seems order cannot be save when we are using inline form but i cant find why .
When we are not using inline form everything is ok

 

You must be logged in to post in the forum