Commerce changes:

Credit Card failures now bounce user back to checkout screen with error there
Added Check commerce plugin and removed select box from Cash plugin.  Users now don't have to chose twice.
Added label to each payment plugin.  ITransact module now defaults to "Credit Card" for display purposes.
This commit is contained in:
Frank Dillon 2007-07-26 21:15:48 +00:00
parent b5be9f79a3
commit 2c1005522b
9 changed files with 364 additions and 44 deletions

View file

@ -97,7 +97,13 @@ sub configurationForm {
$f = WebGUI::HTMLForm->new($self->session);
my $i18n = WebGUI::International->new($self->session, 'Commerce');
$f->yesNo(
$f->text(
-name => $self->prepend('label'),
-value => $self->label,
-label => $i18n->get('label'),
-hoverHelp => $i18n->get('label hoverhelp'),
);
$f->yesNo(
-name => $self->prepend('enabled'),
-value => $self->enabled,
-label => $i18n->get('enable'),
@ -289,6 +295,19 @@ sub errorCode {
#-------------------------------------------------------------------
=head2 label ( )
Returns the label for the commerce plugin.
=cut
sub label {
my $self = shift;
return $self->get("label") || $self->namespace;
}
#-------------------------------------------------------------------
=head2 load ( namespace )
A convienient method to load a plugin. It handles all error checking and stuff for you.

View file

@ -44,22 +44,16 @@ sub checkoutForm {
my ($self, $u, $f, %months, %years, $i18n);
$self = shift;
$i18n = WebGUI::International->new($self->session, 'CommercePaymentCash');
$i18n = $self->i18n;
$u = WebGUI::User->new($self->session,$self->session->user->userId);
$f = WebGUI::HTMLForm->new($self->session);
$f->selectBox(
-name=>"paymentMethod",
-label=>$i18n->get("payment method"),
-value=>[$self->session->form->process("paymentMethod")],
-defaultValue=>['cash'],
-options=> { 'cash' => $i18n->get('cash'),
'check' => $i18n->get('check'),
'other' => $i18n->get('other'),
}
);
$f->readOnly(
-label=>$i18n->get("payment method"),
-value=>ucfirst($self->getPaymentMethod),
);
$f->text(
-name => 'firstName',
@ -115,8 +109,7 @@ sub checkoutForm {
sub configurationForm {
my ($self, $f, $i18n);
$self = shift;
$i18n = WebGUI::International->new($self->session, 'CommercePaymentCash');
$i18n = $self->i18n;
$f = WebGUI::HTMLForm->new($self->session);
$f->textarea(
@ -131,7 +124,6 @@ sub configurationForm {
-label => $i18n->get('complete transaction'),
-hoverHelp => $i18n->get('complete transaction description'),
);
return $self->SUPER::configurationForm($f->printRowsOnly);
}
@ -141,6 +133,15 @@ sub confirmTransaction {
return 0;
}
#-------------------------------------------------------------------
sub i18n {
my $self = shift;
unless (exists $self->{_i18n}) {
$self->{_i18n} = WebGUI::International->new($self->session,'CommercePaymentCash');
}
return $self->{_i18n};
}
#-------------------------------------------------------------------
=head2 init ( namespace )
@ -161,18 +162,25 @@ sub init {
my ($class, $self);
$class = shift;
my $session = shift;
$self = $class->SUPER::init($session,'Cash');
my $namespace = shift || 'Cash';
$self = $class->SUPER::init($session,$namespace);
return $self;
}
#-------------------------------------------------------------------
sub gatewayId {
my $self = shift;
return $self->get('paymentMethod').":".$self->session->id->generate;
return $self->getPaymentMethod.":".$self->session->id->generate;
}
#-------------------------------------------------------------------
sub getPaymentMethod {
my $self = shift;
unless($self->{_paymentMethod}) {
$self->{_paymentMethod} = "cash";
}
return $self->{_paymentMethod};
}
#-------------------------------------------------------------------
sub errorCode {
@ -180,6 +188,19 @@ sub errorCode {
return $self->{_error}->{code};
}
#-------------------------------------------------------------------
=head2 label ( )
Returns the label for the commerce plugin.
=cut
sub label {
my $self = shift;
my $i18n = $self->i18n;
return $self->get("label") || $i18n->get("label");
}
#-------------------------------------------------------------------
sub name {
return 'Cash';
@ -198,7 +219,7 @@ sub normalTransaction {
$normal = shift;
if ($normal) {
my $i18n = WebGUI::International->new($self->session, 'CommercePaymentCash');
my $i18n = $self->i18n;
$self->{_transactionParams} = {
AMT => sprintf('%.2f', $normal->{amount}),
DESCRIPTION => $normal->{description} || $i18n->get('no description'),
@ -260,7 +281,7 @@ sub validateFormData {
my ($self, @error, $i18n, $currentYear, $currentMonth);
$self = shift;
$i18n = WebGUI::International->new($self->session,'CommercePaymentCash');
$i18n = $self->i18n;
push (@error, $i18n->get('invalid firstName')) unless ($self->session->form->process("firstName"));
push (@error, $i18n->get('invalid lastName')) unless ($self->session->form->process("lastName"));
@ -271,7 +292,8 @@ sub validateFormData {
unless (@error) {
$self->{_paymentData} = {
PAYMENTMETHOD => $self->session->form->process("paymentMethod"),
PAYMENTMETHOD => $self->getPaymentMethod,
#$self->session->form->process("paymentMethod"),
};
$self->{_userData} = {

View file

@ -0,0 +1,84 @@
package WebGUI::Commerce::Payment::Check;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2007 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com info@plainblack.com
-------------------------------------------------------------------
=head1 NAME
Package WebGUI::Commerce::Payment::Check
=head1 DESCRIPTION
Payment plug-in for check transactions.
=cut
use strict;
use WebGUI::HTMLForm;
use WebGUI::Commerce::Payment;
use WebGUI::Commerce::Item;
use Tie::IxHash;
use WebGUI::International;
use WebGUI::SQL;
use base 'WebGUI::Commerce::Payment::Cash';
#-------------------------------------------------------------------
sub getPaymentMethod {
my $self = shift;
unless($self->{_paymentMethod}) {
$self->{_paymentMethod} = "check";
}
return $self->{_paymentMethod};
}
#-------------------------------------------------------------------
sub i18n {
my $self = shift;
unless (exists $self->{_i18n}) {
$self->{_i18n} = WebGUI::International->new($self->session,'CommercePaymentCheck');
}
return $self->{_i18n};
}
#-------------------------------------------------------------------
=head2 init ( namespace )
Constructor for the Check plugin.
=head3 session
A copy of the session object
=head3 namespace
The namespace of the plugin.
=cut
sub init {
my ($class, $self);
$class = shift;
my $session = shift;
my $namespace = shift || 'Check';
$self = $class->SUPER::init($session,$namespace);
return $self;
}
#-------------------------------------------------------------------
sub name {
return 'Check';
}
1;

View file

@ -353,6 +353,20 @@ sub errorCode {
return undef;
}
#-------------------------------------------------------------------
=head2 label ( )
Returns the label for the commerce plugin.
=cut
sub label {
my $self = shift;
my $i18n = WebGUI::International->new($self->session,'CommercePaymentITransact');
return $self->get("label") || $i18n->get("label");
}
#-------------------------------------------------------------------
sub name {
return 'ITransact';