Developer forum

Forum » Development » Checkout handler success redirect to receipt

Checkout handler success redirect to receipt

Andrew Rushworth
Reply

When I get success response back from payment gateway i do the following:

SetOrderComplete(order, reference);

SetSuccessful(order); //update the order status and amount

CheckoutDone(order);

But when this is complete, it goes to a  balnk page. Why does it not go to the Receipt page?

 

If i call RedirectToCart(), it goes to the receipt page, but it throws an error in the background because the cart is no longer availabe as its converted to an order.

I just want to show the receipt page after the order is complete.


Replies

 
Nicolai Pedersen
Reply

Hi Andrew

Can you share some more of your code? It makes it easier for us to see what could happen.

Also for your reference please find attached an example of one of our payment providers and how that code is executed.

Thanks, Nicolai

 
Andrew Rushworth
Reply

Hi Nicolai,

1. Set a transaction on the payment gatway and then redirect to the gateway

2. The user captures credit card details on the payment gateway and completes the transaction

3. payment gateway then redirects back DW with the reference number (attached Redirect)

4. DW then receives the reference number in teh Redirect method, calls the payment gateway to get the transaction details (success, fail, etc), and then I process the result (attached ProcessResponse.

5. If transaction is successful, I call:
5.1 SetOrderComplete
5.2 SetSuccessful
5.3 CheckoutDone

This then goes to an empty page (attached emptyPage).
If i call RedirectToCart, it goes to receipt page(attached ReceiptPage), but in the back end it causes error as cart context is no longer available

emptyPage.PNG ProcessResponse.PNG ReceiptPage.PNG Redirect.PNG
 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Andrew,

If I understand you correctly, you get a blank receipt page when you don't call RedirectToCart and you have a working flow where a receipt is shown if you call RedirectToCart. In the latter case however, you get an exception in the log.

Is that exception by any chance a ThreadAbortException? I have a sneaking suspicion that the error you're seeing in the backend is a ThreadAbortException that is caught by the Try-Catch in ProcessResponse. It logs it as an error and then throws it back to the Try-Catch block in Redirect which then handles it correctly.

The correct action is to call RedirectToCart once you want to show the receipt to the customer, so you can either move the RedirectToCart call to Redirect or you can handle ThreadAbortExceptions in ProcessResponse so solve the issue.

If it's not a ThreadAbortException, can you provide details about the exception, such as the stack trace or at least the name? Also, can you provide the version number of your Dynamicweb installation?

- Jeppe

 
Andrew Rushworth
Reply

I managed to string together a redirect url to go the receipt page.

LS Retail Integration

However it raises the same issue when uploading to environment that has live integration with LS Retail...so it might have been LS Retail integration causing issue.  The issue is as follows:
When calling SetOrderComplete(order), the system goes into an infinite loop and crashes the site.  I've attached an example of the log file highlighting when I called SetOrderComplete and then the loop of the same error. (I don't get this on my local environment without integration)

Order Order saved (IsCart:False, Complete:False), (IP:10.101.1.1, Url:/Default.aspx?ID=7590&CheckoutHandlerOrderID=ORDER883&PayU=Response&PayUReference=18430935437189), Thread:42, HashCode:2329722)
Dynamicweb.Ecommerce.Common.Context The Context.GetCart() is not a cart and cannot be updated. (Order.IsCart = False, Order.Complete = False, Order.AutoId = 225, SessionCartKey = EcomCart)
log.PNG
 
Andrew Rushworth
Reply

Thanks Jeppe, it indeed is Thread Abort Exception. 

I have added in a handler for the to the ProcessResponse to resolve that - makes sense.

 

I now get an enless loop on the production environment though where it loops errors on SetOrderComplete when Live integration to LS Retail is configured.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Andrew,
could you look and share the LS Retail log for that order?
It is usually located in the: Files\System\Log\LiveIntegration folder.
Kind regards, Dmitrij

 
Andrew Rushworth
Reply

Hi Dmitriy.

Attached is ORDER883, it has the same problem.  When this happens, the iis process dies and the site gives 520 error, until you clear cookies.
Apprecaite any assistance.

Regards,
Andrew

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Andrew,
it looks like you have some custom code that causing the order save event that breaks the order so it can not be processed correctly inside 
Dynamicweb.Ecommerce.Cart.CheckoutHandler SetOrderComplete method:



Could you check in all your custom codes if you do not have the BeforeUpdateCartToOrder subscriber that can call order save?
Also what Dynamicweb version are you using?
And it looks like you have some custom written LS Retail module so I can not fully investigate it.

Kind regards, Dmitrij

 
Andrew Rushworth
Reply

Thanks Dmitrij.  There are other people doing the integration so will check with them and get back to you.

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

We have the same issue, RedirectToCart throws an ThreadAbortException, and the custoemr is never sent to the receipt page.
Did you find out anything?

 
Nicolai Pedersen
Reply

ThreadAbortException is always thrown by redirects, so nothing odd there.

Do you have a custom checkouthandler, and can you show us your code bit?

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

Yes, custom checkouthandler. Code is sent by email.

Is it also normal that "SetOrderComplete(order, paymentId)" trigger "public override string Redirect(Order order)"?

 

You must be logged in to post in the forum