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:
parent
006d1efffc
commit
921f03c107
3 changed files with 68 additions and 75 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue