- Posts: 53
- Thank you received: 1
empty cart after payment done
5 years 2 months ago #334766
by matmosis
empty cart after payment done was created by matmosis
-- HikaShop version -- : 4.4.3
-- Joomla version -- : 3.9.27
-- PHP version -- : 7.3.28
-- Browser(s) name and version -- : Chrome 90.0.4430.212
Hello,
we built a custom payment plugin than send the products list (json format) to a homemade backend.
Backend send back to custom payment plugin the bank gateway url, and payment plugin redirect the browser.
Customer pay, bank gateway send S2S notification to our backend than send a S2S notification to custom payment plugin that receive notification by onPaymentNotification().
if we are here payment is OK for sure! So only here we want to empty customer cart.
Is it possible?
We look at hikashop_get('class.cart')->cleanCartFromSession(); but the onPaymentNotification() is called on a S2S notification, not in browser so no session at all.
Is there another way to achive this? or a standard way to do that
Thank you
-- Joomla version -- : 3.9.27
-- PHP version -- : 7.3.28
-- Browser(s) name and version -- : Chrome 90.0.4430.212
Hello,
we built a custom payment plugin than send the products list (json format) to a homemade backend.
Backend send back to custom payment plugin the bank gateway url, and payment plugin redirect the browser.
Customer pay, bank gateway send S2S notification to our backend than send a S2S notification to custom payment plugin that receive notification by onPaymentNotification().
if we are here payment is OK for sure! So only here we want to empty customer cart.
Is it possible?
We look at hikashop_get('class.cart')->cleanCartFromSession(); but the onPaymentNotification() is called on a S2S notification, not in browser so no session at all.
Is there another way to achive this? or a standard way to do that
Thank you
Please Log in or Create an account to join the conversation.
Less
More
- Posts: 12953
- Thank you received: 1778
5 years 2 months ago #334771
by Mohamed Thelji
Replied by Mohamed Thelji on topic empty cart after payment done
Hello,
In your case, the best solution will be to use the "Clean cart when order is" option via "Hikashop->System->Configuration->Main->Cart tab", and set it to "Created".
Kind regards,
Mohamed.
if we are here payment is OK for sure! So only here we want to empty customer cart.
Is it possible?
In your case, the best solution will be to use the "Clean cart when order is" option via "Hikashop->System->Configuration->Main->Cart tab", and set it to "Created".
Kind regards,
Mohamed.
Please Log in or Create an account to join the conversation.
5 years 2 months ago #334779
by matmosis
Replied by matmosis on topic empty cart after payment done
yes but in that case if customer during payment process decide to abort, or the payment fails for any reason, he have to start it all over again and put products on cart again.
We would like to avoid this to encourage the customer to continue with the purchase, like on Amazon, the cart is emptied only if the payment is successful.
Any other idea?
Thank for your kind support
We would like to avoid this to encourage the customer to continue with the purchase, like on Amazon, the cart is emptied only if the payment is successful.
Any other idea?
Thank for your kind support
Please Log in or Create an account to join the conversation.
5 years 2 months ago #334780
by nicolas
Replied by nicolas on topic empty cart after payment done
Hi,
Normally, when you send the data of the order to the payment gateway to get the redirect URL to the payment form page, or when you actually do the redirection to the payment form page of the payment gateway, you have a parameter where you can specify the "return URL" for the customer when the payment is successful.
There, you want to provide the "after_end" URL of HikaShop. That will automatically clear the cart of the customer when he gets back to your website.
The after_end URL can be generated like that:
Alternatively, if you really what to clear the cart in the onPaymentNotification function, you can directly delete the cart from the hikashop_cart and hikashop_cart_product tables in the database based on the user_id of the user linked to the order. However, if the customer has multiple carts (possible with the "Enable multi carts" setting activated), the customer could have several carts. So you won't be 100% sure that you're deleting the cart corresponding to the order unless you check the products of the cart against the products in the order.
Normally, when you send the data of the order to the payment gateway to get the redirect URL to the payment form page, or when you actually do the redirection to the payment form page of the payment gateway, you have a parameter where you can specify the "return URL" for the customer when the payment is successful.
There, you want to provide the "after_end" URL of HikaShop. That will automatically clear the cart of the customer when he gets back to your website.
The after_end URL can be generated like that:
Code:
$return_url = HIKASHOP_LIVE."index.php?option=com_hikashop&ctrl=checkout&task=after_end";
Alternatively, if you really what to clear the cart in the onPaymentNotification function, you can directly delete the cart from the hikashop_cart and hikashop_cart_product tables in the database based on the user_id of the user linked to the order. However, if the customer has multiple carts (possible with the "Enable multi carts" setting activated), the customer could have several carts. So you won't be 100% sure that you're deleting the cart corresponding to the order unless you check the products of the cart against the products in the order.
Please Log in or Create an account to join the conversation.
5 years 2 months ago #334804
by matmosis
Replied by matmosis on topic empty cart after payment done
Hi,
i think we will go with onPaymentNotification() solution, we do not use multiple carts so is a good solution.
Thank you
i think we will go with onPaymentNotification() solution, we do not use multiple carts so is a good solution.
Thank you
Please Log in or Create an account to join the conversation.
Time to create page: 0.220 seconds