diff options
author | fbriere <fbriere> | 2006-08-19 18:14:27 +0000 |
---|---|---|
committer | fbriere <fbriere> | 2006-08-19 18:14:27 +0000 |
commit | e97a2d3512479f30718872b70196a2be18ec2b2e (patch) | |
tree | 529d92fa6ae2c3ba6066c79e760268bcf5c9572d | |
parent | 980d429a92740e97ca84e1fa9fb951284160c820 (diff) |
Added backwards-compatible support for exp_date
-rwxr-xr-x | InternetSecure.pm | 6 | ||||
-rwxr-xr-x | t/exp_date.t | 52 |
2 files changed, 58 insertions, 0 deletions
diff --git a/InternetSecure.pm b/InternetSecure.pm index c41e3ce..65847f1 100755 --- a/InternetSecure.pm +++ b/InternetSecure.pm @@ -135,6 +135,12 @@ sub to_xml { my %content = $self->content; + # Backwards-compatible support for exp_date + if (exists $content{exp_date} && ! exists $content{expiration}) { + $content{expiration} = delete $content{exp_date}; + $self->content(%content); + } + $self->required_fields(qw(action card_number expiration)); croak "Unsupported transaction type: $content{type}" diff --git a/t/exp_date.t b/t/exp_date.t new file mode 100755 index 0000000..1c52314 --- /dev/null +++ b/t/exp_date.t @@ -0,0 +1,52 @@ +# vim:set syntax=perl encoding=utf-8: + +# Check for backwards-compatible support for exp_date + +use Test::More tests => 2 + 1; + +BEGIN { use_ok('Business::OnlinePayment') }; +BEGIN { use_ok('XML::Simple', qw(xml_in)) }; + +my $txn = new Business::OnlinePayment 'InternetSecure', merchant_id => '0000'; + +$txn->content( + action => 'Normal Authorization', + + card_number => '5111-1111-1111-1111', + exp_date => '0704', + + amount => 13.95, + ); + +is_deeply( xml_in($txn->to_xml), xml_in(<<__EOF__) ); +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<TranxRequest> + <MerchantNumber>0000</MerchantNumber> + <xxxCard_Number>5111111111111111</xxxCard_Number> + <xxxCCMonth>07</xxxCCMonth> + <xxxCCYear>2004</xxxCCYear> + <CVV2>0</CVV2> + <CVV2Indicator></CVV2Indicator> + <Products>13.95::1::::::{CAD}</Products> + <xxxName></xxxName> + <xxxCompany></xxxCompany> + <xxxAddress></xxxAddress> + <xxxCity></xxxCity> + <xxxProvince></xxxProvince> + <xxxPostal></xxxPostal> + <xxxCountry></xxxCountry> + <xxxPhone></xxxPhone> + <xxxEmail></xxxEmail> + <xxxShippingName></xxxShippingName> + <xxxShippingCompany></xxxShippingCompany> + <xxxShippingAddress></xxxShippingAddress> + <xxxShippingCity></xxxShippingCity> + <xxxShippingProvince></xxxShippingProvince> + <xxxShippingPostal></xxxShippingPostal> + <xxxShippingCountry></xxxShippingCountry> + <xxxShippingPhone></xxxShippingPhone> + <xxxShippingEmail></xxxShippingEmail> +</TranxRequest> + +__EOF__ + |