Developer forum

Forum » Ecommerce - Standard features » PayPal notification based on capture status

PayPal notification based on capture status

Adrian Ursu
Reply

Hi Guys,

I need to send the order notification to the Shop admins only after the Capture message is returned from PayPal.

Now I see I can only send the email notification on Receipt page or based on Order Status. But the Order Status (Completed) is not connected to the Capture status.
Any ideeas?

Is there any notification we can connect to?

Thanks,
Adrian


Replies

 
Nicolai Høeg Pedersen
Reply

You can use the Notifications.eCommerce.Order.GatewayStatusChanged notification subscriber.

BR Nicolai

 
Adrian Ursu
Reply

Hi Nicolai, Thank you for your reply.

Is there any implementation scenario that will trigger the PayPal payment in the checkout process before the order is submitted?

Like a payment Order step? This could prevent an order being submitted without a valid payment.

I have seen this behavior on several shops when you decide to pay with PayPal, you go to PayPal website and after the payment confirmation you are taken back to the receipt page.

In our case the receipt page and the redirection to PayPal seem to happen at the same time.

Thank you,
Adrian

 

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

In Dynamicweb you configure the cart steps - there is only one required step called checkout - that is handled by a checkout handler and is the step that changes the cart to an order. Checkouthandlers are started and when they are done and say checkdone is ok, it converts to and order (i.e. the default which does nothing except convert the cart to an order). When you use Paypal, it is a checkout handler that, when returning OK, converts the cart to an order.

So you should not see both the Paypal and the receipt at the same time - then your configuration is broken.

On our test setup it works exactly like that.

BR Nicolai

 
Adrian Ursu
Reply

In the backend I can see New Order with the payment status "Not captured".

And the notification to the admins is set on the Cart module as "Notification".

As far as I know, the notification is sent after the order is created and not after we get a success from PayPal.

I cannot exclude the case where we have set it up wrongly. That's why I am asking about a recommended way to set it up.

Thanks,

Adrian

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

Maybe I do not understand what the issue is.

This is the normal flow of a cart:

  1. step (Show cart)
  2. step (Customer info)
  3. checkout (i.e. Paypal) - at this step we get an Authorisation for the payment
    1. Callback from gateway (This is where the receipt mail and notification mails are sent - this is also where the cart is converted to an order)
  4. Receipt

Now we have a new order in the backend.

The admin can now choose to Capture the payment when the order is sent.

So, what are you trying to accomplish - or what does not work in these steps?

 
Adrian Ursu
Reply

Well, we are using the IPN from PayPal.

This means that the capture is automatic. Maybe that's where the trouble is.
The steps are configured exactly as in your example.

The customer complains that they are notified for all orders and not just for those orders with Capture status= Success.

That's my challenge

Adrian

 
Nicolai Høeg Pedersen
Reply

So they get notified for orders that are not completed?

 
Adrian Ursu
Reply

Yes. They get emails for order that have the capture state "Not captured"

 
Nicolai Høeg Pedersen
Reply

Is the order completed or not? - captured is another thing...

Could you give me a dump of one such order? What does Paypal admin say about that payment? Why did Paypal not capture it? Did it get authorized?

 
Nicolai Høeg Pedersen
Reply

And also the order log for one such order please.

 
Adrian Ursu
Reply

The order is completed.The customer only complains about the notification.
I will send you the files but I don't have access to their PayPal account

 
Nicolai Høeg Pedersen
Reply

Hi Adrian

If the order is completed, it must be something happening in the PayPal - I'm affraid I cannot do anything about it. My guess is there is some reason why it does not get captured, but only authorized.

BR Nicolai

 
Adrian Ursu
Reply

Hi Nicolai,

It looks like in the checkout provider for PayPalExpress there is no setting for GatewayPaymentStatus and that's why the GatewayStatusChanged notification is not ativated.

Do you have any other ideeas?

Thanks,

Adrian

 
Adrian Ursu
Reply

I did more digging and could not find anything.

I have checked the "Keep cart in context after checkout step" option hoping that the cart will not be converted to order.

It is still converted. It doesn't have anything to do with PayPal. If you want to submit the order, the system directs you to PayPal but it doesn't matter what you do after that. 

In my test I have chosen to close the window (that's to exclude any PayPal dependency). The cart was already transformed into order as soon as I have left the checkout.

The OrderID I have found in the system is Order 406. But in the logs I could only find ORDER404.

Here is a dump from /System/Log/eCom/CheckoutHandler/Dynamicweb.eCommerce.Cart.CheckoutHandlers.PayPalExpressCheckout/Events :

[12/9/2015 4:19:21 PM]:    Order ORDER404: State accepted
[12/9/2015 4:19:37 PM]:    Order ORDER404: State notification
[12/9/2015 4:19:39 PM]:    Order ORDER404: Order is kept in context - upgrading to order
[12/9/2015 4:19:47 PM]:    Order ORDER404: Order was upgraded successfully
[12/9/2015 4:19:48 PM]:    Order ORDER404: Payment succeeded.
[12/9/2015 4:19:49 PM]:    Order ORDER404: Correlation id: b2f2d97c1eddb.

And another one from /System/Log/eCom/Order:

[12/9/2015 4:19:25 PM]:    save Order problem. Invalid state, saving: ORDER404
[12/9/2015 4:19:25 PM]:    stack trace:    at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
   at System.Environment.get_StackTrace()
   at Dynamicweb.eCommerce.Orders.Order.SaveOrder(String IDStr, Boolean saveOldVersion)
   at Dynamicweb.eCommerce.Orders.Order.Save(String IDStr, Boolean saveOldVersion)
   at Dynamicweb.eCommerce.Cart.CheckoutHandlers.PayPalExpressCheckout.OnAccept(Order order, String token)
   at Dynamicweb.eCommerce.Cart.CheckoutHandlers.PayPalExpressCheckout.Redirect(Order order)
   at Dynamicweb.eCommerce.Cart.CheckoutHandler.RedirectToCheckoutHandler()
   at Dynamicweb.eCommerce.Cart.Frontend.GetContent()
   at Dynamicweb.Frontend.Content.GetModule(DataRow& ParagraphRow)
   at Dynamicweb.Frontend.Content.WriteParagraph(ParagraphTemplateJoinClass PtRecord)
   at Dynamicweb.Frontend.Content.CreateLayoutContent(ParagraphTemplateJoinClass PtRecord)
   at Dynamicweb.Frontend.Content.CreateContentEXE()
   at Dynamicweb.Frontend.Content.CreateContent(Int32 pageId)
   at Dynamicweb.Frontend.Content.GetContent(Int32 pageId)
   at Dynamicweb.Frontend.PageView.SetPageTemplateValues()
   at Dynamicweb.Frontend.PageView.Output()
   at Dynamicweb.Frontend.PageviewControl.ParseControls()
   at Dynamicweb.Frontend.PageviewControl.OnInit(EventArgs e)
   at System.Web.UI.Control.InitRecursive(Control namingContainer)
   at System.Web.UI.Control.AddedControl(Control control, Int32 index)
   at System.Web.UI.ControlCollection.Add(Control child)
   at Dynamicweb.Admin.DefaultAspx.Page_Load(Object sender, EventArgs e)
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
   at System.Web.UI.Page.ProcessRequest(HttpContext context)
   at ASP.default_aspx.ProcessRequest(HttpContext context)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
   at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
   at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
   at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
   at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
   at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

 

 

 
Nicolai Høeg Pedersen
Reply

ok. Not an easy one.

Before DW sends the cart to the checkouthandler, it changes the cart to an order with an order number (the payment gateway needs the order number), and when the checkout handler returns, it sets the completed state to true if everything went fine.

The receipt is not sent until the order is completed. If that happens, something is wrong. Can you reproduce it and make a screencast?

BR Nicolai

 

You must be logged in to post in the forum