diff --git a/lib/WebGUI/Shop/PayDriver.pm b/lib/WebGUI/Shop/PayDriver.pm index b9068d928..8828af211 100644 --- a/lib/WebGUI/Shop/PayDriver.pm +++ b/lib/WebGUI/Shop/PayDriver.pm @@ -365,6 +365,19 @@ sub getAddress { #------------------------------------------------------------------- +=head2 getButton ( ) + +Used for the generic, vanilla checkout form. Must be overridden by any methods that +use the default www_getCredentials. + +=cut + +sub getButton { + return ''; +} + +#------------------------------------------------------------------- + =head2 getCart ( ) Returns the WebGUI::Shop::Cart object for the current session. @@ -373,9 +386,7 @@ Returns the WebGUI::Shop::Cart object for the current session. sub getCart { my $self = shift; - my $cart = WebGUI::Shop::Cart->newBySession( $self->session ); - return $cart; } @@ -722,6 +733,40 @@ a GUID. #------------------------------------------------------------------- +=head2 www_getCredentials ( ) + +Displays a summary of the cart, and a button to checkout. Plugins that need to get additional +information, or perform additional checks, should override this method. Uses the getButton +method to create the checkout button. + +=cut + +sub www_getCredentials { + my ($self) = @_; + my $session = $self->session; + + # Generate 'Proceed' button + my $i18n = WebGUI::International->new($session, 'PayDriver_Cash'); + my $var = { + proceedButton => $self->getButton, + }; + $self->appendCartVariables($var); + + my $template = WebGUI::Asset::Template->new($session, $self->get("summaryTemplateId")); + my $output; + if (defined $template) { + $template->prepare; + $output = $template->process($var); + } + else { + $output = $i18n->get('template gone', 'PayDriver_ITransact'); + } + + return $session->style->userStyle($output); +} + +#------------------------------------------------------------------- + =head2 www_edit ( ) Generates an edit form. diff --git a/lib/WebGUI/Shop/PayDriver/Cash.pm b/lib/WebGUI/Shop/PayDriver/Cash.pm index 348adfe1c..0aa77c97d 100644 --- a/lib/WebGUI/Shop/PayDriver/Cash.pm +++ b/lib/WebGUI/Shop/PayDriver/Cash.pm @@ -75,6 +75,27 @@ sub definition { #------------------------------------------------------------------- +=head2 getButton ( ) + +Return a form with button to finalize checkout from the Shop. + +=cut + +sub getButton { + my ($self) = @_; + my $session = $self->session; + + # Generate 'Proceed' button + my $i18n = WebGUI::International->new($session, 'PayDriver_Cash'); + return WebGUI::Form::formHeader( $session ) + . $self->getDoFormTags('pay') + . WebGUI::Form::submit( $session, { value => $i18n->get('Pay') } ) + . WebGUI::Form::formFooter( $session) + ; +} + +#------------------------------------------------------------------- + =head2 processPayment ( ) Returns (1, undef, 1, 'Success'), meaning that the payments whith this plugin always are successful. @@ -87,46 +108,6 @@ sub processPayment { #------------------------------------------------------------------- -=head2 www_getCredentials ( [ addressId ] ) - -Displays the checkout form for this plugin. - -=head3 addressId - -Optionally supply this variable which will set the payment address to this addressId. - -=cut - -sub www_getCredentials { - my ($self, $addressId) = @_; - my $session = $self->session; - - # Generate 'Proceed' button - my $i18n = WebGUI::International->new($session, 'PayDriver_Cash'); - my $var = { - proceedButton => WebGUI::Form::formHeader( $session ) - . $self->getDoFormTags('pay') - . WebGUI::Form::submit( $session, { value => $i18n->get('Pay') } ) - . WebGUI::Form::formFooter( $session) - , - }; - $self->appendCartVariables($var); - - my $template = WebGUI::Asset::Template->new($session, $self->get("summaryTemplateId")); - my $output; - if (defined $template) { - $template->prepare; - $output = $template->process($var); - } - else { - $output = $i18n->get('template gone', 'PayDriver_ITransact'); - } - - return $session->style->userStyle($output); -} - -#------------------------------------------------------------------- - =head2 www_pay ( ) Checks credentials, and completes the transaction if those are correct. diff --git a/lib/WebGUI/Shop/PayDriver/PayPal.pm b/lib/WebGUI/Shop/PayDriver/PayPal.pm index 346771e5d..d7d41558e 100644 --- a/lib/WebGUI/Shop/PayDriver/PayPal.pm +++ b/lib/WebGUI/Shop/PayDriver/PayPal.pm @@ -338,37 +338,4 @@ sub getPaypalCountry { return $retcode; } -#------------------------------------------------------------------- - -=head2 www_getCredentials ( ) - -Displays the checkout form for this plugin. - -=cut - -sub www_getCredentials { - my ($self, $addressId) = @_; - my $session = $self->session; - - # Generate 'Proceed' button - my $i18n = WebGUI::International->new($session, 'PayDriver_PayPalStd'); - my $var = { - proceedButton => $self->getButton, - }; - $self->appendCartVariables($var); - - my $template = WebGUI::Asset::Template->new($session, $self->get("summaryTemplateId")); - my $output; - if (defined $template) { - $template->prepare; - $output = $template->process($var); - } - else { - $output = $i18n->get('template gone', 'PayDriver_ITransact'); - } - - return $session->style->userStyle($output); -} - 1; -