summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-11-30 05:45:29 -0600
committerJonathan Prykop <jonathan@freeside.biz>2016-11-30 05:50:35 -0600
commit9547ad4e7cc87b1cfe6bc9f2428da81481e18926 (patch)
tree3cb49dfa923999b87c0f626ef176b4bf0b7913ec
parent3d8958a36f22a88738b637b4d5583e989e91bc8e (diff)
71513: Card tokenization [bug fixes, removed cardtype/taxclass override ui]
-rw-r--r--FS/FS/agent.pm3
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm5
-rwxr-xr-xFS/t/suite/13-tokenization.t42
-rwxr-xr-xhttemplate/browse/agent.cgi24
-rw-r--r--httemplate/edit/agent_payment_gateway.html28
-rw-r--r--httemplate/edit/process/agent_payment_gateway.html13
6 files changed, 54 insertions, 61 deletions
diff --git a/FS/FS/agent.pm b/FS/FS/agent.pm
index b97e9b9..e70b971 100644
--- a/FS/FS/agent.pm
+++ b/FS/FS/agent.pm
@@ -239,8 +239,7 @@ sub ticketing_queue {
Returns a payment gateway object (see L<FS::payment_gateway>) for this agent.
-Currently available options are I<nofatal>, I<method>, I<thirdparty>,
-<conf> and I<load_gatewaynum>.
+Currently available options are I<nofatal>, I<method>, I<thirdparty> and I<conf>.
If I<nofatal> is set, and no gateway is available, then the empty string
will be returned instead of throwing a fatal exception.
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index fb0c010..35c4f0d 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -113,7 +113,6 @@ I<depend_jobnum> allows payment capture to unlock export jobs
=cut
# Currently only used by ClientAPI
-# NOT 4.x COMPATIBLE (see below)
sub realtime_collect {
my( $self, %options ) = @_;
@@ -127,10 +126,6 @@ sub realtime_collect {
$options{amount} = $self->balance unless exists( $options{amount} );
return '' unless $options{amount} > 0;
- #### NOT 4.x COMPATIBLE
- $options{method} = FS::payby->payby2bop($self->payby)
- unless exists( $options{method} );
-
return $self->realtime_bop({%options});
}
diff --git a/FS/t/suite/13-tokenization.t b/FS/t/suite/13-tokenization.t
index 1b654ad..9a3ef3f 100755
--- a/FS/t/suite/13-tokenization.t
+++ b/FS/t/suite/13-tokenization.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use FS::Test;
-use Test::More tests => 8;
+use Test::More tests => 9;
use FS::Conf;
### can only run on test database (company name "Freeside Test")
@@ -38,6 +38,46 @@ TESTTERMINAL';
$conf->set('business-onlinepayment' => $bopconf);
is( join("\n",$conf->config('business-onlinepayment')), $bopconf, "setting first default gateway" ) or BAIL_OUT('');
+# generate a few void/refund records for upgrading
+my $counter = 20;
+foreach my $cust_pay ( $fs->qsearch('cust_pay',{ payby => 'CARD' }) ) {
+ if ($counter % 2) {
+ $err = $cust_pay->void('Testing');
+ $err = "Voiding: $err" if $err;
+ } else {
+ # from realtime_refund_bop, just the important bits
+ while ( $cust_pay->unapplied < $cust_pay->paid ) {
+ my @cust_bill_pay = $cust_pay->cust_bill_pay;
+ last unless @cust_bill_pay;
+ my $cust_bill_pay = pop @cust_bill_pay;
+ $err = $cust_bill_pay->delete;
+ $err = "Refund unapply: $err" if $err;
+ last if $err;
+ }
+ last if $err;
+ my $cust_refund = new FS::cust_refund ( {
+ 'custnum' => $cust_pay->cust_main->custnum,
+ 'paynum' => $cust_pay->paynum,
+ 'source_paynum' => $cust_pay->paynum,
+ 'refund' => $cust_pay->paid,
+ '_date' => '',
+ 'payby' => $cust_pay->payby,
+ 'payinfo' => $cust_pay->payinfo,
+ 'reason' => 'Testing',
+ 'gatewaynum' => $cust_pay->gatewaynum,
+ 'processor' => $cust_pay->payment_gateway ? $cust_pay->payment_gateway->processor : '',
+ 'auth' => $cust_pay->auth,
+ 'order_number' => $cust_pay->order_number,
+ } );
+ $err = $cust_refund->insert( reason_type => 'Refund' );
+ $err = "Refunding: $err" if $err;
+ }
+ last if $err;
+ $counter -= 1;
+ last unless $counter > 0;
+}
+ok( !$err, "create some refunds and voids" ) or BAIL_OUT($err);
+
$err = system('freeside-upgrade','admin');
ok( !$err, 'initial upgrade' ) or BAIL_OUT('Error string: '.$!);
diff --git a/httemplate/browse/agent.cgi b/httemplate/browse/agent.cgi
index 3fe68c1..751e8b6 100755
--- a/httemplate/browse/agent.cgi
+++ b/httemplate/browse/agent.cgi
@@ -42,7 +42,7 @@ full offerings (via their type).<BR><BR>
<TH CLASS="grid" BGCOLOR="#cccccc">Currencies</TH>
% }
- <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Overrides</FONT></TH>
+ <TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Payment Gateway Override</FONT></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><FONT SIZE=-1>Configuration Overrides</FONT></TH>
</TR>
@@ -331,32 +331,24 @@ Unused
% }
% ##
-% # payment gateway overrides
+% # payment gateway override
% ##
<TD CLASS="inv" BGCOLOR="<% $bgcolor %>">
<TABLE CLASS="inv" CELLSPACING=0 CELLPADDING=0>
-% foreach my $override (
-% # sort { } want taxclass-full stuff first? and default cards (empty cardtype)
-% qsearch('agent_payment_gateway', { 'agentnum' => $agent->agentnum } )
-% ) {
-%
-
+% my $gw_override = qsearchs('agent_payment_gateway', { 'agentnum' => $agent->agentnum } );
+% if ($gw_override) {
<TR>
<TD>
- <% $override->cardtype || 'Default' %> to <% $override->payment_gateway->gateway_module %> (<% $override->payment_gateway->gateway_username %>)
- <% $override->taxclass
- ? ' for '. $override->taxclass. ' only'
- : ''
- %>
- <FONT SIZE=-1><A HREF="javascript:areyousure('delete this payment gateway override', '<%$p%>misc/delete-agent_payment_gateway.cgi?<% $override->agentgatewaynum %>')">(delete)</A></FONT>
+ <% $gw_override->payment_gateway->gateway_module %> (<% $gw_override->payment_gateway->gateway_username %>)
+ <FONT SIZE=-1><A HREF="javascript:areyousure('delete this payment gateway override', '<%$p%>misc/delete-agent_payment_gateway.cgi?<% $gw_override->agentgatewaynum %>')">(delete)</A></FONT>
</TD>
</TR>
-% }
-
+% } else {
<TR>
<TD><FONT SIZE=-1><A HREF="<%$p%>edit/agent_payment_gateway.html?agentnum=<% $agent->agentnum %>">(add override)</A></FONT></TD>
</TR>
+% }
</TABLE>
</TD>
diff --git a/httemplate/edit/agent_payment_gateway.html b/httemplate/edit/agent_payment_gateway.html
index 41a9f3e..753bc76 100644
--- a/httemplate/edit/agent_payment_gateway.html
+++ b/httemplate/edit/agent_payment_gateway.html
@@ -1,6 +1,6 @@
<% include("/elements/header.html","$action payment gateway override for ". $agent->agent, menubar(
#'View all payment gateways' => $p. 'browse/payment_gateway.html',
- 'View all agents' => $p. 'browse/agent.html',
+ 'View all agents' => $p. 'browse/agent.cgi',
)) %>
<% include('/elements/error.html') %>
@@ -20,32 +20,6 @@ Use gateway <SELECT NAME="gatewaynum">
</SELECT>
<BR><BR>
-for <SELECT NAME="cardtype" MULTIPLE>
-% foreach my $cardtype (
-% "",
-% "VISA card",
-% "MasterCard",
-% "Discover card",
-% "American Express card",
-% "Diner's Club/Carte Blanche",
-% "enRoute",
-% "JCB",
-% "BankCard",
-% "Switch",
-% "Solo",
-% 'ACH',
-% 'PayPal',
-%) {
-
- <OPTION VALUE="<% $cardtype %>"><% $cardtype || '(Default fallback)' %>
-% }
-
-</SELECT>
-<BR><BR>
-
-(optional) when invoice contains only items of taxclass <INPUT TYPE="text" NAME="taxclass">
-<BR><BR>
-
<INPUT TYPE="submit" VALUE="Add gateway override">
</FORM>
diff --git a/httemplate/edit/process/agent_payment_gateway.html b/httemplate/edit/process/agent_payment_gateway.html
index 5b5fd94..c9789cf 100644
--- a/httemplate/edit/process/agent_payment_gateway.html
+++ b/httemplate/edit/process/agent_payment_gateway.html
@@ -10,20 +10,13 @@ die "agentnum $1 not found" unless $agent;
#my $old
-my @new = map {
- my $cardtype = $_;
- new FS::agent_payment_gateway {
+my $new = new FS::agent_payment_gateway {
( map { $_ => scalar($cgi->param($_)) }
fields('agent_payment_gateway')
),
- 'cardtype' => $cardtype,
};
- }
- $cgi->param('cardtype');
-foreach my $new (@new) {
- my $error = $new->insert;
- die $error if $error;
-}
+my $error = $new->insert;
+die $error if $error;
</%init>