xenoterracide / Business-OnlinePayment-CyberSource

Release history of Business-OnlinePayment-CyberSource
http://search.cpan.org/dist/Business-OnlinePayment-CyberSource/
2 stars 4 forks source link

Expired credit card errors #3

Open jkister opened 9 years ago

jkister commented 9 years ago

I noticed when doing a simple transaction (like in Synopsis of Business::Onlinepayment) with an expired credit card (01/14), I get a stack error:

$_ = Exception::Base::throw("Exception::Base", "No trace found") called in package Business::OnlinePayment::CyberSource::Client at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Client.pm line 309
$_ = Business::OnlinePayment::CyberSource::Client::_fill_fields("Business::OnlinePayment::CyberSource::Client=HASH(0x3049580)", "Business::CyberSource::Response=HASH(0x60ae110)") called in package Business::OnlinePayment::CyberSource::Client at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Client.pm line 100
$_ = Business::OnlinePayment::CyberSource::Client::try {...} () called in package Try::Tiny at /usr/lib/perl5/Try/Tiny.pm line 81
$_ = eval {...} called in package Try::Tiny at /usr/lib/perl5/Try/Tiny.pm line 72
$_ = Try::Tiny::try("CODE(0x292bef8)", "Try::Tiny::Catch=REF(0x5e62538)") called in package Business::OnlinePayment::CyberSource::Client at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Client.pm line 109
$_ = Business::OnlinePayment::CyberSource::Client::_authorize("Business::OnlinePayment::CyberSource::Client=HASH(0x3049580)", "Business::CyberSource::Request::Authorization", "HASH(0x5110388)") called in package Business::OnlinePayment::CyberSource::Client at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Client.pm line 31
$_ = Business::OnlinePayment::CyberSource::Client::authorize("Business::OnlinePayment::CyberSource::Client=HASH(0x3049580)", "HASH(0x5110388)") called in package Class::MOP::Method::Wrapped at /usr/lib/perl5/x86_64-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 43
$_ = Class::MOP::Method::Wrapped::__ANON__("Business::OnlinePayment::CyberSource::Client=HASH(0x3049580)", "HASH(0x5110388)") called in package Class::MOP::Method::Wrapped at /usr/lib/perl5/x86_64-linux-thread-multi/Class/MOP/Method/Wrapped.pm line 87
$_ = Business::OnlinePayment::CyberSource::Client::authorize("Business::OnlinePayment::CyberSource::Client=HASH(0x3049580)", "HASH(0x5110388)") called in package Moose::Meta::Method::Delegation at /usr/lib/perl5/x86_64-linux-thread-multi/Moose/Meta/Method/Delegation.pm line 110
$_ = Business::OnlinePayment::CyberSource::authorize("Business::OnlinePayment::CyberSource=HASH(0x24076a0)", "HASH(0x5110388)") called in package Business::OnlinePayment::CyberSource::Role::TransactionHandling at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Role/TransactionHandling.pm line 96
$_ = Business::OnlinePayment::CyberSource::Role::TransactionHandling::submit("Business::OnlinePayment::CyberSource=HASH(0x24076a0)") called in package Business::OnlinePayment at /usr/lib/perl5/Business/OnlinePayment.pm line 117
$_ = Business::OnlinePayment::__ANON__("Business::OnlinePayment::CyberSource=HASH(0x24076a0)") called in package main at ./test_payment line 57
$_ = eval {...} called in package main at ./test_payment line 56
...propagated in package Business::OnlinePayment::CyberSource::Client at /usr/lib/perl5/Business/OnlinePayment/CyberSource/Client.pm line 106.

I edited Business::OnlinePayment/CyberSource/Client.pm:

--- Client.pm.orig      2015-03-10 15:10:17.319571832 +0000
+++ Client.pm   2015-03-10 15:10:54.760092886 +0000
@@ -303,6 +303,8 @@
                $res                  = $trace->response();
        }
        else {
+        use Data::Dumper;
+        print Dumper( $response );
                Exception::Base->throw( 'No trace found' );
        }

and this shows:

$VAR1 = bless( {
                 'is_error' => 0,
                 'decision' => 'REJECT',
                 'is_accept' => 0,
                 'reason_code' => '202',
                 'request_token' => 0,
                 'reference_code' => '00000001',
                 'request_id' => 0,
                 'reason_text' => 'Expired card. You might also receive this if the expiration date you provided does not match the date the issuing bank has on file'
               }, 'Business::CyberSource::Response' );
xenoterracide commented 9 years ago

If you're looking for debug data you can set the following environment variable, it is not recommended for production environments as it logs sensitive data.

 REMOTE_CLIENT_DEBUG variable. This can be set to either 0, 1, 2, for varying levels of verbosity.

it's possible/probable that the exception itself could be improved, patches welcome on that

jkister commented 9 years ago

I am actually thinking that the script is not supposed to die with that kind of error when we try to authorize an expired credit card.. is that not true ?

jkister commented 9 years ago

oh, i see now we can just eval { the submit() } and keep on going.

xenoterracide commented 9 years ago

hmm... I actually don't remember, I'd have to ask the freeside people what the behavior of B:OP is supposed to be in that context... though admittedly I'd rather offload the module as I no longer have credentials to test it.

xenoterracide commented 9 years ago

I suggest using Try::Tiny instead of eval, there are numerous eval gotchas, and the module already requires it thus you'll already have it