News:

Looking for documentation? Take a look on our wiki

Main Menu

Custom payment gateway - need help with IPN

Started by brendonhatcher, April 13, 2012, 01:06:40 AM

Previous topic - Next topic

brendonhatcher

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

alatak

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


razor7

#3
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");
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

alatak

Hi,

Yes you are rigth, it is better to have the file in the plugin.
You can also use this constant JPATH_SITE.

razor7

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!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

razor7

#6
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
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

alatak

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.

razor7

Great!, that means i haven't broken anything!!!

Best regards!
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

razor7

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()
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

alatak

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.

razor7

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.
MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store

alatak


razor7

MGS Creativa - VirtueMart Payment Plugin Experts
http://www.mgscreativa.com

Take a look at our downloads section for VirtueMart payment plugins and mouch more!
http://www.mgscreativa.com/en/online-store