summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2012-06-30 16:37:06 -0700
committerMark Wells <mark@freeside.biz>2012-06-30 16:37:06 -0700
commit92aedddd3684167abb60cd3f1d77bbc156c592e6 (patch)
treef061fdd9dd2434ad6f490f01d682496b46a925d5 /httemplate
parente5fd495945bc0b907cf0d4d21d52bb6b12e7051a (diff)
Business::BatchPayment interface, #17373
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/browse/payment_gateway.html4
-rw-r--r--httemplate/edit/payment_gateway.html56
-rw-r--r--httemplate/misc/download-batch.cgi13
-rw-r--r--httemplate/search/elements/cust_pay_batch_top.html35
-rwxr-xr-xhttemplate/search/pay_batch.cgi20
5 files changed, 88 insertions, 40 deletions
diff --git a/httemplate/browse/payment_gateway.html b/httemplate/browse/payment_gateway.html
index a06e5cf7c..7a8a668d7 100644
--- a/httemplate/browse/payment_gateway.html
+++ b/httemplate/browse/payment_gateway.html
@@ -77,9 +77,9 @@ my $options_sub = sub {
my $html = '<TABLE CELLSPACING=0 CELLPADDING=0>';
- my %options = $payment_gateway->options;
+ tie my %options, 'Tie::IxHash', $payment_gateway->options;
foreach my $option ( keys %options ) {
- $html .= '<TR><TH>'. $option. ':</TH>'.
+ $html .= '<TR><TH ALIGN="right">'. $option. ':</TH>'.
'<TD>'. $options{$option}. '</TD></TR>';
}
$html .= '</TABLE>';
diff --git a/httemplate/edit/payment_gateway.html b/httemplate/edit/payment_gateway.html
index cfb86048c..2840df35b 100644
--- a/httemplate/edit/payment_gateway.html
+++ b/httemplate/edit/payment_gateway.html
@@ -6,11 +6,12 @@
'field_callback' => $field_callback,
'labels' => {
'gatewaynum' => 'Gateway',
+ 'gateway_namespace' => 'Gateway type',
'gateway_module' => 'Gateway',
'gateway_username' => 'Username',
'gateway_password' => 'Password',
'gateway_action' => 'Action',
- 'gateway_options' => 'Options: (Name/Value pairs, one element per line)',
+ 'gateway_options' => 'Options (Name/Value pairs, <BR>one element per line)',
'gateway_callback_url' => 'Callback URL',
},
)
@@ -18,18 +19,18 @@
<SCRIPT TYPE="text/javascript">
- var gatewayNamespace = new Array;
-
-% foreach my $module ( sort { lc($a) cmp lc ($b) } keys %modules ) {
- gatewayNamespace.push('<% $modules{$module} %>')
-% }
-
- // document.getElementById('gateway_namespace').value = gatewayNamespace[0];
- function setNamespace(what) {
- document.getElementById('gateway_namespace').value =
- gatewayNamespace[what.selectedIndex];
+% my $json = JSON->new->canonical;
+ var modulesForNamespace = <% $json->encode(\%modules_for_namespace) %>;
+ function changeNamespace(what) {
+ var ns = what.value;
+ var select_module = document.getElementById('gateway_module');
+ select_module.options.length = 0;
+ for (var x in modulesForNamespace[ns]) {
+ var o = document.createElement('option');
+ o.value = o.text = modulesForNamespace[ns][x];
+ select_module.add(o, null);
+ }
}
-
</SCRIPT>
<%init>
@@ -67,6 +68,7 @@ my %modules = (
'OpenECHO' => 'Business::OnlinePayment',
'PayConnect' => 'Business::OnlinePayment',
'PayflowPro' => 'Business::OnlinePayment',
+ 'Paymentech' => 'Business::BatchPayment',
'PaymenTech' => 'Business::OnlinePayment',
'PaymentsGateway' => 'Business::OnlinePayment',
'PayPal' => 'Business::OnlinePayment',
@@ -88,7 +90,13 @@ my %modules = (
'VirtualNet' => 'Business::OnlinePayment',
'WesternACH' => 'Business::OnlinePayment',
'WorldPay' => 'Business::OnlinePayment',
-);
+);
+
+my %modules_for_namespace;
+for (keys %modules) {
+ $modules_for_namespace{$modules{$_}} ||= [];
+ push @{ $modules_for_namespace{$modules{$_}} }, $_;
+}
my @actions = (
'Normal Authorization',
@@ -99,17 +107,23 @@ my @actions = (
my $fields = [
{
field => 'gateway_namespace',
- type => 'hidden',
- curr_value_callback => sub { my($cgi, $object, $fref) = @_;
- $modules{$object->gateway_module}
- || 'Business::OnlinePayment'
- },
+ type => 'select',
+ options => [ qw(
+ Business::OnlinePayment
+ Business::BatchPayment
+ Business::OnlineThirdPartyPayment
+ ) ],
+ labels => {
+ 'Business::OnlinePayment' => 'Direct',
+ 'Business::BatchPayment' => 'Batch',
+ 'Business::OnlineThirdPartyPayment' => 'Hosted',
+ },
+ onchange => 'changeNamespace',
},
{
field => 'gateway_module',
type => 'select',
options => [ sort { lc($a) cmp lc ($b) } keys %modules ],
- onchange => 'setNamespace',
},
'gateway_username',
'gateway_password',
@@ -126,6 +140,8 @@ my $fields = [
{
field => 'gateway_options',
type => 'textarea',
+ rows => '8',
+ cols => '40',
curr_value_callback => sub { my($cgi, $object, $fref) = @_;
join("\r", $object->options );
},
@@ -135,7 +151,7 @@ my $fields = [
my $field_callback = sub {
my ($cgi, $object, $field_hashref ) = @_;
if ($object->gatewaynum) {
- if ( $field_hashref->{field} eq 'gateway_module' ) {
+ if ( $field_hashref->{field} =~ /gateway_(module|namespace)/ ) {
$field_hashref->{type} = 'fixed';
}
}
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
index 23deba712..f3a31eb3b 100644
--- a/httemplate/misc/download-batch.cgi
+++ b/httemplate/misc/download-batch.cgi
@@ -1,4 +1,4 @@
-<% $pay_batch->export_batch($format) %><%init>
+<% $pay_batch->export_batch(%opt) %><%init>
#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
http_header('Content-Type' => 'text/plain' ); # not necessarily correct...
@@ -10,9 +10,14 @@ if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) {
die "No batch number (bad URL) \n";
}
-my $format;
-if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) {
- $format = $1;
+my %opt;
+if ( $cgi->param('gatewaynum') =~ /^(\d+)$/ ) {
+ my $gateway = FS::payment_gateway->by_key($1);
+ die "gatewaynum $1 not found" unless $gateway;
+ $opt{'gateway'} = $gateway;
+}
+elsif ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) {
+ $opt{'format'} = $1;
}
my $pay_batch = qsearchs('pay_batch', { batchnum => $batchnum } );
diff --git a/httemplate/search/elements/cust_pay_batch_top.html b/httemplate/search/elements/cust_pay_batch_top.html
index ce0ee9ed4..005b76182 100644
--- a/httemplate/search/elements/cust_pay_batch_top.html
+++ b/httemplate/search/elements/cust_pay_batch_top.html
@@ -14,7 +14,8 @@ Download batch in format <SELECT NAME="format">
% foreach ( keys %download_formats ) {
<OPTION VALUE="<%$_%>"><% $download_formats{$_} %></OPTION>
% }
-</SELECT>
+</SELECT>
+<& .select_gateway &>
% }
<INPUT TYPE="submit" VALUE="Download"></FORM><BR><BR></TR>
% } # end of download
@@ -31,7 +32,7 @@ Download batch in format <SELECT NAME="format">
'name' => 'FileUpload',
'action' => "${p}misc/upload-batch.cgi",
'num_files' => 1,
- 'fields' => [ 'batchnum', 'format' ],
+ 'fields' => [ 'batchnum', 'format', 'gatewaynum' ],
'message' => 'Batch results uploaded.',
) %>
Upload results<BR></TR>
@@ -45,20 +46,22 @@ Upload results<BR></TR>
<BR></TR>
% if ( $fixed ) {
% if ( $fixed eq 'td_eft1464' ) { # special case
-<TR>Format <SELECT NAME="format">
+<TR>Upload in format <SELECT NAME="format">
<OPTION VALUE="td_eftack264">TD EFT Acknowledgement</OPTION>
<OPTION VALUE="td_eftret80">TD EFT Returned Items</OPTION>
-</SELECT></TR>
+</SELECT> </TR>
% }
% else {
<INPUT TYPE="hidden" NAME="format" VALUE="<% $fixed %>">
% }
% }
% else {
-<TR>Format <SELECT NAME="format">
+<TR>Upload in format <SELECT NAME="format">
% foreach ( keys(%upload_formats) ) {
<OPTION VALUE="<%$_%>"><% $upload_formats{$_} %></OPTION>
% }
+</SELECT>
+<& .select_gateway &>
% } # if $fixed
<TR><INPUT TYPE="submit" VALUE="Upload"></TR>
</FORM><BR>
@@ -82,6 +85,26 @@ Batch is <% $statustext{$status} %><BR>
<%$count%> payments batched<BR>
<%$money_char%><%$total%> total in batch<BR>
+<%def .select_gateway>
+% if ( $show_gateways ) {
+ or from gateway
+<& /elements/select-table.html,
+ empty_label => ' ',
+ field => 'gatewaynum',
+ table => 'payment_gateway',
+ name_col => 'label',
+ value_col => 'gatewaynum',
+ order_by => 'ORDER BY gatewaynum',
+ hashref => {
+ 'gateway_namespace' => 'Business::BatchPayment',
+ 'disabled' => '',
+ }
+&>
+% }
+</%def>
+<%shared>
+my $show_gateways = FS::payment_gateway->count("gateway_namespace = 'Business::BatchPayment'");
+</%shared>
<%init>
my %opt = @_;
my $pay_batch = $opt{'pay_batch'} or return;
@@ -91,7 +114,7 @@ my $payby = $pay_batch->payby;
my $status = $pay_batch->status;
my $curuser = $FS::CurrentUser::CurrentUser;
my $batchnum = $pay_batch->batchnum;
-
+
my $fixed = $conf->config("batch-fixed_format-$payby");
tie my %download_formats, 'Tie::IxHash', (
diff --git a/httemplate/search/pay_batch.cgi b/httemplate/search/pay_batch.cgi
index b2a15ef3d..05415f36e 100755
--- a/httemplate/search/pay_batch.cgi
+++ b/httemplate/search/pay_batch.cgi
@@ -14,7 +14,8 @@
'Type',
'First Download',
'Last Upload',
- 'Item Count',
+ 'Items',
+ 'Unresolved',
'Amount',
'Status',
],
@@ -46,13 +47,16 @@
}
},
sub {
- my $st = "SELECT COUNT(*) from cust_pay_batch WHERE batchnum=" . shift->batchnum;
- my $sth = dbh->prepare($st)
- or die dbh->errstr. "doing $st";
- $sth->execute
- or die "Error executing \"$st\": ". $sth->errstr;
- $sth->fetchrow_arrayref->[0];
- },
+ FS::cust_pay_batch->count(
+ 'batchnum = '.$_[0]->batchnum
+ )
+ },
+ sub {
+ FS::cust_pay_batch->count(
+ 'status is null and batchnum = '.
+ $_[0]->batchnum
+ )
+ },
sub {
my $st = "SELECT SUM(amount) from cust_pay_batch WHERE batchnum=" . shift->batchnum;
my $sth = dbh->prepare($st)