summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2008-07-22 16:27:53 +0000
committerjeff <jeff>2008-07-22 16:27:53 +0000
commit5b03d96b42ff9aa46bda1ad21dd674c2713ace83 (patch)
tree69ba5da727bfc1d8274dda77358374f129c51ade
parent18935a05828a0a5afd3ae11c78905754dbaeedb2 (diff)
force country to ISO-3166-alpha-3
-rw-r--r--Changes3
-rw-r--r--IPPay.pm34
-rw-r--r--Makefile.PL1
-rw-r--r--t/card.t1
4 files changed, 33 insertions, 6 deletions
diff --git a/Changes b/Changes
index 9b074f8..c904684 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension Business::OnlinePayment::IPPay.
+0.04 Tue Jul 22 12:19:54 2008 EDT
+ - force country and ship country to ISA-3166-alpha-3
+
0.03 Sun Jul 10 21:00:58 2008 EDT
- require Business::OnlinePayment::HTTPS 0.09
- remove unnecessary requirements
diff --git a/IPPay.pm b/IPPay.pm
index 771d5e3..9c35919 100644
--- a/IPPay.pm
+++ b/IPPay.pm
@@ -5,12 +5,13 @@ use Carp;
use Tie::IxHash;
use XML::Simple;
use XML::Writer;
+use Locale::Country;
use Business::OnlinePayment;
use Business::OnlinePayment::HTTPS;
use vars qw($VERSION $DEBUG @ISA $me);
@ISA = qw(Business::OnlinePayment::HTTPS);
-$VERSION = '0.03';
+$VERSION = '0.04';
$DEBUG = 0;
$me = 'Business::OnlinePayment::IPPay';
@@ -222,6 +223,27 @@ sub submit {
my $terminalid = $content{login} if $type eq 'CC';
my $merchantid = $content{login} if $type eq 'ECHECK';
+ my $country = country2code( $content{country}, LOCALE_CODE_ALPHA_3 );
+ $country = country_code2code( $content{country},
+ LOCALE_CODE_ALPHA_2,
+ LOCALE_CODE_ALPHA_3
+ )
+ unless $country;
+ $country = $content{country}
+ unless $country;
+ $country = uc($country) if $country;
+
+ my $ship_country =
+ country2code( $content{ship_country}, LOCALE_CODE_ALPHA_3 );
+ $ship_country = country_code2code( $content{ship_country},
+ LOCALE_CODE_ALPHA_2,
+ LOCALE_CODE_ALPHA_3
+ )
+ unless $ship_country;
+ $ship_country = $content{ship_country}
+ unless $ship_country;
+ $ship_country = uc($ship_country) if $ship_country;
+
tie my %ach, 'Tie::IxHash',
$self->revmap_fields(
#AccountType => 'account_type',
@@ -240,7 +262,7 @@ sub submit {
Address => 'ship_address',
City => 'ship_city',
StateProv => 'ship_state',
- Country => 'ship_country',
+ Country => \$ship_country,
Phone => 'ship_phone',
);
@@ -250,7 +272,7 @@ sub submit {
Address => 'address',
City => 'city',
StateProv => 'state',
- Country => 'country',
+ Country => \$country,
Phone => 'phone',
);
}
@@ -295,7 +317,7 @@ sub submit {
BillingCity => 'city',
BillingStateProv => 'state',
BillingPostalCode => 'zip',
- BillingCountry => 'country',
+ BillingCountry => \$country,
BillingPhone => 'phone',
Email => 'email',
UserIPAddr => 'customer_ip',
@@ -493,7 +515,7 @@ from content(%content):
BillingCity => 'city',
BillingStateProv => 'state',
BillingPostalCode => 'zip',
- BillingCountry => 'country',
+ BillingCountry => 'country', # forced to ISO-3166-alpha-3
BillingPhone => 'phone',
Email => 'email',
UserIPAddr => 'customer_ip',
@@ -512,7 +534,7 @@ from content(%content):
Address => 'ship_address',
City => 'ship_city',
StateProv => 'ship_state',
- Country => 'ship_country',
+ Country => 'ship_country', # forced to ISO-3166-alpha-3
Phone => 'ship_phone',
=head1 NOTE
diff --git a/Makefile.PL b/Makefile.PL
index f522ecc..079fdf5 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -5,6 +5,7 @@ WriteMakefile(
'AUTHOR' => 'Jeff Finucane <ippay@weasellips.com>',
'PREREQ_PM' => { 'Business::OnlinePayment' => 3,
'Business::OnlinePayment::HTTPS' => 0.09,
+ 'Locale::Country' => 2,
'Test::More' => 0.42,
'Tie::IxHash' => 0,
'XML::Simple' => 0,
diff --git a/t/card.t b/t/card.t
index a0da538..21b024b 100644
--- a/t/card.t
+++ b/t/card.t
@@ -25,6 +25,7 @@ my %content = (
city => 'Anywhere',
state => 'UT',
zip => '84058',
+ country => 'US', # will be forced to USA
customer_id => 'tfb',
);