Order Not Cancelled automatically after Payment declined in MangoPay

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268138

-- HikaShop version -- : 3.0.1
-- Joomla version -- : 3.6.5
-- PHP version -- : 5.6

Hi there,

I'm opening a new thread as suggested by Jerome in this thread:
www.hikashop.com/forum/22-market-bug-rep...erly-redirected.html

I'm using the MangoPay Payment plugin as per HikaMarket 1.7.3 and when MangoPay declines the card or the user cancells the transaction the Hikashop order is not automatically cancelled and notifications are not sent to the user nor to the Vendor.

Initially there was a problem in the MangoPay plugin with the redirection after the transaction was cancelled but Jerome managed to fix that as per the forum thread previously referenced.

Jerome thinks the problem with the order not getting cancelled may be in Hikashop.

My Settings in teh MagoPay payment method are:
Cancel URL: /index.php?option=com_content&view=article&id=15
Return URL: BLANK
Invalid Status: cancelled
pending status: created
verified status: confirmed

Thanks!

Last edit: 7 years 6 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 6 months ago #268143

Hi,

I'm thinking that the problem comes from the way the order statuses are configured in the menu System>Order statuses on your website.
Could you provide a screenshot of that listing so that we can see what you have there ?

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268208

Hi,

Please find attached the requested screen-shot.

On that screen, I tried to make the "created" status "cancellable" which helped since now the order status is now automatically changed to Cancelled when the MangoPay Payment is declined or cancell.

That's great, but still there are issues with the notifications. Only the HikaMarket Vendor gets notified about the order status change to cancelled. The buyer and the store admin do NOT get email notification about the order status change to Cancelled.

Is there any other setting that needs to be changed?

Thanks!

Attachments:
Last edit: 7 years 6 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 4747
  • Thank you received: 644
  • MODERATOR
7 years 6 months ago #268224

Hello,

Can you provide a complete screenshot of your email listing, in Components => HikaSHop => Configuration, then in System => Emails, please.
And add as well your Mangopay plugin specific configuration screenshot.

Awaiting news from you.

Regards

Last edit: 7 years 6 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268289

Hi Philip,

Please find attached the screenshots you requested.

Please note that when the order is confirmed all the email notifications are sent correctly. When the order is cancelled from the back end and the option "notify customer" is selected also all the email notifications are sent correctly.

Only the user and the web admin notifications are failing when the order is automatically cancelled from the front end after payment cancelled or declined by the MangoPay Gateway.

If instead of MangoPay I try with Stripe, then when the order is cancelled or declined by Stripe all the email notifications are sent OK.

Thanks!

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 6 months ago #268295

Hi,

It's normal that the customer is not notified automatically. When the payment is invalid, it's usually because the credit card he entered is invalid and the payment gateway already notified him of the problem. Since it's his action which triggered that, there is no notification. Like when you change the status of an order in the backend, you can notify the customer, but not yourself.

Regarding the notification to you after the order is cancelled, there is no notification by default either since what you usually want is to be notified of paid orders, not the others. It would be possible to change that by adding the parameter email=1 to the cancel URL of the payment plugin. So it would require modifying one line of the mangopay payment plugin of HikaMarket to do it.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268351

Hi Nicolas,

Thank you for your input. What you say may make sense for other Payment Gateways but I’m afraid it is not applicable to the MangoPay Payment Gateway which is the scenario I’m dealing with.

First let me explain how the payment process works when using MangoPay. After the user completes the checkout process and clicks “finish”, he is redirected to the MangoPay Payment Gateway page where the user only sees the amount he is about to pay and the only inputs are the credit card number, expiry date and CVV code (please see the attachment). At that point the order is created and the user has been notified via email. Then he enters his CC details in the MangoPay page and once the user clicks “validate”, if the CC number is correct he is ALWAYS redirected back to the store. But that does NOT mean the payment was accepted, the bank may reject the payment which happens a lot (you can test this by using CC 4706750000000009 together with CVV 999 ). So it is up to us to provide visual validation about what has happened since MangoPay does NOT provide any feedback to the user about the transaction.

If the payment is accepted the user is redirected back to the “checkout→ after_end” view where we show a message saying payment was accepted. The order gets changed to confirmed and the user gets another email saying the order is confirmed. That’s great.

However, if the payment is declined he is redirected back to the shopping cart and no message whatsoever shows. So the user has no clue what has happened with the payment. In addition, the order stays as created (he does not know about Hikashop and HikaShop order statuses) and he has received a nice email saying your order is created and showing the content of the shopping cart. So there are a lot of possibilities he thinks everything went well when in fact it did not.

If you think about the Payment process when using your Stripe Payment Plugin, you will realise it is very similar to what I have described. After finishing the checkout process the user is also presented with a very small form (instead of being redirected to the MangPay form the Stripe form is embeded in the website) where he can only input his credit card details (see attached) and when submitting the CC form then he is either redirected back to the “checkout→ after_end” view if it is successful or to the shopping cart if it is not.

But there are three big differences in what happens when the bank declines the payment and the user is Paying via Stripe (you can test it with card number 4000000000000002):

A) When the user is redirected back to the shopping cart there is a Joomla Jerror message saying “your card was declined” .
B ) The order status is automatically changed to CANCELLED (even if the CREATED status is NOT Cancellable in system→order statuses)
C) The user gets a second email saying your order is cancelled

So it is very obvious for the User his order did not go through when using Stripe. And it should be the same way if using MangoPay instead, but unfortunately as it works today it does not support A), B ) nor C), which is very disappointing.

The workarounds I have so far are not so great:

A) I can use the “cancel URL” parameter in the MangoPay Payment plugin to redirect the user to a menu item with an article showing a message that the transaction was not successful. This is not so bad but it is not as elegant as showing a Jerror message in the shopping cart saying your transaction was declined. This way the user is already in the shopping cart and he can try immediately with another card. By having the user in a different Menu Item I then need to suggest him to go back to the shopping cart which is an extra step.

B ) To get the order status automatically changed to CANCELLED I need to go to system→ order statuses and make the CREATED status Cancellable. This is NOT great because now users get a button in their order history to cancel their orders in CREATED status and I don’t want that. The stripe plugin cancels the order even if the CREATED Status is NOT Cancellable.

C) For the user to get notified about his order being cancelled you’re suggesting to add a parameter (email=1) in the MangoPay plugin. In which file? In which line? Will this be applied to the new versions moving forward? Or are you suggesting a core hack?

I really hope you can get declined Payments to behave the same for Stripe and MangoPay since it is perfect how it works for Stripe and I think it should behave the same way for A), B ) and C) when MangoPay is used.

Many thanks!

Attachments:
Last edit: 7 years 6 months ago by sabroso.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 6 months ago #268362

Hi,

Thank you for your explanations.
Stripe is kind of special as the plugin gets notified of the cancellation in the payment notification through Stripe javascript on the browser. So it's a mix of a server to server notification and a redirection of the customer. So it actually doesn't work like most payment plugins we have due to the way the integration has to be done.

If you don't want that cancel button on the orders listing, then you can edit the file "listing" of the view "order" to remove it.
Otherwise, it would require modifying the MangoPay plugin to change the order status directly in the plugin, but that's not something I can do. I'm offering an alternative here.

The modification I proposed for MangoPay is to be added in plugins/hikashoppayment/mangopay/mangopay.php on this line:
$cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $dbOrder->order_id . $this->url_itemid;
It is a core hack. If you want to have that included, for example with an extra option in the plugin, that's something to debate with Jerome on the HikaMarket forum as MangoPay is a plugin from HikaMarket.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268405

Thanks Nicolas,

OK understood, I will not insist more with the Stripe Plugin :)

OK, A) and B ) are sorted since I can live with configuring the Cancell URL in the Plugin and using a Menu Item to show the message. I can also do the view override to get rid of the cancel order button.

However C) is still not completely working. I tested your proposed solution and it does not do anything. Then I tried to add the parameter "&email=1" to the $redirect_url instead of the $cancel_url URL as you suggested, and that helped since now the store admin gets notified of the order being cancelled. So the Vendor and the Store admin get notified of the order cancellation but, the buyer/user still is NOT notified of the cancellation and he is the most important part (he only receives the order creation email).

How can we get the user to receive an email notification as well about his order being cancelled?

Many thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
7 years 6 months ago #268412

Hi,

Well, I don't have a solution for that in HikaShop. The code modif
That would require to change the order status with a call to modifyOrder before the redirection to the cancel_url in the MangoPay payment plugin by adding the code:

elseif(isset($payIn->Status) && $payIn->Status == 'FAILED') {
$order_status = $this->payment_params->invlaid_status;
$history = new stdClass();
$history->notified = 0;
$history->data = 'MangoPay Secure Return: '.$payIn->Status;
$this->modifyOrder($order_id, $order_status, $history, true);
}
before the line:
if(empty($this->app))
in the MangoPay plugin

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268534

Hi Nicolas,

That is brilliant! That's exactly the code that was missing from the plugin. Now the order gets cancelled automatically and everybody gets notified.

I fixed a small typo and enabled the customer notification, so the code is

	elseif(isset($payIn->Status) && $payIn->Status == 'FAILED') {
			$order_status = $this->payment_params->invalid_status;
			$history = new stdClass();
			$history->notified = 1;
			$history->data = 'MangoPay Secure Return: '.$payIn->Status;
			$this->modifyOrder($order_id, $order_status, $history, true);
		}

I will let Jerome know because this patch should be applied to the MangoPay payment plugin moving forward

Thanks a million!!

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 6 months ago #268535

Hello,

When I provided the patch to Nicolas, I choose to not notify the customer by email because he should already know that the transaction has failed ; so there is no need to "spam" him for that ! (and that's the same logical as the other HikaShop payment plugins).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 128
  • Thank you received: 2
7 years 6 months ago #268694

Hi Jerome, that's a great patch! Thank you very much.

In my view the customer needs to be notified since it is very important that it is crystal clear to him that the order is cancelled. It also gives us the possibility add a message in the notification saying that if he still wants the products he needs to place a new order.

The Stripe plugin does that very well since it notifies the customer that his order has been cancelled once the credit card is declined.

Will this patch be part of future version of the MangoPay payment plugin?

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum