cust_id: Use customer number instead of invoice number / order_id: Append "-invoice_n...
authorIvan Kohler <ivan@freeside.biz>
Wed, 21 Aug 2013 18:59:52 +0000 (11:59 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 21 Aug 2013 18:59:52 +0000 (11:59 -0700)
Changes
MANIFEST
eSelectPlus.pm
t/order_num_ca.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 538c875..276cb1b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Business::OnlinePayment::eSelectPlus
 
+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
+
 0.06  Mon Nov 12 14:28:16 PST 2012
         - Fix voids even if an amount is passed (now ignored)
         - Add missing t/void_{ca,us}.t tests
index 93cf9a5..00069b0 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -18,3 +18,4 @@ t/capture_ca.t
 t/capture_us.t
 t/void_us.t
 t/void_ca.t
+t/order_num_ca.t
index 3357703..ebe0203 100644 (file)
@@ -8,7 +8,7 @@ use Business::OnlinePayment::HTTPS 0.03;
 use vars qw($VERSION $DEBUG @ISA);
 
 @ISA = qw(Business::OnlinePayment::HTTPS);
-$VERSION = '0.06';
+$VERSION = '0.07';
 $DEBUG = 0;
 
 sub set_defaults {
@@ -55,6 +55,10 @@ sub submit {
        }
     }
 
+    my %cust_id = ( 'invoice_number' => 'cust_id' );
+
+    my $invoice_number = $self->{_content}{invoice_number};
+
     # BOP field => eSelectPlus field
     #$self->map_fields();
     $self->remap_fields(
@@ -81,8 +85,7 @@ sub submit {
         #                => 'expdate',
 
         'amount'         => 'amount',
-        invoice_number   => 'cust_id',
-        #customer_id      => 'cust_id',
+        customer_id      => 'cust_id',
         order_number     => 'order_id',   # must be unique number
         authorization    => 'txn_number'  # reference to previous trans
 
@@ -121,6 +124,8 @@ sub submit {
 
       $self->generate_order_id;
 
+      $self->{_content}{order_id} .= '-'. ($invoice_number || 0);
+
       $self->{_content}{amount} = sprintf('%.2f', $self->{_content}{amount} );
 
     } elsif ( $action =~ /^(completion|purchasecorrection|refund)$/ ) {
diff --git a/t/order_num_ca.t b/t/order_num_ca.t
new file mode 100644 (file)
index 0000000..baebba4
--- /dev/null
@@ -0,0 +1,38 @@
+BEGIN { $| = 1; print "1..1\n"; }
+
+eval "use Net::SSLeay;";
+if ( $@ ) {
+  print "ok 1 # Skipped: Net::SSLeay is not installed\n"; exit;
+}
+
+use Business::OnlinePayment;
+
+my $tx = new Business::OnlinePayment("eSelectPlus");
+
+#$Business::OnlinePayment::HTTPS::DEBUG = 1;
+#$Business::OnlinePayment::HTTPS::DEBUG = 1;
+$Business::OnlinePayment::eSelectPlus::DEBUG = 1;
+$Business::OnlinePayment::eSelectPlus::DEBUG = 1;
+
+$tx->content(
+    type           => 'VISA',
+    login          => 'moot',
+    password       => 'moot',
+    action         => 'Normal Authorization',
+    amount         => '0.80',
+    currency       => 'CAD',
+    card_number    => '4242424242424242',
+    expiration     => '01/12',
+    invoice_number => '540',
+);
+$tx->test_transaction(1); # test, dont really charge
+$tx->submit();
+    warn $tx->order_number."\n";
+
+if ( $tx->order_number =~ /-540$/ ) {
+    print "ok 1\n";
+} else {
+    warn $tx->order_number."\n";
+    print "not ok 1\n";
+}
+