diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2016-12-09 12:45:01 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2016-12-09 12:45:01 -0600 |
commit | 06583ca8e9590de4bc44e849791166d1b8be90ce (patch) | |
tree | 73dbb169a71acdf7fb0422e4ccfe3fab081122a1 /FS/FS | |
parent | 7a33cb6e4c3e33b7399d6574cbd3ee38ddcba5e0 (diff) |
71513: Card tokenization [refund testing & bug fixes]
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 35293f0ea..59792e70f 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -1454,9 +1454,10 @@ sub realtime_refund_bop { ( $gatewaynum, $processor, $auth, $order_number ) = ( $2, $3, $4, $6 ); } + my $payment_gateway; if ( $gatewaynum ) { #gateway for the payment to be refunded - my $payment_gateway = + $payment_gateway = qsearchs('payment_gateway', { 'gatewaynum' => $gatewaynum } ); die "payment gateway $gatewaynum not found" unless $payment_gateway; @@ -1470,7 +1471,7 @@ sub realtime_refund_bop { } else { #try the default gateway my $conf_processor; - my $payment_gateway = + $payment_gateway = $self->agent->payment_gateway('method' => $options{method}); ( $conf_processor, $login, $password, $namespace ) = @@ -1487,8 +1488,27 @@ sub realtime_refund_bop { unless ($processor eq $conf_processor) || (($conf_processor eq 'CardFortress') && ($processor eq $bop_options{'gateway'})); + $processor = $conf_processor; + } + # if gateway has switched to CardFortress but token_check hasn't run yet, + # tokenize just this record now, so that token gets passed/set appropriately + if ($cust_pay->payby eq 'CARD' && !$cust_pay->tokenized) { + my %tokenopts = ( + 'payment_gateway' => $payment_gateway, + 'method' => 'CC', + 'payinfo' => $cust_pay->payinfo, + 'paydate' => $cust_pay->paydate, + ); + my $error = $self->realtime_tokenize(\%tokenopts); # no-op unless gateway can tokenize + if ($self->tokenized($tokenopts{'payinfo'})) { # implies no error + warn " tokenizing cust_pay\n" if $DEBUG > 1; + $cust_pay->payinfo($tokenopts{'payinfo'}); + $error = $cust_pay->replace; + } + return $error if $error; + } } else { # didn't specify a paynum, so look for agent gateway overrides # like a normal transaction @@ -1567,6 +1587,12 @@ sub realtime_refund_bop { $content{'name'} = $self->get('first'). ' '. $self->get('last'); } } + if ( $cust_pay->payby eq 'CARD' + && !$content{'card_number'} + && $cust_pay->tokenized + ) { + $content{'card_token'} = $cust_pay->payinfo; + } $void->content( 'action' => 'void', %content ); $void->test_transaction(1) if $conf->exists('business-onlinepayment-test_transaction'); |