Refactor out a default www_getCredentials all the way back to PayDriver, to be used by Cash and the PayPal brothers.

This commit is contained in:
Colin Kuskie 2010-04-29 13:02:26 -07:00
parent 006d1efffc
commit 921f03c107
3 changed files with 68 additions and 75 deletions

View file

@ -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.

View file

@ -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;