Developer forum

Forum » Development » Payment provider server notification handling

Payment provider server notification handling

Antek Drzewiecki
Reply

Hi there,

We recently build our own payment provider handler. The payment provider has two feeback methods, one trough user redirect and the other trough server notifications. We are currently having issues handling the the server notifications.

The user can redirect with a success, cancel or error status, all being handled by the front-end. Upon cancel or errors, the order will get downgraded to a cart so the user can attempt a new checkout or change the bank credentials. The flow is illustrated as `CART1 (User) -> checkout -> ORDER1 (User) -> Cancel / failure -> CART2 (User)`.

Now the payment server will mostly send notifications back to the server, because there might be an internal server problem or the user never got redirected back to the website because of inactivity or timeouts. We wish to handle these orders properly. So when a server notification is received with success, you set the order as payed. When receiving a cancel or error message we downgrade it to a cart and log the message. So the flow in time can look like: `CART1 (User) -> checkout -> ORDER1 (User) -> Cancel / failure -> CART2 (User) -> Cancel / failure (notificatio) -> CART3 (Notification)` or even worst when the notification is received before the user redirect `CART1 (User) -> checkout -> ORDER1 (User) -> Cancel / failure (notification) -> CART2 (Notification) -> Cancel / failure -> CART3 (User) `. In most cases when the server notification comes first the custom fields are not transfered from order to cart and a new cart is created while the cart allready exist, leaving the internal DynamicWeb system in a state it can't recover from (Duplicate orderlines, missing orderlines, missing customfields.)

Having that said, making a payment provider isn't that trivial, I have still the following questions:

  • How should you idealy handle (async) payment server notifications in DynamicWeb?
  • Is there any way in the API to check if the order has allready been downgraded to a cart and to set that cart in the context? This could be useful for ignoring server notifications when a user was redirected first.

Replies

 
Nicolai Pedersen
Reply

Hi Antek

No, checkouthandlers are not always fun - lots of things to take into consideration.

Most of what you describe we handle in our checkouthandlers and in the checkout flow in Dynamicweb.

Please find attached the source code for all our implementations.

Take a look at Altapay, DIBS or Quickpay. I believe they are the most comprehensive.

BR Nicolai

 
Antek Drzewiecki
Reply

Thanks Nicolai! Ill take a look on the actual checkout handlers and see how its done there.

 

You must be logged in to post in the forum