Forums / Developer / Payment gateway depending on shopaccounthandler selection

Payment gateway depending on shopaccounthandler selection

Author Message

Eirik Alfstad Johansen

Tuesday 07 August 2007 5:44:13 am

Hi,

I want to decide whether to run a payment gateway or not depending on a selection in the shopaccounthandler (where the user selects payment method). What's the best way to implement this logic? Should it be within the [gatewayname]gateway.php?

Sincerely,

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

Heath

Tuesday 07 August 2007 6:00:31 am

Hello Eirik,

Yes. This is how I would do this at this time.

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Eirik Alfstad Johansen

Wednesday 08 August 2007 1:53:56 am

Hi again,

I tried a couple of things with no luck. Among them are;

1. Returning false in gateway::createRedirectionUrl() - this redirects me to the front page.

2. Returning the full URL to shop/checkout - this brings me to the page which reloads three times waiting for a response.

2. Keeping the full URL to shop/checkout and running the approve() method on the payment object created in gateway::createPaymentObject() before returning it. This seems to have the same effect as the previous solution.

Any ideas?

Sincerely,

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

Bruce Morrison

Wednesday 08 August 2007 4:14:48 am

Hi Eirik

The [gatewayname]gateway.php can be consider a workflow and you need to return workflow prefefined returns e.g. EZ_WORKFLOW_TYPE_STATUS_ACCEPTED, EZ_WORKFLOW_TYPE_STATUS_FETCH_TEMPLATE_REPEAT

So I'd think your code in [gatewayname]gateway.php would look something like

...
function execute( &$process, $event )
{
  if [shop account handler says no gateway]
    return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
  else
    // Do your payment gateway here
}
...

HTH

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Eirik Alfstad Johansen

Wednesday 08 August 2007 4:27:11 am

Thanks for the tip, Bruce However, the coded I used as a basis (the PayPal gateway) does not contain the execute() method. Should I just include it? And if so, what should be the status if the gateway should be run?

Sincerely,

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

Bruce Morrison

Wednesday 08 August 2007 5:02:24 pm

Hi Eirik

Have had a look at the PayPal gateway and it extends the eZRedirectGateway class which does have the execute method. So assuming that your [gatewayname]gateway.php does the same thing you can copy the execute method from eZRedirectGateway to your gateway and wrap the exiting code in your check from the account handler.

In the example from my previous post the body of the eZRedirectGateway::excute would replace the "// Do your payment gateway here" bit.

Maybe not the most elegant solution but the because the excute method is whats called from the core checkout system it's the only way I can see for this to work without changing the core eZ code.

HTH

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Eirik Alfstad Johansen

Monday 13 August 2007 2:10:48 am

Hi Bruce,

Thanks for helping out! Here's what I did specifically, for anyone else who might be interested.

1. Copied the entire execute() method from the eZRedirectGateway class and into my gateway class.
2. Inserted the following code near the top of the execute() method, after:

$processParameters =& $process->attribute( 'parameter_list' );
$processID         =  $process->attribute( 'id' );
// get order id
$orderID        = $processParameters['order_id'];

// get order
$order          =& eZOrder::fetch( $orderID );

// get account information
$accountInfo = $order->accountInformation();

// fetch payment method from account info
$paymentMethod = $accountInfo['payment_method']

// if the user has not selected credit card as payment type
if($paymentMethod != 'credit_card')
{
	// do not run payment gateway
	return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;
}

Sincerely,

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

christian bencivenni

Thursday 06 December 2007 1:13:27 am

Very interesting.
Thank you Eirik for
Only a question: where you set the 'credit_card' value when you seach it in the code?

// fetch payment method from account info
$paymentMethod = $accountInfo['payment_method']
// if the user has not selected credit card as payment type
if($paymentMethod != 'CREDIT_CARD')

Eirik Alfstad Johansen

Thursday 06 December 2007 4:27:50 am

> Only a question: where you set the 'credit_card' value when you seach it in the code?

The value is set in a custom version of shop/userregister, and then fetched by a custom shopaccounthandler.

Sincerely,

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

christian bencivenni

Thursday 06 December 2007 8:19:02 am

So...
you add a, for example, select form inside the userregister form, and then pass the selection in a POST/GET way?
I thinked it wasn't possible to make this kind of passages...

Carla Richieri

Saturday 13 February 2010 4:43:12 am

This was exactly what I was searching.

Thank you !!!

Nicolas Pastorino

Monday 15 February 2010 1:26:58 am

"

This was exactly what I was searching.

Thank you !!!

"

Good to see old posts still bring valuable info :)
Ow, and welcome aboard the eZ Community Carla !
Cheers

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye