more session related changes
This commit is contained in:
parent
16b9675b0c
commit
024514c549
106 changed files with 1498 additions and 1313 deletions
|
|
@ -55,7 +55,7 @@ This returns the description of the item. This must be implemented by an item pl
|
|||
=cut
|
||||
|
||||
sub description {
|
||||
return WebGUI::ErrorHandler::fatal('The description method of WebGUI::Commerce::Item must be overridden.');
|
||||
return $self->session->errorHandler->fatal('The description method of WebGUI::Commerce::Item must be overridden.');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -95,7 +95,7 @@ by an item plugin.
|
|||
=cut
|
||||
|
||||
sub id {
|
||||
return WebGUI::ErrorHandler::fatal('The id method of WebGUI::Commerce::Item must be overridden.');
|
||||
return $self->session->errorHandler->fatal('The id method of WebGUI::Commerce::Item must be overridden.');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -120,7 +120,7 @@ Returns the name of the item. This must be implemented by an item plugin.
|
|||
=cut
|
||||
|
||||
sub name {
|
||||
return WebGUI::ErrorHandler::fatal('The name method of WebGUI::Commerce::Item must be overridden.');
|
||||
return $self->session->errorHandler->fatal('The name method of WebGUI::Commerce::Item must be overridden.');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -160,15 +160,15 @@ sub new {
|
|||
$id = shift;
|
||||
$namespace = shift;
|
||||
|
||||
WebGUI::ErrorHandler::fatal('No namespace') unless ($namespace);
|
||||
WebGUI::ErrorHandler::fatal('No ID') unless ($id);
|
||||
$self->session->errorHandler->fatal('No namespace') unless ($namespace);
|
||||
$self->session->errorHandler->fatal('No ID') unless ($id);
|
||||
|
||||
$cmd = "WebGUI::Commerce::Item::$namespace";
|
||||
$load = "use $cmd";
|
||||
eval($load);
|
||||
WebGUI::ErrorHandler::warn("Item plugin failed to compile: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Item plugin failed to compile: $cmd.".$@) if($@);
|
||||
$plugin = eval($cmd."->new('$id', '$namespace')");
|
||||
WebGUI::ErrorHandler::warn("Couldn't instantiate Item plugin: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Couldn't instantiate Item plugin: $cmd.".$@) if($@);
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
|
|
@ -182,7 +182,7 @@ term price. This must be implemented by an item plugin.
|
|||
=cut
|
||||
|
||||
sub price {
|
||||
return WebGUI::ErrorHandler::fatalError('The price method of WebGUI::Commerce::Item must be overridden.');
|
||||
return $self->session->errorHandler->fatalError('The price method of WebGUI::Commerce::Item must be overridden.');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -194,7 +194,7 @@ Returns the type (namespace) of the item.
|
|||
=cut
|
||||
|
||||
sub type {
|
||||
return WebGUI::ErrorHandler::fatalError('The type method of WebGUI::Commerce::Item must be overridden.');
|
||||
return $self->session->errorHandler->fatalError('The type method of WebGUI::Commerce::Item must be overridden.');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ Returns a reference to an array of all enabled instantiated payment plugins.
|
|||
|
||||
sub getEnabledPlugins {
|
||||
my (@enabledPlugins, $plugin, @plugins);
|
||||
@enabledPlugins = WebGUI::SQL->buildArray("select namespace from commerceSettings where type='Payment' and fieldName='enabled' and fieldValue='1'");
|
||||
@enabledPlugins = $self->session->db->buildArray("select namespace from commerceSettings where type='Payment' and fieldName='enabled' and fieldValue='1'");
|
||||
|
||||
foreach (@enabledPlugins) {
|
||||
$plugin = WebGUI::Commerce::Payment->load($_);
|
||||
|
|
@ -200,7 +200,7 @@ sub init {
|
|||
$class = shift;
|
||||
$namespace = shift;
|
||||
|
||||
$properties = WebGUI::SQL->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".quote($namespace)." and type='Payment'");
|
||||
$properties = $self->session->db->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".$self->session->db->quote($namespace)." and type='Payment'");
|
||||
|
||||
bless {_properties=>$properties, _namespace=>$namespace, _enabled=>$properties->{enabled}}, $class;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ Returns the gatewayId of the transaction. You must override this method.
|
|||
=cut
|
||||
|
||||
sub gatewayId {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the gatewayId method in your Payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the gatewayId method in your Payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -252,7 +252,7 @@ Returns the error code of the last submission.
|
|||
=cut
|
||||
|
||||
sub errorCode {
|
||||
return WebGUI::ErrorHandler::fatal("You must override thie errorCode method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override thie errorCode method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -276,9 +276,9 @@ sub load {
|
|||
$cmd = "WebGUI::Commerce::Payment::$namespace";
|
||||
$load = "use $cmd";
|
||||
eval($load);
|
||||
WebGUI::ErrorHandler::warn("Payment plugin failed to compile: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Payment plugin failed to compile: $cmd.".$@) if($@);
|
||||
$plugin = eval($cmd."->init");
|
||||
WebGUI::ErrorHandler::warn("Couldn't instantiate payment plugin: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Couldn't instantiate payment plugin: $cmd.".$@) if($@);
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
|
|
@ -291,7 +291,7 @@ Returns the (display) name of the plugin. You must override this method.
|
|||
=cut
|
||||
|
||||
sub name {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the name method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the name method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -362,7 +362,7 @@ Returns the result code of the transaction. You must override this method.
|
|||
=cut
|
||||
|
||||
sub resultCode {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the resultCode method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the resultCode method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -374,7 +374,7 @@ Returns the result message of the transaction. You must override this method.
|
|||
=cut
|
||||
|
||||
sub resultMessage {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the resultMessage method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the resultMessage method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -449,7 +449,7 @@ The amaount of money that's being charged for shipping.
|
|||
=cut
|
||||
|
||||
sub shippingCost {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the shippingCost method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the shippingCost method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -466,7 +466,7 @@ The description of the shiping cost.
|
|||
=cut
|
||||
|
||||
sub shippingDescription {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the shippingDescription method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the shippingDescription method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -483,7 +483,7 @@ You must override this method.
|
|||
=cut
|
||||
|
||||
sub supports {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the supports method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the supports method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -495,7 +495,7 @@ A boolean indicating whether the payment has been finished or not. You must over
|
|||
=cut
|
||||
|
||||
sub transactionCompleted {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the transactionCompleted method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the transactionCompleted method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -507,7 +507,7 @@ Returns an error message if a transaction error has occurred. You must override
|
|||
=cut
|
||||
|
||||
sub transactionError {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the transactionError method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the transactionError method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -519,7 +519,7 @@ A boolean indicating whether the payment is pending or not. You must override th
|
|||
=cut
|
||||
|
||||
sub transactionPending {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the transactionPending method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the transactionPending method in the payment plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -533,7 +533,7 @@ undef. You must override this method.
|
|||
=cut
|
||||
|
||||
sub validateFormData {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the validateFormData method in the payment plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the validateFormData method in the payment plugin.");
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ sub cancelRecurringPayment {
|
|||
# print "FIRST PAGE SUCCESS!\n";
|
||||
# print "(".$response->base.")\n";
|
||||
} else {
|
||||
WebGUI::ErrorHandler::fatalError(
|
||||
$self->session->errorHandler->fatalError(
|
||||
'Connection Error while trying to cancel transaction '.$recurring->{transaction}->transactionId." \n".
|
||||
"Could not reach login page.\n".
|
||||
"(".$response->base.")\n".
|
||||
|
|
@ -84,7 +84,7 @@ sub cancelRecurringPayment {
|
|||
# print "CANCELATION PAGE SUCCESS!\n";
|
||||
# print "(".$response->base.")\n";
|
||||
} else {
|
||||
WebGUI::ErrorHandler::fatalError(
|
||||
$self->session->errorHandler->fatalError(
|
||||
'Connection Error while trying to cancel transaction '.$recurring->{transaction}->transactionId." \n".
|
||||
"(".$response->base.")\n".
|
||||
$response->status_line. "\n");
|
||||
|
|
@ -108,38 +108,38 @@ sub checkoutForm {
|
|||
|
||||
$i18n = WebGUI::International->new('CommercePaymentITransact');
|
||||
|
||||
$u = WebGUI::User->new($session{user}{userId});
|
||||
$u = WebGUI::User->new($self->session->user->profileField("userId"));
|
||||
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
$f->text(
|
||||
-name => 'firstName',
|
||||
-label => $i18n->get('firstName'),
|
||||
-value => $session{form}{firstName} || $u->profileField('firstName')
|
||||
-value => $self->session->form->process("firstName") || $u->profileField('firstName')
|
||||
);
|
||||
$f->text(
|
||||
-name => 'lastName',
|
||||
-label => $i18n->get('lastName'),
|
||||
-value => $session{form}{lastName} || $u->profileField('lastName')
|
||||
-value => $self->session->form->process("lastName") || $u->profileField('lastName')
|
||||
);
|
||||
$f->text(
|
||||
-name => 'address',
|
||||
-label => $i18n->get('address'),
|
||||
-value => $session{form}{address} || $u->profileField('homeAddress')
|
||||
-value => $self->session->form->process("address") || $u->profileField('homeAddress')
|
||||
);
|
||||
$f->text(
|
||||
-name => 'city',
|
||||
-label => $i18n->get('city'),
|
||||
-value => $session{form}{city} || $u->profileField('homeCity')
|
||||
-value => $self->session->form->process("city") || $u->profileField('homeCity')
|
||||
);
|
||||
$f->text(
|
||||
-name => 'state',
|
||||
-label => $i18n->get('state'),
|
||||
-value => $session{form}{state} || $u->profileField('homeState')
|
||||
-value => $self->session->form->process("state") || $u->profileField('homeState')
|
||||
);
|
||||
$f->zipcode(
|
||||
-name => 'zipcode',
|
||||
-label => $i18n->get('zipcode'),
|
||||
-value => $session{form}{zipcode} || $u->profileField('homeZip')
|
||||
-value => $self->session->form->process("zipcode") || $u->profileField('homeZip')
|
||||
);
|
||||
my %countries;
|
||||
tie %countries, 'Tie::IxHash';
|
||||
|
|
@ -389,25 +389,25 @@ sub checkoutForm {
|
|||
$f->selectBox(
|
||||
-name=>"country",
|
||||
-label=>$i18n->get("country"),
|
||||
-value=>[$session{form}{country}],
|
||||
-value=>[$self->session->form->process("country")],
|
||||
-defaultValue=>[$u->profileField("homeCountry")],
|
||||
-options=>\%countries
|
||||
);
|
||||
$f->phone(
|
||||
-name=>"phone",
|
||||
-label=>$i18n->get("phone"),
|
||||
-value=>$session{form}{phone},
|
||||
-value=>$self->session->form->process("phone"),
|
||||
-defaultValue=>$u->profileField("homePhone")
|
||||
);
|
||||
$f->email(
|
||||
-name => 'email',
|
||||
-label => $i18n->get('email'),
|
||||
-value => $session{form}{email} || $u->profileField('email')
|
||||
-value => $self->session->form->process("email") || $u->profileField('email')
|
||||
);
|
||||
$f->text(
|
||||
-name => 'cardNumber',
|
||||
-label => $i18n->get('cardNumber'),
|
||||
-value => $session{form}{cardNumber}
|
||||
-value => $self->session->form->process("cardNumber")
|
||||
);
|
||||
tie %months, "Tie::IxHash";
|
||||
%months = map {sprintf('%02d',$_) => sprintf('%02d',$_)} 1..12;
|
||||
|
|
@ -416,14 +416,14 @@ sub checkoutForm {
|
|||
$f->readOnly(
|
||||
-label => $i18n->get('expiration date'),
|
||||
-value =>
|
||||
WebGUI::Form::selectBox({name => 'expMonth', options => \%months, value => [$session{form}{expMonth}]}).
|
||||
WebGUI::Form::selectBox({name => 'expMonth', options => \%months, value => [$self->session->form->process("expMonth")]}).
|
||||
" / ".
|
||||
WebGUI::Form::selectBox({name => 'expYear', options => \%years, value => [$session{form}{expYear}]})
|
||||
WebGUI::Form::selectBox({name => 'expYear', options => \%years, value => [$self->session->form->process("expYear")]})
|
||||
);
|
||||
$f->integer(
|
||||
-name => 'cvv2',
|
||||
-label => $i18n->get('cvv2'),
|
||||
-value => $session{form}{cvv2}
|
||||
-value => $self->session->form->process("cvv2")
|
||||
) if ($self->get('useCVV2'));
|
||||
|
||||
return $f->printRowsOnly;
|
||||
|
|
@ -468,7 +468,7 @@ sub configurationForm {
|
|||
-value => '<br />'
|
||||
);
|
||||
$f->readOnly(
|
||||
-value => $i18n->get('extra info').'<br /><b>https://'.$session{config}{defaultSitename}.'/?op=confirmRecurringTransaction;gateway='.$self->namespace
|
||||
-value => $i18n->get('extra info').'<br /><b>https://'.$self->session->config->get("defaultSitename").'/?op=confirmRecurringTransaction;gateway='.$self->namespace
|
||||
);
|
||||
|
||||
return $self->SUPER::configurationForm($f->printRowsOnly);
|
||||
|
|
@ -480,18 +480,18 @@ sub confirmRecurringTransaction {
|
|||
my $self = shift;
|
||||
|
||||
my $form = $session{form};
|
||||
my $transaction = WebGUI::Commerce::Transaction->getByGatewayId($session{form}{orig_xid}, $self->namespace);
|
||||
my $transaction = WebGUI::Commerce::Transaction->getByGatewayId($self->session->form->process("orig_xid"), $self->namespace);
|
||||
my $itemProperties = $transaction->getItems->[0];
|
||||
my $item = WebGUI::Commerce::Item->new($itemProperties->{itemId}, $itemProperties->{itemType});
|
||||
|
||||
my $startEpoch = WebGUI::DateTime::setToEpoch(sprintf("%4d-%02d-%02d %02d:%02d:%02d", unpack('a4a2a2a2a2a2', $form->{start_date})));
|
||||
my $currentEpoch = WebGUI::DateTime::setToEpoch(sprintf("%4d-%02d-%02d %02d:%02d:%02d", unpack('a4a2a2a2a2a2', $form->{when})));
|
||||
|
||||
WebGUI::SQL->write("delete from ITransact_recurringStatus where gatewayId=".quote($form->{orig_xid}));
|
||||
WebGUI::SQL->write("insert into ITransact_recurringStatus ".
|
||||
$self->session->db->write("delete from ITransact_recurringStatus where gatewayId=".$self->session->db->quote($form->{orig_xid}));
|
||||
$self->session->db->write("insert into ITransact_recurringStatus ".
|
||||
"(gatewayId, initDate, lastTransaction, status, errorMessage, recipe) values ".
|
||||
"(".quote($form->{orig_xid}).", $startEpoch, $currentEpoch, ".quote($form->{status}).", ".quote($form->{error_message}).
|
||||
", ".quote($form->{recipe_name}).")");
|
||||
"(".$self->session->db->quote($form->{orig_xid}).", $startEpoch, $currentEpoch, ".$self->session->db->quote($form->{status}).", ".$self->session->db->quote($form->{error_message}).
|
||||
", ".$self->session->db->quote($form->{recipe_name}).")");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -534,9 +534,9 @@ sub getRecurringPaymentStatus {
|
|||
yearly => 365*3600*24
|
||||
);
|
||||
|
||||
my $transactionData = WebGUI::SQL->quickHashRef("select * from ITransact_recurringStatus where gatewayId=".quote($recurringId));
|
||||
my $transactionData = $self->session->db->quickHashRef("select * from ITransact_recurringStatus where gatewayId=".$self->session->db->quote($recurringId));
|
||||
unless ($transactionData->{recipe}) { # if for some reason there's no transaction data, we shouldn't calc anything
|
||||
WebGUI::ErrorHandler::error("For some reason recurring transaction $recurringId doesn't have any recurring status transaction data. This is most likely because you don't have the Recurring Postback URL set in your ITransact virtual terminal.");
|
||||
$self->session->errorHandler->error("For some reason recurring transaction $recurringId doesn't have any recurring status transaction data. This is most likely because you don't have the Recurring Postback URL set in your ITransact virtual terminal.");
|
||||
return undef;
|
||||
}
|
||||
my $lastTerm = int(($transactionData->{lastTransaction} - $transactionData->{initDate}) / $resolve{$transactionData->{recipe}}) + 1;
|
||||
|
|
@ -691,7 +691,7 @@ my %transactionData = %{$self->{_transactionParams}};
|
|||
<TransactionData>
|
||||
<VendorId>".$self->get('vendorId')."</VendorId>
|
||||
<VendorPassword>".$self->get('password')."</VendorPassword>
|
||||
<HomePage>".$session{setting}{companyURL}."</HomePage>";
|
||||
<HomePage>".$self->session->setting->get("companyURL")."</HomePage>";
|
||||
|
||||
if ($self->{_recurring}) {
|
||||
$xml .=
|
||||
|
|
@ -804,44 +804,44 @@ sub validateFormData {
|
|||
|
||||
$i18n = WebGUI::International->new('CommercePaymentITransact');
|
||||
|
||||
push (@error, $i18n->get('invalid firstName')) unless ($session{form}{firstName});
|
||||
push (@error, $i18n->get('invalid lastName')) unless ($session{form}{lastName});
|
||||
push (@error, $i18n->get('invalid address')) unless ($session{form}{address});
|
||||
push (@error, $i18n->get('invalid city')) unless ($session{form}{city});
|
||||
push (@error, $i18n->get('invalid zip')) if ($session{form}{zipcode} eq "" && $session{form}{country} eq "United States");
|
||||
push (@error, $i18n->get('invalid email')) unless ($session{form}{email});
|
||||
push (@error, $i18n->get('invalid firstName')) unless ($self->session->form->process("firstName"));
|
||||
push (@error, $i18n->get('invalid lastName')) unless ($self->session->form->process("lastName"));
|
||||
push (@error, $i18n->get('invalid address')) unless ($self->session->form->process("address"));
|
||||
push (@error, $i18n->get('invalid city')) unless ($self->session->form->process("city"));
|
||||
push (@error, $i18n->get('invalid zip')) if ($self->session->form->process("zipcode") eq "" && $self->session->form->process("country") eq "United States");
|
||||
push (@error, $i18n->get('invalid email')) unless ($self->session->form->process("email"));
|
||||
|
||||
push (@error, $i18n->get('invalid card number')) unless ($session{form}{cardNumber} =~ /^\d+$/);
|
||||
push (@error, $i18n->get('invalid cvv2')) if ($session{form}{cvv2} !~ /^\d+$/ && $self->get('useCVV2'));
|
||||
push (@error, $i18n->get('invalid card number')) unless ($self->session->form->process("cardNumber") =~ /^\d+$/);
|
||||
push (@error, $i18n->get('invalid cvv2')) if ($self->session->form->process("cvv2") !~ /^\d+$/ && $self->get('useCVV2'));
|
||||
|
||||
($currentYear, $currentMonth) = WebGUI::DateTime::localtime;
|
||||
|
||||
# Check if expDate and expYear have sane values
|
||||
unless (($session{form}{expMonth} =~ /^(0[1-9]|1[0-2])$/) && ($session{form}{expYear} =~ /^\d\d\d\d$/)) {
|
||||
unless (($self->session->form->process("expMonth") =~ /^(0[1-9]|1[0-2])$/) && ($self->session->form->process("expYear") =~ /^\d\d\d\d$/)) {
|
||||
push (@error, $i18n->get('invalid expiration date'));
|
||||
} elsif (($session{form}{expYear} < $currentYear) ||
|
||||
(($session{form}{expYear} == $currentYear) && ($session{form}{expMonth} < $currentMonth))) {
|
||||
} elsif (($self->session->form->process("expYear") < $currentYear) ||
|
||||
(($self->session->form->process("expYear") == $currentYear) && ($self->session->form->process("expMonth") < $currentMonth))) {
|
||||
push (@error, $i18n->get('invalid expiration date'));
|
||||
}
|
||||
|
||||
unless (@error) {
|
||||
$self->{_cardData} = {
|
||||
ACCT => $session{form}{cardNumber},
|
||||
EXPMONTH => $session{form}{expMonth},
|
||||
EXPYEAR => $session{form}{expYear},
|
||||
CVV2 => $session{form}{cvv2},
|
||||
ACCT => $self->session->form->process("cardNumber"),
|
||||
EXPMONTH => $self->session->form->process("expMonth"),
|
||||
EXPYEAR => $self->session->form->process("expYear"),
|
||||
CVV2 => $self->session->form->process("cvv2"),
|
||||
};
|
||||
|
||||
$self->{_userData} = {
|
||||
STREET => $session{form}{address},
|
||||
ZIP => $session{form}{zipcode},
|
||||
CITY => $session{form}{city},
|
||||
FIRSTNAME => $session{form}{firstName},
|
||||
LASTNAME => $session{form}{lastName},
|
||||
EMAIL => $session{form}{email},
|
||||
STATE => $session{form}{state},
|
||||
COUNTRY => $session{form}{country},
|
||||
PHONE => $session{form}{phone},
|
||||
STREET => $self->session->form->process("address"),
|
||||
ZIP => $self->session->form->process("zipcode"),
|
||||
CITY => $self->session->form->process("city"),
|
||||
FIRSTNAME => $self->session->form->process("firstName"),
|
||||
LASTNAME => $self->session->form->process("lastName"),
|
||||
EMAIL => $self->session->form->process("email"),
|
||||
STATE => $self->session->form->process("state"),
|
||||
COUNTRY => $self->session->form->process("country"),
|
||||
PHONE => $self->session->form->process("phone"),
|
||||
};
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ Returns a reference to an array of all enabled instantiated payment plugins.
|
|||
|
||||
sub getEnabledPlugins {
|
||||
my (@enabledPlugins, $plugin, @plugins);
|
||||
@enabledPlugins = WebGUI::SQL->buildArray("select namespace from commerceSettings where type='Shipping' and fieldName='enabled' and fieldValue='1'");
|
||||
@enabledPlugins = $self->session->db->buildArray("select namespace from commerceSettings where type='Shipping' and fieldName='enabled' and fieldValue='1'");
|
||||
|
||||
foreach (@enabledPlugins) {
|
||||
$plugin = WebGUI::Commerce::Shipping->load($_);
|
||||
|
|
@ -161,9 +161,9 @@ sub init {
|
|||
$class = shift;
|
||||
$namespace = shift;
|
||||
|
||||
WebGUI::ErrorHandler::fatal('No namespace passed to init.') unless ($namespace);
|
||||
$self->session->errorHandler->fatal('No namespace passed to init.') unless ($namespace);
|
||||
|
||||
$properties = WebGUI::SQL->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".quote($namespace)." and type='Shipping'");
|
||||
$properties = $self->session->db->buildHashRef("select fieldName, fieldValue from commerceSettings where namespace=".$self->session->db->quote($namespace)." and type='Shipping'");
|
||||
$shoppingCart = WebGUI::Commerce::ShoppingCart->new;
|
||||
|
||||
bless {_properties=>$properties,
|
||||
|
|
@ -204,14 +204,14 @@ sub load {
|
|||
$class = shift;
|
||||
$namespace = shift;
|
||||
|
||||
WebGUI::ErrorHandler::fatal('No namespace passed to load.') unless ($namespace);
|
||||
$self->session->errorHandler->fatal('No namespace passed to load.') unless ($namespace);
|
||||
|
||||
$cmd = "WebGUI::Commerce::Shipping::$namespace";
|
||||
$load = "use $cmd";
|
||||
eval($load);
|
||||
WebGUI::ErrorHandler::warn("Shipping plugin failed to compile: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Shipping plugin failed to compile: $cmd.".$@) if($@);
|
||||
$plugin = eval($cmd."->init");
|
||||
WebGUI::ErrorHandler::warn("Couldn't instantiate shipping plugin: $cmd.".$@) if($@);
|
||||
$self->session->errorHandler->warn("Couldn't instantiate shipping plugin: $cmd.".$@) if($@);
|
||||
return $plugin;
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ Returns the (display) name of the plugin. You must override this method.
|
|||
=cut
|
||||
|
||||
sub name {
|
||||
return WebGUI::ErrorHandler::fatal("You must override the name method in the shipping plugin.");
|
||||
return $self->session->errorHandler->fatal("You must override the name method in the shipping plugin.");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -74,10 +74,10 @@ sub add {
|
|||
quantity => $self->{_items}{$itemId."_".$itemType}{quantity} + $quantity
|
||||
};
|
||||
|
||||
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId})." and itemId=".quote($itemId)." and itemType=".quote($itemType));
|
||||
WebGUI::SQL->write("insert into shoppingCart ".
|
||||
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId})." and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
|
||||
$self->session->db->write("insert into shoppingCart ".
|
||||
"(sessionId, itemId, itemType, quantity) values ".
|
||||
"(".quote($self->{_sessionId}).",".quote($itemId).",".quote($itemType).",".$self->{_items}{$itemId."_".$itemType}{quantity}.")");
|
||||
"(".$self->session->db->quote($self->{_sessionId}).",".$self->session->db->quote($itemId).",".$self->session->db->quote($itemType).",".$self->{_items}{$itemId."_".$itemType}{quantity}.")");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -103,8 +103,8 @@ sub delete {
|
|||
$itemId = shift;
|
||||
$itemType = shift;
|
||||
|
||||
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId}).
|
||||
" and itemId=".quote($itemId)." and itemType=".quote($itemType));
|
||||
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId}).
|
||||
" and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
|
||||
|
||||
delete $self->{_items}{$itemId."_".$itemType};
|
||||
}
|
||||
|
|
@ -143,14 +143,14 @@ sub setQuantity {
|
|||
$itemType = shift;
|
||||
$quantity = shift;
|
||||
|
||||
WebGUI::ErrorHandler::fatal('No quantity or quantity is not a number: ('.$quantity.')') unless ($quantity =~ /^-?\d+$/);
|
||||
$self->session->errorHandler->fatal('No quantity or quantity is not a number: ('.$quantity.')') unless ($quantity =~ /^-?\d+$/);
|
||||
|
||||
return $self->delete($itemId, $itemType) if ($quantity <= 0);
|
||||
|
||||
$self->{_items}{$itemId."_".$itemType}->{quantity} = $quantity;
|
||||
|
||||
WebGUI::SQL->write("update shoppingCart set quantity=".quote($quantity).
|
||||
" where sessionId=".quote($self->{_sessionId})." and itemId=".quote($itemId)." and itemType=".quote($itemType));
|
||||
$self->session->db->write("update shoppingCart set quantity=".$self->session->db->quote($quantity).
|
||||
" where sessionId=".$self->session->db->quote($self->{_sessionId})." and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -165,7 +165,7 @@ sub empty {
|
|||
my ($self);
|
||||
$self = shift;
|
||||
|
||||
WebGUI::SQL->write("delete from shoppingCart where sessionId=".quote($self->{_sessionId}));
|
||||
$self->session->db->write("delete from shoppingCart where sessionId=".$self->session->db->quote($self->{_sessionId}));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -246,9 +246,9 @@ of the current user.
|
|||
sub new {
|
||||
my ($class, $sessionId, $sth, $row, %items);
|
||||
$class = shift;
|
||||
$sessionId = shift || $session{var}{sessionId};
|
||||
$sessionId = shift || $self->session->var->get("sessionId");
|
||||
|
||||
$sth = WebGUI::SQL->read("select * from shoppingCart where sessionId=".quote($sessionId));
|
||||
$sth = $self->session->db->read("select * from shoppingCart where sessionId=".$self->session->db->quote($sessionId));
|
||||
while ($row = $sth->hashRef) {
|
||||
$items{$row->{itemId}."_".$row->{itemType}} = $row;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ sub addItem {
|
|||
$item = shift;
|
||||
$quantity = shift;
|
||||
|
||||
WebGUI::SQL->write("insert into transactionItem ".
|
||||
$self->session->db->write("insert into transactionItem ".
|
||||
"(transactionId, itemName, amount, quantity, itemId, itemType) values ".
|
||||
"(".quote($self->{_transactionId}).",".quote($item->name).",".quote($item->price).",".quote($quantity).",".
|
||||
quote($item->id).",".quote($item->type).")");
|
||||
"(".$self->session->db->quote($self->{_transactionId}).",".$self->session->db->quote($item->name).",".$self->session->db->quote($item->price).",".$self->session->db->quote($quantity).",".
|
||||
$self->session->db->quote($item->id).",".$self->session->db->quote($item->type).")");
|
||||
# Adjust total amount in the transaction table.
|
||||
WebGUI::SQL->write("update transaction set amount=amount+".($item->price * $quantity)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set amount=amount+".($item->price * $quantity)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
$self->{_properties}{amount} += ($item->price * $quantity);
|
||||
push @{$self->{_items}}, {
|
||||
transactionId => $self->{_transactionId},
|
||||
|
|
@ -107,8 +107,8 @@ Deletes the transaction from the database;
|
|||
sub delete {
|
||||
my ($self) = shift;
|
||||
|
||||
WebGUI::SQL->write("delete from transaction where transactionId=".quote($self->{_transactionId}));
|
||||
WebGUI::SQL->write("delete from transactionItem where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("delete from transaction where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
$self->session->db->write("delete from transactionItem where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
|
||||
undef $self;
|
||||
}
|
||||
|
|
@ -144,8 +144,8 @@ sub deleteItem {
|
|||
$itemId = shift;
|
||||
$itemType = shift;
|
||||
|
||||
WebGUI::ErrorHandler::fatal('No itemId') unless ($itemId);
|
||||
WebGUI::ErrorHandler::fatal('No itemType') unless ($itemType);
|
||||
$self->session->errorHandler->fatal('No itemId') unless ($itemId);
|
||||
$self->session->errorHandler->fatal('No itemType') unless ($itemType);
|
||||
|
||||
$amount = $self->get('amount');
|
||||
|
||||
|
|
@ -158,10 +158,10 @@ sub deleteItem {
|
|||
}
|
||||
}
|
||||
|
||||
WebGUI::SQL->write("delete from transactionItem where transactionId=".quote($self->get('transactionId')).
|
||||
" and itemId=".quote($itemId)." and itemType=".quote($itemType));
|
||||
$self->session->db->write("delete from transactionItem where transactionId=".$self->session->db->quote($self->get('transactionId')).
|
||||
" and itemId=".$self->session->db->quote($itemId)." and itemType=".$self->session->db->quote($itemType));
|
||||
|
||||
WebGUI::SQL->write("update transaction set amount=".quote($amount)." where transactionId=".quote($self->get('transactionId')));
|
||||
$self->session->db->write("update transaction set amount=".$self->session->db->quote($amount)." where transactionId=".$self->session->db->quote($self->get('transactionId')));
|
||||
|
||||
$self->{_properties}{amount} = $amount;
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ sub gateway {
|
|||
|
||||
if ($gateway) {
|
||||
$self->{_properties}{gateway} = $gateway;
|
||||
WebGUI::SQL->write("update transaction set gateway=".quote($gateway)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set gateway=".$self->session->db->quote($gateway)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{gateway};
|
||||
|
|
@ -212,7 +212,7 @@ sub gatewayId {
|
|||
|
||||
if ($gatewayId) {
|
||||
$self->{_properties}{gatewayId} = $gatewayId;
|
||||
WebGUI::SQL->write("update transaction set gatewayId=".quote($gatewayId)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set gatewayId=".$self->session->db->quote($gatewayId)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{gatewayId};
|
||||
|
|
@ -263,8 +263,8 @@ sub getByGatewayId {
|
|||
$gatewayId = shift;
|
||||
$paymentGateway = shift;
|
||||
|
||||
($transactionId) = WebGUI::SQL->quickArray("select transactionId from transaction where gatewayId=".quote($gatewayId).
|
||||
" and gateway=".quote($paymentGateway));
|
||||
($transactionId) = $self->session->db->quickArray("select transactionId from transaction where gatewayId=".$self->session->db->quote($gatewayId).
|
||||
" and gateway=".$self->session->db->quote($paymentGateway));
|
||||
|
||||
return WebGUI::Commerce::Transaction->new($transactionId) if $transactionId;
|
||||
return undef;
|
||||
|
|
@ -320,17 +320,17 @@ sub getTransactions {
|
|||
$self = shift;
|
||||
$criteria = shift;
|
||||
|
||||
push (@constraints, 'initDate >= '.quote($criteria->{initStart})) if (defined $criteria->{initStart});
|
||||
push (@constraints, 'initDate <= '.quote($criteria->{initStop})) if (defined $criteria->{initStop});
|
||||
push (@constraints, 'completionDate >= '.quote($criteria->{completionStart})) if (defined $criteria->{completionStart});
|
||||
push (@constraints, 'completionDate <= '.quote($criteria->{completionStop})) if (defined $criteria->{completionStop});
|
||||
push (@constraints, 'status='.quote($criteria->{paymentStatus})) if (defined $criteria->{paymentStatus});
|
||||
push (@constraints, 'shippingStatus='.quote($criteria->{shippingStatus})) if (defined $criteria->{shippingStatus});
|
||||
push (@constraints, 'initDate >= '.$self->session->db->quote($criteria->{initStart})) if (defined $criteria->{initStart});
|
||||
push (@constraints, 'initDate <= '.$self->session->db->quote($criteria->{initStop})) if (defined $criteria->{initStop});
|
||||
push (@constraints, 'completionDate >= '.$self->session->db->quote($criteria->{completionStart})) if (defined $criteria->{completionStart});
|
||||
push (@constraints, 'completionDate <= '.$self->session->db->quote($criteria->{completionStop})) if (defined $criteria->{completionStop});
|
||||
push (@constraints, 'status='.$self->session->db->quote($criteria->{paymentStatus})) if (defined $criteria->{paymentStatus});
|
||||
push (@constraints, 'shippingStatus='.$self->session->db->quote($criteria->{shippingStatus})) if (defined $criteria->{shippingStatus});
|
||||
|
||||
$sql = 'select transactionId from transaction';
|
||||
$sql .= ' where '.join(' and ', @constraints) if (@constraints);
|
||||
|
||||
@transactionIds = WebGUI::SQL->buildArray($sql);
|
||||
@transactionIds = $self->session->db->buildArray($sql);
|
||||
|
||||
foreach (@transactionIds) {
|
||||
push(@transactions, WebGUI::Commerce::Transaction->new($_));
|
||||
|
|
@ -360,7 +360,7 @@ sub isRecurring {
|
|||
|
||||
if (defined $recurring) {
|
||||
$self->{_properties}{recurring} = $recurring;
|
||||
WebGUI::SQL->write("update transaction set recurring=".quote($recurring)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set recurring=".$self->session->db->quote($recurring)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{recurring};
|
||||
|
|
@ -385,7 +385,7 @@ sub lastPayedTerm {
|
|||
|
||||
if (defined $lastPayedTerm) {
|
||||
$self->{_properties}{lastPayedTerm} = $lastPayedTerm;
|
||||
WebGUI::SQL->write("update transaction set lastPayedTerm=".quote($lastPayedTerm)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set lastPayedTerm=".$self->session->db->quote($lastPayedTerm)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{lastPayedTerm};
|
||||
|
|
@ -418,18 +418,18 @@ sub new {
|
|||
$class = shift;
|
||||
$transactionId = shift;
|
||||
$gatewayId = shift;
|
||||
$userId = shift || $session{user}{userId};
|
||||
$userId = shift || $self->session->user->profileField("userId");
|
||||
|
||||
if ($transactionId eq 'new') {
|
||||
$transactionId = WebGUI::Id::generate;
|
||||
|
||||
WebGUI::SQL->write("insert into transaction ".
|
||||
$self->session->db->write("insert into transaction ".
|
||||
"(transactionId, userId, amount, gatewayId, initDate, completionDate, status) values ".
|
||||
"(".quote($transactionId).",".quote($userId).",0,".quote($gatewayId).",".quote(time).",NULL,'Pending')");
|
||||
"(".$self->session->db->quote($transactionId).",".$self->session->db->quote($userId).",0,".$self->session->db->quote($gatewayId).",".$self->session->db->quote(time).",NULL,'Pending')");
|
||||
}
|
||||
|
||||
$properties = WebGUI::SQL->quickHashRef("select * from transaction where transactionId=".quote($transactionId));
|
||||
$sth = WebGUI::SQL->read("select * from transactionItem where transactionId=".quote($transactionId));
|
||||
$properties = $self->session->db->quickHashRef("select * from transaction where transactionId=".$self->session->db->quote($transactionId));
|
||||
$sth = $self->session->db->read("select * from transactionItem where transactionId=".$self->session->db->quote($transactionId));
|
||||
while ($row = $sth->hashRef) {
|
||||
push(@items, $row);
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ Returns a reference to an array which contains transaction objects of all pendin
|
|||
|
||||
sub pendingTransactions {
|
||||
my (@transactionIds, @transactions);
|
||||
@transactionIds = WebGUI::SQL->buildArray("select transactionId from transaction where status = 'Pending'");
|
||||
@transactionIds = $self->session->db->buildArray("select transactionId from transaction where status = 'Pending'");
|
||||
|
||||
foreach (@transactionIds) {
|
||||
push(@transactions, WebGUI::Commerce::Transaction->new($_));
|
||||
|
|
@ -475,7 +475,7 @@ sub shippingCost {
|
|||
|
||||
if ($shippingCost) {
|
||||
$self->{_properties}{shippingCost} = $shippingCost;
|
||||
WebGUI::SQL->write("update transaction set shippingCost=".quote($shippingCost)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set shippingCost=".$self->session->db->quote($shippingCost)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{shippingCost};
|
||||
|
|
@ -500,7 +500,7 @@ sub shippingMethod {
|
|||
|
||||
if ($shippingMethod) {
|
||||
$self->{_properties}{shippingMethod} = $shippingMethod;
|
||||
WebGUI::SQL->write("update transaction set shippingMethod=".quote($shippingMethod)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set shippingMethod=".$self->session->db->quote($shippingMethod)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{shippingMethod};
|
||||
|
|
@ -526,7 +526,7 @@ sub shippingOptions {
|
|||
|
||||
if ($shippingOptions) {
|
||||
$self->{_properties}{shippingOptions} = $shippingOptions;
|
||||
WebGUI::SQL->write("update transaction set shippingOptions=".quote($shippingOptions)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set shippingOptions=".$self->session->db->quote($shippingOptions)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{shippingOptions};
|
||||
|
|
@ -551,7 +551,7 @@ sub shippingStatus {
|
|||
|
||||
if ($shippingStatus) {
|
||||
$self->{_properties}{shippingStatus} = $shippingStatus;
|
||||
WebGUI::SQL->write("update transaction set shippingStatus=".quote($shippingStatus)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set shippingStatus=".$self->session->db->quote($shippingStatus)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{shippingStatus};
|
||||
|
|
@ -576,7 +576,7 @@ sub status {
|
|||
|
||||
if ($status) {
|
||||
$self->{_properties}{status} = $status;
|
||||
WebGUI::SQL->write("update transaction set status=".quote($status)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set status=".$self->session->db->quote($status)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{status};
|
||||
|
|
@ -602,7 +602,7 @@ sub trackingNumber {
|
|||
|
||||
if ($trackingNumber) {
|
||||
$self->{_properties}{trackingNumber} = $trackingNumber;
|
||||
WebGUI::SQL->write("update transaction set trackingNumber=".quote($trackingNumber)." where transactionId=".quote($self->{_transactionId}));
|
||||
$self->session->db->write("update transaction set trackingNumber=".$self->session->db->quote($trackingNumber)." where transactionId=".$self->session->db->quote($self->{_transactionId}));
|
||||
}
|
||||
|
||||
return $self->{_properties}{trackingNumber};
|
||||
|
|
@ -638,7 +638,7 @@ sub transactionsByUser {
|
|||
my $self = shift;
|
||||
my $userId = shift;
|
||||
|
||||
@transactionIds = WebGUI::SQL->buildArray("select transactionId from transaction where userId =".quote($userId));
|
||||
@transactionIds = $self->session->db->buildArray("select transactionId from transaction where userId =".$self->session->db->quote($userId));
|
||||
foreach (@transactionIds) {
|
||||
push (@transactions, WebGUI::Commerce::Transaction->new($_));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue