Return URL error

  • Posts: 22
  • Thank you received: 1
9 months 6 days ago #353635

-- url of the page with the problem -- : www.vividhifi.com
-- HikaShop version -- : 4.7.2 Business Edition
-- Joomla version -- : 4.3.3
-- PHP version -- : 8.1.21

-- url of the page with the problem -- : www.vividhifi.com
-- HikaShop version -- : 4.7.2 Business Edition
-- Joomla version -- : 4.3.3
-- PHP version -- : 8.1.21

Hi I am making a payment plugin for CC Avenue. I am modifying the example plugin. I am able to make the payment at the gateway but am unable to receive the response from the gateway into the onPaymentNotification(&$statuses) function

The company has provided a PHP integration kit that has 3 files
1. Request handler (sends the encrypted payment request to the gateway)
2. Response handler (receives decrypted response from gateway)
3. Crypto file for encryption/decryption

I have been able to modify the example.php file to send the proper request to the gateway, but cannot read the gateway response into the onPaymentNotification(&$statuses) function

I have tried the following 2 return URLs

$return_url = urlencode(HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$order_id.$this->url_itemid);
$return_url = urlencode(HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=notify¬if_payment=hdfc_ccavenue&tmpl=component&lang=EN&order_id='.$order_id.$this->url_itemid);

Both result in a blank page

The encrypted response I get from the gateway is something like this

encResp: a66f9ed977ec2b4a46ef412a180b0f5583afbe7a4db482f37369a2fb68e0ae78b119411a3b11e76535722f8182875213f0145f2ffd6fec56eccec876ea19f0c39bae9f189da5e725fe86f72d4b621ca9e07d30f104bea489b06aa65c501161ac6a188d2aaa24946374bb36f1b780ad60e33188132df818b0054eded3809700f83a7f687b7a402410ff610bab10f8b52286584c46cb8d6ab912abdd2f9ecbc59ca5799a6854489eabd810cc0089a02ab2e6a5188665ca7e421f91c0af04a810a7153880869578b783b4b10a9ccab376e53348f6383e764e05f6b53c6ca77ad4fe778077b06cf82b9e000a00720279d1bdcd48e71a453ba1a160e7e976d41ded68b265adadda42deaed1e212051c72ffd79337b0d5aff02e06c014b7b102e9f27c9447e06be65dbf8b061d3ea651e8648aea5b26a7064f69781c9d3033866baa2515be47329f78bacbe6af740220c0ec8364dafdad210b145b8904895d2c827398ab368c19ea44b5a95f154f752e1875f067d87961aff858b4b8e84bd414912f4f5b6e986568bd245c54a5618c43c5f7e927267d18f16b405560add7328880ad1c234b0f384c1b960f9687761573592475590acb10a33d4aa08b84e9c389eb6fab0828ef4a7f63a870aa3e43e267e3a58da57b749d41df8d82e6c49779ba5e9ff0acbff436fc72dd8dd1b5cc77acd374506ddb06b83236efe374aea3676516f902316d79e769dd45c01181c28b5f92482b82e265032d8929e59a38b5c577e753b3229bfd2d608ac0ecdbe8910f1e6c495a4d7e4cb79f0a7ff73321d3d46812826a9cfdb1ed2d6ce93afcbdcadc8d0d0238415728b86e4702b72ea0d3bbd7d24a7577b9d578487e040cc6e218e4e7ec0730819a6b9ed72cd1f5697507286d7fd38a035273e2e25207f0ff1a32dd2be67697b09afb7c06adb15c0045831daf516b1b774d50f5c7fba3432f4317917b57138b92c082650aba95e63dd75ccc0a9bba9071389fae6a52897f732576130a52e13d121ce3b9cf1955cc8147d31d593de6613eb6dafa270cb42e8d454dd6c3e076d16ae563cb03606007a7af20be1dd4e7ba44cf4b99423174a4c2f33f9632d92045ff429b1004985009fa2671bc7b9b162b54657b75c76b0c896f4cc11992312373150e8343f58dc5ff77bc80ee850038e1bfe275fec4a33041d04bf8ada8aaff1778503b3c378b0c7ff36a0ae5348a62c20259a96ce707b377ccd7f1796e2867eaa486b7709ce1b960b01cb10d8baceeaa8096a58c2e3a820496abb08a8eab359ee113d2ad0cd2058374e8d0e37269525e1a77bb28af42b1576

And the response after decryption is something like this

order_id=123654789&tracking_id=311008298114&bank_ref_no=1652448720867&order_status=Success&failure_message=&payment_mode=Net Banking&card_name=AvenuesTest&status_code=null&status_message=Y¤cy=INR&amount=1.00&billing_name=Charli&billing_address=Room no 1101, near Railway station Ambad&billing_city=Indore&billing_state=MP&billing_zip=425001&billing_country=India&billing_tel=9876543210&billing_email=test@test.com&delivery_name=Chaplin&delivery_address=room no.701 near bus stand&delivery_city=Hyderabad&delivery_state=Andhra&delivery_zip=425001&delivery_country=India&delivery_tel=9876543210&merchant_param1=additional Info&merchant_param2=additional Info&merchant_param3=additional Info&merchant_param4=additional Info&merchant_param5=additional Info&vault=N&offer_type=null&offer_code=null&discount_value=0.0&mer_amount=1.00&eci_value=null&retry=N&response_code=0&billing_notes=&trans_date=13/05/2022 19:04:51&bin_country=

My question is how to receive and read the gateway response into the plugin, so that the order status can be confirmed and email sent

If I receive the response into the response_handler.php file provided by the company, I am able to receive and decrypt the response but the result is displayed on a blank white page like this



But I cannot get the page to be displayed within the Joomla template, and I cannot perform any hikashop functions to change order status/ send email from within this standalone PHP file

I would be happy with both the results -
1. Process the response in the modified example plugin
or
2. Process the response with the company provided response handler file, as long as I can display it within the Joomla template and perform Hikashop order confirmation process

I am also attaching a screenshot of the processing code in the company provided response handler file

Attachments:

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 months 5 days ago #353638

Hi,

First, let's provide some context.
Different payment gateways works in different ways.
For many payment gateways, you provide two URLs along with the data of the order:
- the URL where you want the user to be redirected to ( you usually provide the after_end URL )
- the URL where you want the payment gateway to send the payment notification data to ( you provide the notify URL )

The after_end URL used for the user will display the thank you page of HikaShop.
The notification URL will verify that the payment notification is legit and will change the status of the order to confirmed, which will also send the emails. So it's normal that this page is blank, since it's normally a server to server communication. Some even require that the website doesn't output anything in such cases.

From what you're saying, it seems that your payment gateway asks you to provide only one URL which needs to do both the payment notification and the thank you page display. So I think that's why you're struggling a bit.
The workflow needs to be like this:
- you provide the notify URL along with the order data to the payment gateway
- after the payment is done, the payment gateway will redirect the user to that notify URL along with the data for the payment
- the onPaymentNotification function will be called in your plugin.
- there, you need to validate the notification with the same algorithm as in the response_handler file
- once you validate the notification, you can use the code of the example plugin to change the status of the order to confirmed. If you stop here, the user will get a blank page with nothing on it.
- after the status is modified, you want to redirect to the after_end URL. That way, the user will get the normal thank you page of HikaShop, inside your website template.

You can actually see in the code of the example plugin that we have commented the redirect to the return URL after the order status modification:
i.imgur.com/3o26Dce.png
As I was saying, this is usually not necessary, but in your case, you need to uncomment this, basically.

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

  • Posts: 22
  • Thank you received: 1
9 months 4 days ago #353652

Thank you so much for your detailed response Nicolas. The plugin is working now. It was an error with the notification url

There is a new problem though. The order creation and confirmation emails are not going out. Even if i manually update the order status from the backend and select notify customer. Test mails from Joomla are going out and the email history contain all the emails

Last edit: 9 months 4 days ago by rmalik.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
9 months 4 days ago #353656

Hi,

Check the Customers>Emails history menu.
This listing displays all the emails sent by HikaShop to your email server.
If you see the email in there, then HikaShop did send the email to the email server and the email server didn't reply with an error.
I suppose you'll see the email you're looking for there.
And so, if the email is in there but you don't receive it in your mailbox, it's likely you have a problem with the settings in the Emails section of the HikaShop configuration.
For example, if you have the same email address for the "from" and the "to" of an email, some email servers might ignore the email.
So others will require a specific bounce email address.
Or it could also be that the email is refused by the receiver email server because it is flagged as spam.
Normally, the reason is stored in the log of the email server of your hosting, and if you provide them with a copy of the email details from the email history, they should be able to tell you what's wrong.

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

  • Posts: 22
  • Thank you received: 1
9 months 3 days ago #353708

Thanks. The email issue is resolved. I changed the "from" email id from a gmail id to an email id of my domain

The following user(s) said Thank You: nicolas

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

Time to create page: 0.073 seconds
Powered by Kunena Forum