Business-CyberSource
view release on metacpan or search on metacpan
as it will provide further information on why what some things are and
the general workflow.
To get started you will want to read the documentation in
Business::CyberSource::Client and Business::CyberSource::Request. If
you find any documentation unclear or outright missing, please file a
bug.
If there are features that are part of CyberSource's API but are not
documented, or are missing here, please file a bug. I'll be happy to
add them, but due to the size of the upstream API, I have not had time
to cover all the features and some are currently undocumented.
ENVIRONMENT
Debugging
Supports MooseY::RemoteHelper::Role::Clients REMOTE_CLIENT_DEBUG
variable. This can be set to either 0, 1, 2, for varying levels of
verbosity.
Testing
all environment variables are prefixed with PERL_BUSINESS_CYBERSOURCE_
Credentials
USERNAME
PASSWORD
set's the username and password in the client for running tests.
Direct Currency Conversion
DCC_CC_YYYY
sets the test credit card expiration year for both Visa and MasterCard
DCC_CC_MM
sets the test credit card expiration month for both Visa and MasterCard
DCC_MASTERCARD
A test credit card number provided by your your credit card processor
DCC_VISA
A test credit card number provided by your your credit card processor
EXAMPLE
In the example, carp means you should log something Dumper means you
should log it with lots of detail. Safe::Isa is used because you should
either use it or check for blessed it is always possible that somewhere
in the stack someone is using die on a string.
use 5.010;
use Carp;
use Try::Tiny;
use Safe::Isa;
use Data::Printer alias => 'Dumper';
use Business::CyberSource::Client;
use Business::CyberSource::Request::Authorization;
use Business::CyberSource::Request::Capture;
# exception namepsace
my $e_ns = 'Business::CyberSource::Exception';
my $client = Business::CyberSource::Client->new({
user => 'Merchant ID',
pass => 'API Key',
test => 1,
debug => 1, # do not set in production as it prints sensative
# information
});
my $auth_request;
try {
$auth_request
= Business::CyberSource::Request::Authorization->new({
reference_code => '42',
bill_to => {
first_name => 'Caleb',
last_name => 'Cushing',
street1 => '100 somewhere st',
city => 'Houston',
state => 'TX',
postal_code => '77064',
country => 'US',
email => 'xenoterracide@gmail.com',
},
purchase_totals => {
currency => 'USD',
total => 5.00,
discount => 0.03, # optional and may depend on processor
duty => 0.01, # optional and may depend on processor
},
card => {
account_number => '4111111111111111',
expiration => {
month => 9,
year => 2025,
},
},
});
}
catch {
my $e = $_;
if ( $e->$_does('Business::CyberSource::Response::Role::Base')) {
carp $e->reason_code . $e->reason_text;
}
elsif ( $e->$_isa( $e_ns . '::SOAPFault' ) ) {
carp $e->faultcode . $e->faultstring;
}
elsif ( $e->$_isa( $e_ns ) || $e->$_isa( 'Moose::Exception' ) ) {
Dumper( $e );
## probably your payload was bad, check type more
## specifically and feed good error messages to your
## customer
( run in 0.801 second using v1.01-cache-2.11-cpan-39bf76dae61 )