VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: spinoops on March 28, 2014, 09:29:06 AM

Title: Creating a payment plug-in for Swissbilling
Post by: spinoops on March 28, 2014, 09:29:06 AM
Hi,

I'm developing a new plug-in for a payment method like Swissbilling. This is my first one so I think I've much to learn. My problem is that I don't know how to display a message after the payment status (success, error, cancel). In Swissbilling documentation, they say that we need an Url for both status like sucess.php or error.php. I needed to find how to do that in Virtuemart so I looked into the standard plugin and saw that :

/**
* plgVmOnPaymentResponseReceived
* This event is fired when the  method returns to the shop after the transaction
*
*  the method itself should send in the URL the parameters needed
* NOTE for Plugin developers:
*  If the plugin is NOT actually executed (not the selected payment method), this method must return NULL
*
* @param int     $virtuemart_order_id : should return the virtuemart_order_id
* @param text    $html: the html to display
* @return mixed Null when this method was not selected, otherwise the true or false
*
* @author Valerie Isaksen
*
*/
function plgVmOnPaymentResponseReceived(, &$virtuemart_order_id, &$html) {
return null;
}


I then used this Url for the response from Swissbilling : index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification

But I don't have more informations about the use of this method. Could somebody tell me which parameters I need to add exactly?

Thanks for your answer and best regards.
Title: Re: Creating a payment plug-in for Swissbilling
Post by: alatak on March 28, 2014, 10:06:33 AM
Hello
The standard plugin is not the one you should look at.
Look at any other payment plugin that handle the response depending on the payment answer.
Title: Re: Creating a payment plug-in for Swissbilling
Post by: spinoops on April 01, 2014, 15:34:18 PM
Hi,

When I confirm my order (I click the confirm button to access to the payment platform), my order is always saved in the VM Database... If the payment is refused or cancelled, where can I block the creation of the order in the database?

Thanks,
Title: Re: Creating a payment plug-in for Swissbilling
Post by: spinoops on April 01, 2014, 16:01:54 PM
I think I will directly modify the DB in the function plgVmOnPaymentResponseReceived(&$html) :

if Success : Change status to paid.
if Failed : Change status to cancelled.
if Cancel : delete the order

But how to do if the customer uses history back on the payment paltform?