Forums / Setup & design / I want to offer several payment method - workflow limitation ?

I want to offer several payment method - workflow limitation ?

Author Message

Xavier Dutoit

Tuesday 12 April 2005 12:46:41 am

Hi,

Is is a default solution to offer several payments methods (paypal, by "hand" -wire, check, visa...) ?

I've been able to install paypal, and I was wondering if the best method is to create a multiplexer.

1) I would create a "select the payment method" event and trigger it on before/checkout... but I don't know what to set. Is this a flag somewhere ? Create a new status ? add a product "payment" ?

2) On the after/checkout, I'd like to put a multiplexer... but I don't know how to define what to test and how to explain to branch to one payment system or another.

Any idea ? Does it exist a general purpose "switch/test" event ? Is this possible to set a param on a previous event that could be read by such "switch/test" event ?

If someone has used the workflow to do more than a simple event, stand up and speak loud ;)

X+

http://www.sydesy.com

Eirik Alfstad Johansen

Friday 15 April 2005 4:52:06 am

Hi Xavier,

As for storing the payment method, I would do so in the head of the order by modifying the shopaccounthandler, or creating a new one as an extension. You could then test against this value in your second event, and then redirect to the appropriate payment gateway.

You could also store the payment method as an order item, but it doesn't make much sense unless the specific payment method should result in a fee/discount.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Xavier Dutoit

Friday 15 April 2005 5:47:33 am

Hi Eirik,

Once you've stored the payment method on the order, how can you use it on a multiplexer ?

I thought about puting all the payments events one after the other, and test in the process "if order->paymentmethod != mypaymentmethod then exit..."

Is that what you've done ? Not that's a big problem to modify the paypal event, but I don't find this solution highly attractive...

X+

P.S. The more I use the workflow system, the more I miss features to allow easily inter event communications and things like that.

http://www.sydesy.com

Eirik Alfstad Johansen

Friday 15 April 2005 6:27:08 am

Hi Xavier,

Provided that you have stored the payment method as suggested, meaning as an xml attribute in the data_text_1 field of the ezorder table, you could fetch the value doing something like this (please note that this code has not been tested):

include_once( "kernel/classes/ezorder.php" );
include_once( 'lib/ezxml/classes/ezxml.php' );

// order fetch parameters
$offset         = 0;
$limit          = 1;
$sortField      = 'created';
$sortOrder      = 'desc';

// fetch most recent order
$orderArray =& eZOrder::active( true, $offset, $limit, $sortField, $sortOrder );

$xmlData 	= $orderArray[0]->attribute('data_text_1');
$xmlObject	= new eZXML();
$domDocument    =& $xmlObject->domTree( $xmlData );
$tname          =& $domDocument->elementsByName( "payment_method" );
$paymentMethod  = $tname[0]->textContent();

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Xavier Dutoit

Friday 15 April 2005 6:42:28 am

Hi,

I'll test the code thanks.

However, I haven't be clear about what's my real problem:
How would you do the multiplexer (based on what you've extracted from the code) ?

As the real multiplexer isn't able (for what I've understood) to switch on a value like the choosen payment system extracted from the code ?

The only solution I thought of was to put all the payments as events into the same workflow (1, paypal, 2 by check, 3 by worldpay...), and test in each process if the choosen payment system is "me" or if I do nothing and let the next event deal with the order.

Am I clearer ?

X+

http://www.sydesy.com

Eirik Alfstad Johansen

Monday 18 April 2005 4:18:13 am

Hi Xavier,

I would probably do it a little different. In stead of creating an event to select the payment method, I would create a custome shopaccounthandler and include the selection of the payment method in the same screen where the user registers the order information.

I would then create a custome event to run before checkout including the code posted earlier.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Xavier Dutoit

Monday 18 April 2005 9:13:51 am

Hi,

That's a good idea, and once a user has choosen a payment method, that's quite likely he's going to use the same on the next order too.

Ok, I'm going to have a look at how to do a custom shopaccounthandler.

Many thanks.

I'm going to modify my signature to only keep my question about a cache resistant method to exchange parameters between templates :
http://www.ez.no/community/forum/...tween_several_parts_blocks_on_a_page

BTW, you gave me the idea of using the signature for a call for help.

http://www.sydesy.com

Eirik Alfstad Johansen

Monday 18 April 2005 11:16:07 am

<quote>
BTW, you gave me the idea of using the signature for a call for help.
</quote>

Glad it has helped. :)

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/