Author Topic: Developing a VM Extension / Plugin  (Read 3324 times)

xpozay

  • Beginner
  • *
  • Posts: 48
Developing a VM Extension / Plugin
« on: July 14, 2011, 11:44:55 am »
Hi there,

I was just looking through your wiki for payment plugins and found this class - plgVmOnConfirmedOrderStorePaymentData(),

Is this the class that we would use to initiate a call after a confirmed order?  For example, if I wanted to update some external databases with customer information after a successful order.

Thanks

alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Developing a VM Extension / Plugin
« Reply #1 on: July 14, 2011, 16:43:36 pm »
Hi,

Actually it depends how your payment is confirmed: if the order is confirmed via an asynchrone notification (like notify for paypal), you should use plgVmOnPaymentNotification function.

xpozay

  • Beginner
  • *
  • Posts: 48
Re: Developing a VM Extension / Plugin
« Reply #2 on: July 15, 2011, 11:35:31 am »
OK thanks.

Does this then mean that if I allow payment from paypal, cheque, athorise.net each would require their own plugin?  I would have thought that upon order status change a call to external plugin would be feasible.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9839
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Developing a VM Extension / Plugin
« Reply #3 on: July 15, 2011, 11:40:25 am »
this looks like to 2 questions mixed.

First every payment needs its own plugin. We want to provide a generic plugin for form based payments as you had already in vm1.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Dade

  • Beginner
  • *
  • Posts: 2
Re: Developing a VM Extension / Plugin
« Reply #4 on: July 15, 2011, 23:37:59 pm »
Hi all,
I'm new to this forums as I'm dealing for the first time with VirtueMart component due to a new project I'm working with.

Just to share with the rest of the community that I'm trying to create a payment extensions for AlphaUserPoints component. I am not a programmer at all (but I learn fast :P), hence I may share with the community the code to get it improved and free.

Great component btw, I had already tested older beta release of VM 2.0 and it has been a nice improvement. I will try to report bugs when I find them.

GGz!

xpozay

  • Beginner
  • *
  • Posts: 48
Re: Developing a VM Extension / Plugin
« Reply #5 on: July 16, 2011, 00:24:13 am »
Thanks.  Actually there should only be 1 question - which is in my original post.  Just trying to confirm that only that one class "plgVmOnConfirmedOrderStorePaymentData()"  is required to be called post confirmed order.  My aim is to update an external table with some of the order details.

However, alatak statement has confused me, saying that it depends on how the payment is confirmed.  I would have thought that no matter how the payment is done, a single class can be used for "post confirmed orders".  From a process / business point of view, we don't really care how something is paid as long as it is paid.

Thanks for your help


alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Developing a VM Extension / Plugin
« Reply #6 on: July 17, 2011, 01:18:29 am »
HI

Sorry if i confused you.
May be you can tell me what kind if payment you are trying to develop, and may be I can be more helpfull.


xpozay

  • Beginner
  • *
  • Posts: 48
Re: Developing a VM Extension / Plugin
« Reply #7 on: July 17, 2011, 09:22:56 am »
Hi thanks.

I am actually not trying to create a payment.  I want to initiate a task after any successful order (ie confirmed order whether paid or not).  For example, as soon as a order is confirmed (paid or free), then I want to make a call to a function which will update a series of external databases such as an event or CRM system.

Thanks

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9839
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Developing a VM Extension / Plugin
« Reply #8 on: July 17, 2011, 18:02:50 pm »
imho and afaik,

the function plgVmOnConfirmedOrderStorePaymentData is just replaced by plgVmOnPaymentNotification. This is a small "error", yes. I have to restructure it a bit. But in your case only the name of the function may change (and then within the next 2 weeks).
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

xpozay

  • Beginner
  • *
  • Posts: 48
Re: Developing a VM Extension / Plugin
« Reply #9 on: November 02, 2011, 15:28:57 pm »
Hi again,

I was just looking back through some of my older posts.  This particular thread I didn't think was addressed completely - perhaps I didn't communicate my thoughts well enough.  At the same time I came across this post
http://forum.virtuemart.net/index.php?topic=90563.0
which is after the "same thing" or at least after the same process / concept.

Basically, I think it is imperative that there be a way to call pieces of code (VM or 3rd party) once particular events happen.  For one, it would be when an order status has changed, say from pending to completed.  This will allow developers to create code that adds users to groups, perform calculations on data, send email notifications, run a report, etc.  the list is endless.

For me, once a payment has been confirmed, I need to execute the following tasks:
- send notification
- add user details to database records
- call a web services function to grant user access to another application (external to Joomla)
- generate an invoice
- create a pdf certificate
- create an email account - again using web services

Now I don't expect VM to do all of this, however, It would seem appropriate for VM to kick off the process as it knows when a particular event has occurred.

This is done well in Tienda today and works wonderfully.  It's easy to setup and allows Tienda to manage the payment and the 3rd party code to its job too. With the earlier releases of VM we had to hack the payment class code such as ps_paypal, etc. code to make the calls.  Clearly hacking the code would not be a desirable solution.

Is there now a way to achieve this?

Thanks


alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Developing a VM Extension / Plugin
« Reply #10 on: November 03, 2011, 08:26:21 am »
Hi

Did you even try VM2?
Quote
For me, once a payment has been confirmed, I need to execute the following tasks:
- send notification
It does

Quote
- add user details to database records
It does

Quote
- call a web services function to grant user access to another application (external to Joomla)
It does not yet. But really this is an advanced feature.

Quote
- generate an invoice
It does not yet. Just create an invoice is not difficult. But the invoice should be coupled with a delivery system.
Phoca did a great job for VM1. May be they will adpat to VM2?

Quote
- create a pdf certificate
Joomla 1.7 does not support PDFs any longer. And anyway will be coupled with the invoice / delivery system.

Quote
- create an email account - again using web services
an email account? using web services?
An user account is created.
why using web services?

Please try first VM2, and then send us recommendations!


ursule15

  • Beginner
  • *
  • Posts: 2
Re: Developing a VM Extension / Plugin
« Reply #11 on: December 01, 2011, 09:44:39 am »
I am exactly same request as xpozay, and no, afaik, vm or vm2 does not have this feature (but I'm not an expert, I will appreciate to be wrong on that point).

Basically, the idea is to launch sql request (or whatever code it is) after order has been confirmed (or whatever order status we want).

Any idea what is the modification / hack to do ?
What function / class  to use ? plgVmOnConfirmedOrderStorePaymentData  ? plgVmOnPaymentNotification ? Something else ?

@alatak - Valerie, des idées ? ;-)

Thanks.


Cleanshooter

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 69
    • My Blog
Re: Developing a VM Extension / Plugin
« Reply #12 on: December 01, 2011, 19:55:34 pm »
As Valerie mentioned many of the tasks that you want to do are done with-in VM already.  If you want to modify the process you would probably need to "hack" or modify the code.  Especially if you want VM to modify external/custom databases.   The other option is to create a VM2 plug-in that will handle the tasks you described.  However in order to create a plug-in you may want to wait until VM2 is released.
- Cleanshooter