VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: brendonhatcher on April 13, 2012, 01:06:40 AM

Title: Custom payment gateway - need help with IPN
Post by: brendonhatcher on April 13, 2012, 01:06:40 AM
Hi

VCS is a South African payment gateway.
They recently created a payment plugin for VM2.

I am having difficulties working out how the successful payment will update the order in VM2 to "paid".

Reading on the forum, I found /index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component as a possible passback url

The VCS terminal makes provision for a "success" and "failure" URL.
However, these do not allow parameter URLs, so I can use the above example.

Any ideas?

Regards
Brendon
Title: Re: Custom payment gateway - need help with IPN
Post by: alatak on April 18, 2012, 09:45:51 AM
Hi,

Create a file called for example notify.php, add the following code, and place it it the root folder:

$_REQUEST['option'] = "com_virtuemart";
$_REQUEST['view'] = "pluginresponse";
$_REQUEST['task'] = "pluginnotification";
$_REQUEST['tmpl'] = "component";
require_once("index.php");
?>


and in VCS : give for the URL the name http://yourdomain.com/notify.php
Title: Re: Custom payment gateway - need help with IPN
Post by: buzi on April 18, 2012, 13:29:18 PM
Thanks for this alatak  :)
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 03, 2012, 22:06:07 PM
Quote from: alatak on April 18, 2012, 09:45:51 AM
$_REQUEST['option'] = "com_virtuemart";
$_REQUEST['view'] = "pluginresponse";
$_REQUEST['task'] = "pluginnotification";
$_REQUEST['tmpl'] = "component";
require_once("index.php");
?>

Hi, on trying this, it works, but the URL of my site keeps saying http://www.misite.com/notify.php, it is possible to reload the page so it changes to the correct url? IE: http://www.mysite.com/index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component

Thanks a lot!

PS: Just in case someone needs it. In my case, I prefer to have the notify.php on the plugin folder, so in joomla 1.5 and joomla 2.5 the paths are different, so to keep it working, i added this simple code.

if (file_exists("../../index.php"))
    require_once("../../index.php");
else
    require_once("../../../index.php");
Title: Re: Custom payment gateway - need help with IPN
Post by: alatak on May 03, 2012, 23:34:47 PM
Hi,

Yes you are rigth, it is better to have the file in the plugin.
You can also use this constant JPATH_SITE.
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 04, 2012, 03:28:06 AM
Quote from: alatak on May 03, 2012, 23:34:47 PM
You can also use this constant JPATH_SITE.
I don't think so, because this file is not knowing where index.php is and also is not having access to joomla global vars.

Anyway, is it possible to solve the URL issue? (http://www.misite.com/notify.php => http://www.mysite.com/index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component)

Thanks!
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 09, 2012, 15:21:51 PM
Hi, i think i have solved the redirect issue with this little piece of code.

$topic=$_GET["topic"];
$id=$_GET["id"];

if (file_exists("../../index.php"))
    header("Location: ../../index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&topic=$topic&id=$id");
else
    header("Location: ../../../index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&topic=$topic&id=$id");


But when redirected, the page gets completely blank! but the method plgVmOnPaymentNotification gets called ok!

Is that normal, to get a blank page on calling plgVmOnPaymentNotification?

thanks!

PS: using VM 2.0.6
Title: Re: Custom payment gateway - need help with IPN
Post by: alatak on May 09, 2012, 15:48:16 PM
Hi,

Yes it is normal to get a blank page. The task pluginnotification is used for server to server notification, and should not ave any output.
If you need output, you can use task pluginresponsereceive.
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 09, 2012, 15:57:17 PM
Great!, that means i haven't broken anything!!!

Best regards!
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 09, 2012, 16:52:59 PM
Hi, just one more question.

What sould i return if something goes wrong in the IPN check? Actually I'm returning "false" but there is no documentation about return value of plgVmOnPaymentNotification()
Title: Re: Custom payment gateway - need help with IPN
Post by: alatak on May 10, 2012, 09:26:16 AM
Hi,

the plugin itself should decide what to do when the IPN is wrong. You can decide to change the order status, or to remove the order. You choose.
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 10, 2012, 13:53:22 PM
Hi, I know that, I mus decide in that function what to do with the order, but I mean wich return value should return to VM, if something needs to be returned.
Title: Re: Custom payment gateway - need help with IPN
Post by: alatak on May 10, 2012, 13:54:06 PM
Hi,

nothing needs to be returned.
Title: Re: Custom payment gateway - need help with IPN
Post by: razor7 on May 10, 2012, 13:55:02 PM
Great!

Thanks a lot!