summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-04-08 17:39:28 -0700
committerIvan Kohler <ivan@freeside.biz>2014-04-08 17:39:28 -0700
commitd83690e6c6ec34f7767b22794b53cc9da60078f4 (patch)
tree35602548c3639df00c8e386b17992dd4cb1293a0
parent3348212d55be92c7ad71a8410e7d6153a3e5f709 (diff)
Pass AVS and CVV information
-rw-r--r--Changes3
-rw-r--r--eSelectPlus.pm92
-rw-r--r--t/capture_ca.t3
-rw-r--r--t/capture_us.t3
-rw-r--r--t/credit_card_ca.t3
-rw-r--r--t/credit_card_us.t3
6 files changed, 95 insertions, 12 deletions
diff --git a/Changes b/Changes
index 276cb1b..2ec011a 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Business::OnlinePayment::eSelectPlus
+0.08 unreleased
+ - Pass AVS and CVV information
+
0.07 Wed Aug 21 11:53:36 PDT 2013
- eSelectPlus cust_id: Use customer number instead of invoice number
- eSelectPlus order_id: Append "-invoice_num" per documentation
diff --git a/eSelectPlus.pm b/eSelectPlus.pm
index ebe0203..b118080 100644
--- a/eSelectPlus.pm
+++ b/eSelectPlus.pm
@@ -8,7 +8,7 @@ use Business::OnlinePayment::HTTPS 0.03;
use vars qw($VERSION $DEBUG @ISA);
@ISA = qw(Business::OnlinePayment::HTTPS);
-$VERSION = '0.07';
+$VERSION = '0.08_01';
$DEBUG = 0;
sub set_defaults {
@@ -66,30 +66,30 @@ sub submit {
# => 'transaction_type',
#login => 'store_id',
#password => 'api_token',
+
#authorization =>
- #customer_ip =>
#name =>
#first_name =>
#last_name =>
#company =>
- #address =>
+ #address => 'avs_street_number'/'avs_street_name' handled below
#city =>
#state =>
- #zip =>
+ zip => 'avs_zipcode',
#country =>
- phone =>
+ phone => 'avs_custphone',
#fax =>
- email =>
+ email => 'avs_email',
+ customer_ip => 'avs_custip',
+
card_number => 'pan',
- #expiration =>
- # => 'expdate',
+ #expiration => 'expdate', #handled below
+ cvv2 => 'cvd_value',
'amount' => 'amount',
customer_id => 'cust_id',
order_number => 'order_id', # must be unique number
- authorization => 'txn_number' # reference to previous trans
-
- #cvv2 =>
+ authorization => 'txn_number', # reference to previous trans
);
my $action = $self->{_content}{'action'};
@@ -122,6 +122,13 @@ sub submit {
$month = '0'. $month if $month =~ /^\d$/;
$self->{_content}{expdate} = $year.$month;
+ #CVD Indicator
+ #0 = CVD value is deliberately bypassed or is not provided by the merchant
+ #1 = CVD value is present.
+ #2 = CVD value is on the card, but is illegible.
+ #9 = Cardholder states that the card has no CVD imprint.
+ $self->{_content}{cvd_indicator} = $self->{_content}{cvd_value} ? 1 : 0;
+
$self->generate_order_id;
$self->{_content}{order_id} .= '-'. ($invoice_number || 0);
@@ -143,6 +150,20 @@ sub submit {
}
+ if ( $self->{_content}{address} ) {
+ my $number = '';
+ my $name = $self->{_content}{address};
+ if ( $name =~ s/^\s*(\d+)\w\s+// ) {
+ $number = $1;
+ }
+ $name = substr( $name, 0, 19 - length($number) );
+ $self->{_content}{avs_street_number} = $number;
+ $self->{_content}{avs_street_name} = $name;
+ }
+
+ $self->{_content}{avs_zipcode} =~ s/\W//g
+ if defined $self->{_content}{avs_zipcode};
+
# E-Commerce Indicator (see eSelectPlus docs)
$self->{_content}{'crypt_type'} ||= 7;
@@ -159,7 +180,25 @@ sub submit {
'<store_id>'. $self->{_content}{'login'}. '</store_id>'.
'<api_token>'. $self->{_content}{'password'}. '</api_token>'.
"<$action>".
- join('', map "<$_>$fields{$_}</$_>", keys %fields ).
+ join('', map "<$_>$fields{$_}</$_>", keys %fields );
+
+ if ( $action =~ /^(purchase|preauth|ind_refund)$/ ) {
+ tie my %avs_fields, 'Tie::IxHash', $self->get_fields( $self->avs_fields );
+ $post_data .=
+ '<avs_info>'.
+ join('', map "<$_>$avs_fields{$_}</$_>", keys %avs_fields ).
+ '</avs_info>'
+ if grep $_, values %avs_fields;
+
+ tie my %cvd_fields, 'Tie::IxHash', $self->get_fields( $self->cvd_fields );
+ $post_data .=
+ '<cvd_info>'.
+ join('', map "<$_>$cvd_fields{$_}</$_>", keys %cvd_fields ).
+ '</cvd_info>'
+ if grep $_, values %cvd_fields;
+ }
+
+ $post_data .=
"</$action>".
'</request>';
@@ -270,6 +309,35 @@ sub fields {
);
}
+sub avs_fields {
+ my $self = shift;
+
+ #order is important to this processor
+ qw(
+ avs_street_number
+ avs_street_name
+ avs_zipcode
+ avs_email
+ avs_hostname
+ avs_browser
+ avs_shiptocountry
+ avs_shipmethod
+ avs_merchprodsku
+ avs_custip
+ avs_custphone
+ );
+}
+
+sub cvd_fields {
+ my $self = shift;
+
+ #order is important to this processor
+ qw(
+ cvd_indicator
+ cvd_value
+ );
+}
+
sub GetXMLProp {
my( $self, $raw, $prop ) = @_;
local $^W=0;
diff --git a/t/capture_ca.t b/t/capture_ca.t
index 460ea7c..b233d11 100644
--- a/t/capture_ca.t
+++ b/t/capture_ca.t
@@ -25,6 +25,9 @@ $tx->content(
# name => 'eSelectPlus Tester',
card_number => '4242424242424242',
expiration => '12/14',
+ cvv2 => '123',
+ address => '1234 Tofu Lane',
+ zip => 'L3T 2C6',
);
$tx->test_transaction(1); # test, dont really charge
diff --git a/t/capture_us.t b/t/capture_us.t
index f5952df..2da01cd 100644
--- a/t/capture_us.t
+++ b/t/capture_us.t
@@ -24,6 +24,9 @@ $tx->content(
# name => 'eSelectPlus Tester',
card_number => '4242424242424242',
expiration => '12/12',
+ cvv2 => '123',
+ address => '1234 Tofu Lane',
+ zip => '543215454',
# invoice_number => 'freeform',
);
diff --git a/t/credit_card_ca.t b/t/credit_card_ca.t
index a0d5835..a421d83 100644
--- a/t/credit_card_ca.t
+++ b/t/credit_card_ca.t
@@ -23,6 +23,9 @@ $tx->content(
currency => 'CAD',
card_number => '4242424242424242',
expiration => '01/12',
+ cvv2 => '123',
+ address => '1234 Tofu Lane',
+ zip => 'L3T 2C6',
);
$tx->test_transaction(1); # test, dont really charge
$tx->submit();
diff --git a/t/credit_card_us.t b/t/credit_card_us.t
index a857ae3..c24532f 100644
--- a/t/credit_card_us.t
+++ b/t/credit_card_us.t
@@ -23,6 +23,9 @@ $tx->content(
currency => 'USD',
card_number => '4242424242424242',
expiration => '01/12',
+ cvv2 => '123',
+ address => '1234 Tofu Lane',
+ zip => '543215454',
);
$tx->test_transaction(1); # test, dont really charge
$tx->submit();