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

eZ debug

Timing: Jan 18 2025 15:16:06
Script start
Timing: Jan 18 2025 15:16:06
Module start 'content'
Timing: Jan 18 2025 15:16:07
Module end 'content'
Timing: Jan 18 2025 15:16:07
Script end

Main resources:

Total runtime1.4458 sec
Peak memory usage4,096.0000 KB
Database Queries229

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 587.9688180.7969
Module start 'content' 0.00681.3041 768.7656814.1875
Module end 'content' 1.31090.1348 1,582.9531353.2734
Script end 1.4457  1,936.2266 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.2664210.0002
Check MTime0.00130.0930210.0001
Mysql Total
Database connection0.00100.069610.0010
Mysqli_queries1.346393.12172290.0059
Looping result0.00230.15942270.0000
Template Total1.415397.920.7077
Template load0.00170.117720.0009
Template processing1.413697.775120.7068
Template load and register function0.00010.006610.0001
states
state_id_array0.00080.054610.0008
state_identifier_array0.00120.080720.0006
Override
Cache load0.00160.1102730.0000
Sytem overhead
Fetch class attribute can translate value0.00130.088670.0002
Fetch class attribute name0.00140.0971160.0001
XML
Image XML parsing0.00240.163770.0003
class_abstraction
Instantiating content class attribute0.00010.0038210.0000
General
dbfile0.00500.3474460.0001
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 52
 Number of unique templates used: 8

Time used to render debug report: 0.0002 secs