VirtueMart Forum

VirtueMart 2 + 3 + 4 => Plugins: Payment, Shipment and others => Topic started by: alexdran on October 08, 2012, 23:02:25 PM

Title: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 08, 2012, 23:02:25 PM
Hello all
is it possible to create a plugin for virtueMart payment only to catch an order confirmed
(and launch then an external script) ?

suggestion if possible to achieve and on how to address it?

thank you in advance for the help
alex  :)
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: bytelord on October 08, 2012, 23:22:36 PM
Hello,

Confirmed by who? Do you mean someone makes an order and wait's a confirmation?
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 08, 2012, 23:28:09 PM
Quote from: bytelord on October 08, 2012, 23:22:36 PM
Hello,

Confirmed by who? Do you mean someone makes an order and wait's a confirmation?

I mean an order passed that arrives in 'C' / Confirmed status

But also catch the event of changing order Status would be enough, of course having also information about the order passed for my script to be launched

I want to manage membership subscriptions with this system, then update a table where every subscription date is updated after the order (i.e. product 1Year subscription)


thank you again for any help
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: bytelord on October 08, 2012, 23:32:32 PM
Hello,

it think you have do develop a plugin for that and for subscriptions also a component to mange them.

More information could be found here: http://dev.virtuemart.net/projects/virtuemart/wiki/Plugin_system
here: http://dev.virtuemart.net/projects/virtuemart/wiki/Payment_Plugins
and here: http://dev.virtuemart.net/projects/virtuemart/wiki/Product_Plugins

btw, this can be configured under payment plugins, what's your vm version?

Regards
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 08, 2012, 23:48:15 PM
forgot to add indeed

I'm working on joomla 2.5 and virtueMart 2.0.12 installation


I agree on the need of having a component to show and manage subscriptions, for the rest:
where do I need to look for the function to intercept order status ?
Payment or Product plugin?

I have looked for the function on the plugin page without finding anything interesting (unless any oversight)

thank you again
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: bytelord on October 09, 2012, 00:50:29 AM
Hello,

You could study payment standart plugin for example. The event that fired is plgVmConfirmedOrder

Regards
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 09, 2012, 09:49:36 AM
thanks a lot!!! I will go for this option
alex :)
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 09, 2012, 12:23:16 PM
I have created a plugin
with

plgVmConfirmedOrder ($cart, $order) {

printing some the $order variable and exiting (in order for me to see is processed)

there is no check at the beginning if another method is selected (it should be called any payment method selected)


the plugin is installed and activated
however completing the order it is not called (otherwise the php would die())


does the method is called also in back-end when in the list of orders a status is changed ??
I do not think so... What do you think I need to use in that case alternatively, since my first try is not effective ?


thank you again
alex
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: bytelord on October 09, 2012, 12:33:30 PM
Hi,

you can study the vm core, i am sure you will find the functions that running when status changed. The first method is only triggered when user's checkout ... not in the backend. So maybe you need 2 of them, or hack the core and edit the 'C' state "function" to do something more .. what you want i suppose. Alternative a plugin but cannot trigerred from the backend.

Regards
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: alexdran on October 09, 2012, 20:12:04 PM
thank you again for the suggestion

I cannot however achieve the first step of catching the order passed
I have created a paypal payment plugin and also tried with a custom plugin; both are active on joomla;
the payment plugin is also selected among payment plugins (even if is not appearing on the select-payment-method step in home page; and this is good, since has to be transparent)


i have declared the following functions:
- plgVmOnPaymentResponseReceived
- plgVmOnPaymentNotification
- plgVmOnConfirmedOrderStorePaymentData
- plgVmConfirmedOrder

printing the function name and exiting the script; but the purchase process ends normally ("with thank you message") and apparently
it is not passing by my methods at all

any additional suggestion on what should I look for to intercept the payment?

thank you again 
:)
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: bytelord on October 09, 2012, 21:12:07 PM
Hello,

plgVmOnPaymentResponseReceived and plgVmOnPaymentNotification are trigerred usually from the external hosts (like paypal, cc, etc) for validation or returns the successful payment, its a custom url if you look better inside the files you study.
you should create a plugin to "track" those, may be the payment method comes first, may be play with ordering. I have create some payment plugins and the triggers was successfully trigerred. Also enable debugging to follow it better.

Regards
Title: Re: Payment Plugin - trigger function after order confirmed
Post by: RCheesley on August 18, 2013, 19:41:37 PM
Sorry to resurrect an old post, but did you get anywhere with this? I've got a plugin written which hooks Akeeba Subs into VM and I can get it to trigger in the back-end using plgVmOnUpdateSingleItem but this doesn't seem to be getting triggered in the front-end when confirmation comes in from PayPal?

I've also tried the triggers mentioned here but none seem to fire on front-end :(

Ruth