Business-CyberSource
view release on metacpan or search on metacpan
lib/Business/CyberSource.pm view on Meta::CPAN
general workflow.
To get started you will want to read the documentation in
L<Business::CyberSource::Client> and L<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.
=head1 ENVIRONMENT
=head2 Debugging
Supports L<MooseY::RemoteHelper::Role::Client>s C<REMOTE_CLIENT_DEBUG>
variable. This can be set to either C<0>, C<1>, C<2>, for varying levels of
verbosity.
=head2 Testing
all environment variables are prefixed with C<PERL_BUSINESS_CYBERSOURCE_>
=head3 Credentials
=head4 USERNAME
=head4 PASSWORD
set's the L<username|Busines::CyberSource::Client/"user"> and
L<password|Busines::CyberSource::Client/"pass"> in the client for running
tests.
=head3 Direct Currency Conversion
=head4 DCC_CC_YYYY
sets the test credit card expiration year for both Visa and MasterCard
=head4 DCC_CC_MM
sets the test credit card expiration month for both Visa and MasterCard
=head4 DCC_MASTERCARD
A test credit card number provided by your your credit card processor
=head4 DCC_VISA
A test credit card number provided by your your credit card processor
=head1 EXAMPLE
In the example, C<carp> means you should log something C<Dumper> means you should
log it with lots of detail. L<Safe::Isa> is used because you should either use
it or check for C<blessed> it is always possible that somewhere in the stack
someone is using C<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 3.171 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )