diff --git a/lib/WebGUI/Commerce/Payment.pm b/lib/WebGUI/Commerce/Payment.pm index e7b27feef..030233e08 100644 --- a/lib/WebGUI/Commerce/Payment.pm +++ b/lib/WebGUI/Commerce/Payment.pm @@ -102,6 +102,13 @@ sub configurationForm { -value => $self->enabled, -label => $i18n->get('enable'), ); + $f->group( + -name => $self->prepend('whoCanUse'), + -value => [1], + -label => 'Who Can Use?', + -hoverHelp => 'Members belonging to this group will see this payment gateway as a choice at the payment gateway selection screen during checkout.' + ); + $f->raw($form); return $f->printRowsOnly; diff --git a/lib/WebGUI/Commerce/Payment/Cash.pm b/lib/WebGUI/Commerce/Payment/Cash.pm index b2ff58a14..6ebcaf128 100644 --- a/lib/WebGUI/Commerce/Payment/Cash.pm +++ b/lib/WebGUI/Commerce/Payment/Cash.pm @@ -365,18 +365,26 @@ sub configurationForm { $i18n = WebGUI::International->new($self->session, 'CommercePaymentITransact'); $f = WebGUI::HTMLForm->new($self->session); + $f->textarea( -name => $self->prepend('emailMessage'), -label => $i18n->get('emailMessage'), -value => $self->get('emailMessage') ); + + $f->yesNo( + -name => $self->prepend('completeTransaction'), + -value => $self->get('completeTransaction') || 1, + -label => 'Complete Transaction on Submit?', + -hoverHelp => 'When set to \'yes\', the transaction is completed when the user submits payment details. When set to \'no\', the transaction is set to pending and must be manually set to complete. This may be useful if you wish to allow site visitors to select the Cash Payment method, but would like to wait for payment to clear before completing the transaction.' + ); return $self->SUPER::configurationForm($f->printRowsOnly); } #------------------------------------------------------------------- sub confirmTransaction { - # This function should never be called with site side payment gateways! + return 0; } @@ -384,7 +392,7 @@ sub confirmTransaction { =head2 init ( namespace ) -Constructor for the ITransact plugin. +Constructor for the Cash plugin. =head3 session @@ -408,21 +416,18 @@ sub init { sub gatewayId { my $self = shift; - return $self->session->id->generate;; + return $self->get('paymentMethod').":".$self->session->id->generate; } #------------------------------------------------------------------- sub errorCode { - return undef; + my $self = shift; + return $self->{_error}->{code}; } #------------------------------------------------------------------- sub name { - my ($self) = shift; - #my $i18n = WebGUI::International->new($self->session, "CommercePaymentITransact"); - #return $i18n->get('module name'); - return "Cash"; } @@ -440,16 +445,22 @@ sub normalTransaction { if ($normal) { my $i18n = WebGUI::International->new($self->session, 'CommercePaymentITransact'); - $self->{_recurring} = 0; $self->{_transactionParams} = { AMT => sprintf('%.2f', $normal->{amount}), - DESCRIPTION => $normal->{description}) || $i18n->get('no description'), + DESCRIPTION => $normal->{description} || $i18n->get('no description'), INVOICENUMBER => $normal->{invoiceNumber}, ORGID => $normal->{id}, }; } - - return $self->submit; + + if ($self->get('completeTransaction')) { + $self->{_transaction}->{status} = 'complete'; + } + else { + $self->{_transaction}->{status} = 'pending'; + $self->{_error}->{message} = 'Your transaction will be completed upon receipt of payment.'; + $self->{_error}->{code} = 1; + } } #------------------------------------------------------------------- @@ -464,14 +475,6 @@ sub shippingDescription { $self->{_shipping}->{description} = shift; } -#------------------------------------------------------------------- -sub submit { - my $self = shift; - - # this just needs to set the object properties with the transaction data - # since there is no approval or 'submit' process. Cash transactions always succeed. -} - #------------------------------------------------------------------- sub supports { return { @@ -482,19 +485,20 @@ sub supports { #------------------------------------------------------------------- sub transactionCompleted { - my ($self) = shift; - - return 1; + my $self = shift; + return 1 if $self->{_transaction}->{status} eq 'complete'; } #------------------------------------------------------------------- sub transactionError { - return undef; + my $self = shift; + return $self->{_error}->{message}; } #------------------------------------------------------------------- sub transactionPending { - return 0; + my $self = shift; + return 1 if $self->{_transaction}->{status} eq 'pending'; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Operation/Commerce.pm b/lib/WebGUI/Operation/Commerce.pm index e2d3c51c8..046aae93f 100644 --- a/lib/WebGUI/Operation/Commerce.pm +++ b/lib/WebGUI/Operation/Commerce.pm @@ -850,7 +850,7 @@ sub www_listTransactions { $criteria{shippingStatus} = $session->form->process("sStatus") if ($session->form->process("sStatus")); $criteria{paymentStatus} = $session->form->process("tStatus") if ($session->form->process("tStatus")); - @transactions = WebGUI::Commerce::Transaction->getTransactions(\%criteria); + @transactions = WebGUI::Commerce::Transaction->new($session)->getTransactions(\%criteria); $output .= '
| '. @@ -912,7 +912,7 @@ sub www_selectPaymentGateway { name => $_->name, namespace => $_->namespace, formElement => WebGUI::Form::radio($session,{name=>'paymentGateway', value=>$_->namespace}) - }); + }) if ($session->user->isInGroup($_->get('whoCanUse'))); } } elsif (scalar(@$plugins) == 1) { my $paymentGateway = $plugins->[0]->namespace; @@ -923,7 +923,7 @@ sub www_selectPaymentGateway { $var{message} = $i18n->get('select payment gateway'); $var{pluginsAvailable} = @$plugins; $var{noPluginsMessage} = $i18n->get('no payment gateway'); - $var{formHeader} = WebGUI::Form::formHeader.WebGUI::Form::hidden($session,{name=>'op', value=>'selectPaymentGatewaySave'}); + $var{formHeader} = WebGUI::Form::formHeader($session).WebGUI::Form::hidden($session,{name=>'op', value=>'selectPaymentGatewaySave'}); $var{formSubmit} = WebGUI::Form::submit($session,{value=>$i18n->get('payment gateway select')}); $var{formFooter} = WebGUI::Form::formFooter; |
|---|