Zen Cart Logo
Forums / Addon Payment Modules / Custom payment mod. Best practise advice needed for making api call in admin?

Custom payment mod. Best practise advice needed for making api call in admin?

Locked

Views: 1,251

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
10 Mar 2010, 8:59 PM
#1
phillip_darley avatar

phillip_darley

New Zenner

Join Date:
Mar 2009
Posts:
16
Plugin Contributions:
0

Custom payment mod. Best practise advice needed for making api call in admin?

Hi fellow zenners,

I'm creating a custom payment module and need some advice.

My module is much like the linkpoint api mod and requires a two-stage transaction process; one transaction (xml api call) to the merchant when card details are gathered (done this in before_process method) and a second at a later stage when the item has been delivered. *I don't know how / where to code this second transaction:
*

1) I could update /admin/orders.php and update the update_action code block and check if update status is delivered then make call. This is like a non-standard hacky way of doing it
2) admin_notification method in my mod order class could create a html form which allows the user to action the second transaction api call
**3) **Is there another, zc standardised way of doing this so my mod conforms? I've noticed linkpoint has a 'review' page but don't know how this works.

Any feedback and suggestions are welcomed :bigups:.

Cheers,
Phil

13 Mar 2010, 8:21 AM
#2
phillip_darley avatar

phillip_darley

New Zenner

Join Date:
Mar 2009
Posts:
16
Plugin Contributions:
0

Re: Custom payment mod. Best practise advice needed for making api call in admin?

To put it in simpler terms I want to add a new function to my custom orders object (which sits in includes/modules/payment/mymod.php) and to be able to call this function from within the admin/orders.php page, ideally triggered when user updates an orders status. It has to be done in a way that is indepenent of core zc code.

Any advice would be fantastic :yes:

22 Mar 2010, 10:23 AM
#3
phillip_darley avatar

phillip_darley

New Zenner

Join Date:
Mar 2009
Posts:
16
Plugin Contributions:
0

Re: Custom payment mod. Best practise advice needed for making api call in admin?

I figured this out.

The observer and notfier design pattern is what I was after.

There are currenty no admin events but to get around this I added the following code to admin/orders.php in the 'orders_update' switch statement:

global $zco_notifier;
$zco_notifier->notify('NOTIFIER_ADMIN_UPDATE_ORDER_STATUS');

I then created an observer which listened for this eventId, thus allowing me to put all my business logic in my observer class, independent of the zc core code :clap:.

Cheers,
Phil