From 6093c410c9888244ffab3e27cb42eb15e5108318 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 10 Jul 2008 14:50:42 +0000 Subject: [PATCH] - Fixed a problem where shop could create internal server errors instead of catching the exceptions. - Made the iTransact terminal link a button that automatically logs you in. - iTransact now more gracefully handles recurring payment postback errors. --- docs/changelog/7.x.x.txt | 4 ++ lib/WebGUI/Shop/PayDriver/ITransact.pm | 74 +++++++++++++++----------- lib/WebGUI/URL/Content.pm | 2 +- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index fade18db6..f7c52d5ec 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,6 +1,10 @@ 7.5.16 - Created a migration from 7.4.40 directly to 7.5.16. - fixed: transactions lost during 7.5.11 upgrade + - Fixed a problem where shop could create internal server errors instead of + catching the exceptions. + - Made the iTransact terminal link a button that automatically logs you in. + - iTransact now more gracefully handles recurring payment postback errors. - fixed: More permissive DSN checking to allow use of SQLite (thanks pathma) - fixed: Project manager modal dialog doesn't work in some instances. - fixed: Syndicated Content doesn't always decode text properly diff --git a/lib/WebGUI/Shop/PayDriver/ITransact.pm b/lib/WebGUI/Shop/PayDriver/ITransact.pm index c6374af53..1d98b4028 100644 --- a/lib/WebGUI/Shop/PayDriver/ITransact.pm +++ b/lib/WebGUI/Shop/PayDriver/ITransact.pm @@ -440,33 +440,6 @@ sub getButton { return $payForm; } -#------------------------------------------------------------------- -sub getEditForm { - my $self = shift; - my $session = $self->session; - my $i18n = WebGUI::International->new($session, 'PayDriver_ITransact'); - - my $f = $self->SUPER::getEditForm( @_ ); - $f->readOnly( - -value => '
' - ); - $f->readOnly( - -value => ''.$i18n->get('show terminal').'' - ) if $self->get('vendorId'); - $f->readOnly( - -value => '
' - ); - $f->readOnly( - -value => - $i18n->get('extra info') - .'
' - .'https://'.$session->config->get("sitename")->[0] - .'/?shop=pay;method=do;do=processRecurringTransactionPostback;paymentGatewayId='.$self->getId.'' - ); - - return $f; -} - #------------------------------------------------------------------- =head2 handlesRecurring @@ -587,6 +560,44 @@ sub processPayment { } } +#------------------------------------------------------------------- + +=head2 www_edit ( ) + +Generates an edit form. + +=cut + +sub www_edit { + my $self = shift; + my $session = $self->session; + my $admin = WebGUI::Shop::Admin->new($session); + my $i18n = WebGUI::International->new($session, 'PayDriver_ITransact'); + + return $session->privilege->insufficient() unless $admin->canManage; + + my $form = $self->getEditForm; + $form->submit; + + my $terminal = WebGUI::HTMLForm->new($session, action=>"https://secure.paymentclearing.com/cgi-bin/rc/sess.cgi", extras=>'target="_blank"'); + $terminal->hidden(name=>"ret_addr", value=>"/cgi-bin/rc/sure/sure.cgi?sure_template_code=session_check&sure_use_session_mid=1"); + $terminal->hidden(name=>"override", value=>1); + $terminal->hidden(name=>"cookie_precheck", value=>0); + $terminal->hidden(name=>"mid", value=>$self->get('vendorId')); + $terminal->hidden(name=>"pwd", value=>$self->get('password')); + $terminal->submit(value=>$i18n->get('show terminal')); + + my $output = '
'; + if ($self->get('vendorId')) { + $output .= $terminal->print.'
'; + } + $output .= $i18n->get('extra info').'
' + .'https://'.$session->config->get("sitename")->[0] + .'/?shop=pay;method=do;do=processRecurringTransactionPostback;paymentGatewayId='.$self->getId.''; + + return $admin->getAdminConsole->render($form->print.$output, $i18n->get('payment methods','PayDriver')); +} + #------------------------------------------------------------------- sub www_getCredentials { my $self = shift; @@ -727,13 +738,14 @@ sub www_processRecurringTransactionPostback { my $errorMessage = $form->process( 'error_message' ); # Fetch the original transaction - my $baseTransaction = WebGUI::Shop::Transaction->newByGatewayId( $session, $originatingXid, $self->getId ); + my $baseTransaction = eval{WebGUI::Shop::Transaction->newByGatewayId( $session, $originatingXid, $self->getId )}; #---- Check the validity of the request ------- # First check whether the original transaction actualy exists - unless ( $baseTransaction ) { - $session->errorHandler->warn->("Check recurring postback: No base transction for XID: [$originatingXid]"); - return "Check recurring postback: No base transction for XID: [$originatingXid]"; + if (WebGUI::Error->caught || !(defined $baseTransaction) ) { + $session->errorHandler->warn("Check recurring postback: No base transction for XID: [$originatingXid]"); + $session->http->setStatus('500', "No base transction for XID: [$originatingXid]"); + return "Check recurring postback. No base transction for XID: [$originatingXid]"; } # Secondly check if the postback is coming from secure.paymentclearing.com diff --git a/lib/WebGUI/URL/Content.pm b/lib/WebGUI/URL/Content.pm index 5566ba52c..fc0651612 100644 --- a/lib/WebGUI/URL/Content.pm +++ b/lib/WebGUI/URL/Content.pm @@ -53,7 +53,7 @@ sub handler { $request->push_handlers(PerlResponseHandler => sub { my $session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server); foreach my $handler (@{$config->get("contentHandlers")}) { - my $output = WebGUI::Pluggable::run($handler, "handler", [ $session ] ); + my $output = eval { WebGUI::Pluggable::run($handler, "handler", [ $session ] )}; if ( my $e = WebGUI::Error->caught ) { $session->errorHandler->error($e->package.":".$e->line." - ".$e->error); $session->errorHandler->debug($e->package.":".$e->line." - ".$e->trace);