return after iDeal payment url

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
2 years 4 months ago #337801

-- HikaShop version -- : 4.4.1
-- Joomla version -- : 3.9.26
-- PHP version -- : 7.4.x

Hi,

We have a problem were notification emails won't be send if a customer never reaches the "Payment success page". this happens when a customer closes the payment provider website before being returned to the "Payment success page" on our own website.
They payment provider always sends a webhook telling us the payment status changed, even when the users never gets back to our website.
So instead of sending the emails on the thank you page `header('Location: ' . $this->oRecord);`.
We would like to send the email on the webhook page.
We could redirect the webhook call to the transaction_success_url. But that would cause double emails to be send if the user does make it to the transaction_success_url. What is the best way to solve this problem. What part of the plugin could we modify to fix this?

Regards,

Mark

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 years 4 months ago #337807

Hi,

The webhook should call the onPaymentNotification function of the payment plugin.
There, there should be the changing of the order status to cancelled when the payment is cancelled, I suppose.
This normally uses the modifyOrder function call.
Before that call, you should add a parameter history_notified to the order object being passed to the modifyOrder function to ask HikaShop to send the "order status notification" email to the customer.

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

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
2 years 4 months ago #338015

Thanks for the response.
Just to make it clear, we use Idealcheckout. How am I supposed to call the onPaymentNotification. Currently what happens is that the return page after payment redirects to to following url:
06.bluepoint-concept.nl/index.php?option...pl=component&lang=nl
When I prevent the redirect to go to this url and copy it to manually go to that page I just get a blank page. Which part of the code will actually be called when going to this url.


The current the webhook method of the gateway does the following:

if(isset($jsonBody->data->financial_status) && $jsonBody->data->financial_status == "completed"){
   $this->oRecord['transaction_status'] = 'SUCCESS';
}else{
   $this->oRecord['transaction_status'] = 'CANCELLED';
}




if (empty($this->oRecord['transaction_log']) == false) {
   $this->oRecord['transaction_log'] .= "\n\n";
}

$this->oRecord['transaction_log'] .= 'Executing StatusRequest on ' . date('Y-m-d, H:i:s') . ' for #' . $sTransactionId . '. Recieved: ' . $this->oRecord['transaction_status'];

$this->save();
So it adds the status to the record in table: pa8ju_idealcheckout_transactions and after that it will add a record to the transaction_log. So now we have the new transaction status in our database. So next I would to redirect to the onPaymentNotification page right? How would I do that?
Kind regards,
Mark

Last edit: 2 years 4 months ago by nicolas.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 years 4 months ago #338032

Hi,

If you want to redirect to the onPaymentNotification function, you could:
1. redirect to the 06.bluepoint-concept.nl/index.php?option...pl=component&lang=nl notification URL. This will automatically call onPaymentNotification
This can be done in PHP with stackoverflow.com/questions/768431/how-d...ke-a-redirect-in-php
2. to manually call the onPaymentNotification, you need to :
- load Joomla if that's not already done stackoverflow.com/questions/23937651/loa...in-external-php-file
- load HikaShop with

if(!include_once(rtrim(JPATH_ADMINISTRATOR,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_hikashop'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helper.php')) return;
- load the plugin with
$data = hikashop_import('hikashoppayment', 'idealcheckoutideal');
- call onPaymentNotification with :
$trans = hikashop_get('helper.translation');
$cleaned_statuses = $trans->getStatusTrans();
$data->onPaymentNotification($cleaned_statuses);

Last edit: 2 years 4 months ago by nicolas.

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

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
2 years 4 months ago #338095

Hi,

Thanks for the reply! Unfortunately it's not completely working yet.

As you suggested I imported Joomla and the plugins and called onPaymentNotification. Now when I finish the payment it will set the order from 'created' to 'new order' which is good. I also get the popup in my Joomla backend saying a new order has been placed. But the emails are still not being send. Also when I return to the vendor the product I just ordered is still in my shopping cart. So the session is not begin emptyed aswell.

Is there anything else I need to call to send the emails and empty the shopping card?

Last edit: 2 years 4 months ago by BluepointWebdesign.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
2 years 4 months ago #338097

Hi,

For the shopping cart to be emptied, either it has to be done manually by the payment plugin, or the payment plugin needs to redirect the customer to the after_end URL of HikaShop will will empty the cart automatically.
For example, in the "example" payment plugin we provide on our developer documentation, we have this piece of code:

$return_url = HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$order_id.$this->url_itemid;
...
$this->app->redirect($return_url);
in the onPaymentNotification function which does that.

Regarding the notification email to the customer, it depends on the code in the onPaymentNotification function.
If you look again at the example payment plugin's code, you can see this call before the redirect:
$this->modifyOrder($order_id, $this->payment_params->verified_status, true, true);
This modifyOrder function is the function we recommend payment plugin developers to use in order to change the status of the order.
If the third parameter is set to true, HikaShop will notify the user with an "order status notification" email.
If the fourth parameter is set to true, HikaShop will notify the admin with a "payment notification" email.
If your customers don't get the email notification, then it means that either this function is called with wrong parameters, or that the order status is changed without using that function.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum