Permalink
Browse files

Build results of 6ffd2e5 (on master)

  • Loading branch information...
2 parents 6a6abb4 + 6ffd2e5 commit b38ebeb7748b3c7a6eb431fd19756964893043b3 @xenoterracide committed May 10, 2012
Showing with 72 additions and 258 deletions.
  1. +0 −164 ;
  2. +0 −1 MANIFEST
  3. +0 −1 META.json
  4. +0 −1 META.yml
  5. +0 −1 Makefile.PL
  6. +0 −1 t/000-report-versions-tiny.t
  7. +72 −89 t/authorization-business-rules.t
View
164 ;
@@ -1,164 +0,0 @@
-package Business::CyberSource;
-use 5.008;
-use strict;
-use warnings;
-
-# VERSION
-
-1;
-
-# ABSTRACT: Perl interface to the CyberSource Simple Order SOAP API
-
-=head1 DESCRIPTION
-
-This library is a Perl interface to the CyberSource Simple Order SOAP API built
-on L<Moose> and L<XML::Compile::SOAP> technologies. This library aims to
-eventually provide a full interface the SOAPI.
-
-You may wish to read the Official CyberSource Documentation on L<Credit Card
-Services for the Simpler Order
-API|http://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SO_API/html/>
-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
-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
-
-all environment variables are prefixed with C<PERL_BUSINESS_CYBERSOURCE_>
-
-=head2 DEBUG
-
-causes all requests to be C<carp>ed to STDERROR
-
-=head2 USERNAME
-
-set's the L<username in the client|Busines::CyberSource::Client/"username">
-for testing
-
-=head2 PASSWORD
-
-set's the L<e in the client|Busines::CyberSource::Client/"username">
-
-=head1 EXAMPLE
-
- use 5.010;
- use Carp;
- use Try::Tiny;
-
- use Business::CyberSource::Client;
- use Business::CyberSource::Request::Authorization;
- use Business::CyberSource::Request::Capture;
-
- my $client = Business::CyberSource::Client->new({
- username => 'Merchant ID',
- password => 'API Key',
- production => 1,
- });
-
- my $auth_request = try {
- Business::CyberSource::Request::Authorization->new({
- reference_code => '42',
- first_name => 'Caleb',
- last_name => 'Cushing',
- street => '100 somewhere st',
- city => 'Houston',
- state => 'TX',
- zip => '77064',
- country => 'US',
- email => 'xenoterracide@gmail.com',
- credit_card => '4111111111111111',
- cc_exp_month => '09',
- cc_exp_year => '2025',
- currency => 'USD',
- total => 5.00,
- });
- }
- catch {
- carp $_;
- };
-
- my $auth_response = try {
- $client->run_transaction( $auth_request );
- }
- catch {
- carp $_;
-
- if ( $auth_request->has_trace ) {
- carp 'REQUEST: '
- . $auth_request->trace->request->as_string
- . 'RESPONSE: '
- . $auth_request->trace->response->as_string
- ;
- }
- };
-
- unless( $auth_response->is_accepted ) {
- carp $auth_response->reason_text;
- }
- else {
- my $capture_request
- = Business::CyberSource::Request::Capture->new({
- reference_code => $auth_request->reference_code,
- request_id => $auth_response->request_id,
- total => $auth_response->amount,
- currency => $auth_response->currency,
- });
-
- my $capture_response = try {
- $client->run_transaction( $capture_request );
- }
- catch {
- carp $_;
-
- if ( $capture_request->has_trace ) {
- carp 'REQUEST: '
- . $capture_request->trace->request->as_string
- . 'RESPONSE: '
- . $capture_request->trace->response->as_string
- ;
- }
- };
-
- if ( $capture_response->is_accepted ) {
- # you probably want to record this
- say $capture_response->reconcilliation_id;
- }
- }
-
-This code is not meant to be DRY, but more of a top to bottom example. Also
-note that if you really want to do Authorization and Capture at one time use a
-L<Sale|Business::CyberSource::Request::Sale>. Most common Reasons for
-Exceptions would be bad input into the request object (which validates things)
-or CyberSource just randomly throwing an ERROR, in which case you can usually
-just retry later. You don't have to print the response on error during
-development, you can easily just use the L<DEBUG Environment variable|/"DEBUG">
-
-=head1 ACKNOWLEDGMENTS
-
-=over
-
-=item * Mark Overmeer
-
-for the help with getting L<XML::Compile::SOAP::WSS> working.
-
-=back
-
-=head1 SEE ALSO
-
-=over
-
-=item * L<Checkout::CyberSource::SOAP>
-
-=item * L<Business::OnlinePayment::CyberSource>
-
-=back
-
-=cut
View
1 MANIFEST
@@ -1,4 +1,3 @@
-;
Changes
LICENSE
MANIFEST
View
1 META.json
@@ -74,7 +74,6 @@
"test" : {
"requires" : {
"Data::Dumper" : "0",
- "Env" : "0",
"File::Find" : "0",
"File::Temp" : "0",
"Test::Exception" : "0",
View
1 META.yml
@@ -4,7 +4,6 @@ author:
- 'Caleb Cushing <xenoterracide@gmail.com>'
build_requires:
Data::Dumper: 0
- Env: 0
File::Find: 0
File::Temp: 0
Test::Exception: 0
View
1 Makefile.PL
@@ -15,7 +15,6 @@ my %WriteMakefileArgs = (
"AUTHOR" => "Caleb Cushing <xenoterracide\@gmail.com>",
"BUILD_REQUIRES" => {
"Data::Dumper" => 0,
- "Env" => 0,
"File::Find" => 0,
"File::Temp" => 0,
"Test::Exception" => 0,
View
1 t/000-report-versions-tiny.t
@@ -52,7 +52,6 @@ eval { $v .= pmver('Business::CreditCard','any version') };
eval { $v .= pmver('Carp','any version') };
eval { $v .= pmver('Config','any version') };
eval { $v .= pmver('Data::Dumper','any version') };
-eval { $v .= pmver('Env','any version') };
eval { $v .= pmver('ExtUtils::MakeMaker','6.30') };
eval { $v .= pmver('File::Find','any version') };
eval { $v .= pmver('File::ShareDir','any version') };
View
161 t/authorization-business-rules.t
@@ -1,27 +1,26 @@
-#!/usr/bin/perl
-use 5.008;
use strict;
use warnings;
-use Env qw( CYBS_ID CYBS_KEY );
use Test::More;
use Test::Requires::Env qw(
PERL_BUSINESS_CYBERSOURCE_USERNAME
PERL_BUSINESS_CYBERSOURCE_PASSWORD
);
+use Test::Exception;
-my ( $CYBS_ID, $CYBS_KEY )
- = (
- $ENV{PERL_BUSINESS_CYBERSOURCE_USERNAME},
- $ENV{PERL_BUSINESS_CYBERSOURCE_PASSWORD},
- );
+use Module::Runtime qw( use_module );
-use Business::CyberSource::Request::Authorization;
+my $client
+ = new_ok( use_module( 'Business::CyberSource::Client') => [{
+ username => $ENV{PERL_BUSINESS_CYBERSOURCE_USERNAME},
+ password => $ENV{PERL_BUSINESS_CYBERSOURCE_PASSWORD},
+ production => 0,
+ }]);
-my $req0
- = Business::CyberSource::Request::Authorization->new({
- username => $CYBS_ID,
- password => $CYBS_KEY,
- reference_code => 't109-0',
+my $authc = use_module('Business::CyberSource::Request::Authorization');
+
+my $auth_req0
+ = new_ok( $authc => [{
+ reference_code => 'test-auth-business-rules-0-' . time,
first_name => 'Caleb',
last_name => 'Cushing',
street => 'somewhere',
@@ -37,39 +36,31 @@ my $req0
cc_exp_year => '2025',
cvn => '1111',
ignore_cv_result => 1,
- production => 0,
- });
-
-my $ret0;
-
-eval { $ret0 = $req0->submit };
-
-note( $req0->trace->printRequest );
-note( $req0->trace->printResponse );
-
-is( $ret0->decision, 'ACCEPT', 'check decision' );
-is( $ret0->reference_code, 't109-0', 'check reference_code' );
-is( $ret0->reason_code, 100, 'check reason_code' );
-is( $ret0->currency, 'USD', 'check currency' );
-is( $ret0->amount, '9001.00', 'check amount' );
-is( $ret0->avs_code, 'Y', 'check avs_code' );
-is( $ret0->avs_code_raw, 'Y', 'check avs_code_raw' );
-is( $ret0->processor_response, 'C2', 'check processor_response');
-is( $ret0->reason_text, 'Successful transaction', 'check reason_text' );
-is( $ret0->auth_code, '831000', 'check auth_code exists');
-
-ok( $ret0->request_id, 'check request_id exists' );
-ok( $ret0->request_token, 'check request_token exists' );
-ok( $ret0->datetime, 'check datetime exists' );
-ok( $ret0->auth_record, 'check auth_record exists' );
-
-
-my $req1
- = Business::CyberSource::Request::Authorization->new({
- username => $CYBS_ID,
- password => $CYBS_KEY,
- production => 0,
- reference_code => 't109-1',
+ }]);
+
+my $auth_res0 = $client->run_transaction( $auth_req );
+
+isa_ok $auth_res0, 'Business::CyberSource::Response';
+
+is( $auth_res0->decision, 'ACCEPT', 'check decision' );
+is( $auth_res0->reference_code, 't109-0', 'check reference_code' );
+is( $auth_res0->reason_code, 100, 'check reason_code' );
+is( $auth_res0->currency, 'USD', 'check currency' );
+is( $auth_res0->amount, '9001.00', 'check amount' );
+is( $auth_res0->avs_code, 'Y', 'check avs_code' );
+is( $auth_res0->avs_code_raw, 'Y', 'check avs_code_raw' );
+is( $auth_res0->processor_response, 'C2', 'check processor_response');
+is( $auth_res0->reason_text, 'Successful transaction', 'check reason_text' );
+is( $auth_res0->auth_code, '831000', 'check auth_code exists');
+
+ok( $auth_res0->request_id, 'check request_id exists' );
+ok( $auth_res0->request_token, 'check request_token exists' );
+ok( $auth_res0->datetime, 'check datetime exists' );
+ok( $auth_res0->auth_record, 'check auth_record exists' );
+
+my $auth_req1
+ = new_ok( $authc => [{
+ reference_code => 'test-auth-business-rules-1-' . time,
first_name => 'Caleb',
last_name => 'Cushing',
street => 'somewhere',
@@ -86,34 +77,29 @@ my $req1
ignore_avs_result => 1,
});
-my $ret1;
-
-eval { $ret1 = $req1->submit };
-
-note( $req1->trace->printRequest );
-note( $req1->trace->printResponse );
-
-is( $ret1->decision, 'ACCEPT', 'check decision' );
-is( $ret1->reference_code, 't109-1', 'check reference_code' );
-is( $ret1->reason_code, 100, 'check reason_code' );
-is( $ret1->currency, 'USD', 'check currency' );
-is( $ret1->amount, '5005.00', 'check amount' );
-is( $ret1->avs_code, 'N', 'check avs_code' );
-is( $ret1->avs_code_raw, 'N', 'check avs_code_raw' );
-is( $ret1->processor_response, '00', 'check processor_response');
-is( $ret1->reason_text, 'Successful transaction', 'check reason_text' );
-is( $ret1->auth_code, '831000', 'check auth_code exists');
-
-ok( $ret1->request_id, 'check request_id exists' );
-ok( $ret1->request_token, 'check request_token exists' );
-ok( $ret1->datetime, 'check datetime exists' );
-ok( $ret1->auth_record, 'check auth_record exists' );
-
-my $req2
- = Business::CyberSource::Request::Authorization->new({
- username => $CYBS_ID,
- password => $CYBS_KEY,
- production => 0,
+
+my $auth_res1 = $client->run_transaction( $auth_req1 );
+
+isa_ok $auth_res1, 'Business::CyberSource::Response';
+
+is( $auth_res1->decision, 'ACCEPT', 'check decision' );
+is( $auth_res1->reference_code, 't109-1', 'check reference_code' );
+is( $auth_res1->reason_code, 100, 'check reason_code' );
+is( $auth_res1->currency, 'USD', 'check currency' );
+is( $auth_res1->amount, '5005.00', 'check amount' );
+is( $auth_res1->avs_code, 'N', 'check avs_code' );
+is( $auth_res1->avs_code_raw, 'N', 'check avs_code_raw' );
+is( $auth_res1->processor_response, '00', 'check processor_response');
+is( $auth_res1->reason_text, 'Successful transaction', 'check reason_text' );
+is( $auth_res1->auth_code, '831000', 'check auth_code exists');
+
+ok( $auth_res1->request_id, 'check request_id exists' );
+ok( $auth_res1->request_token, 'check request_token exists' );
+ok( $auth_res1->datetime, 'check datetime exists' );
+ok( $auth_res1->auth_record, 'check auth_record exists' );
+
+my $auth_req2
+ = new_ok( $authc => [{
reference_code => 't109-2',
first_name => 'Caleb',
last_name => 'Cushing',
@@ -131,22 +117,19 @@ my $req2
decline_avs_flags => [ qw( Y N ) ],
});
-my $ret2;
-
-eval { $ret2 = $req2->submit };
+my $auth_res2 = $client->run_transaction( $auth_req2 );
-note( $req2->trace->printRequest );
-note( $req2->trace->printResponse );
+isa_ok $auth_res2, 'Business::CyberSource::Response';
-is( $ret2->decision, 'REJECT', 'check decision' );
-is( $ret2->reason_code, 200, 'check reason_code' );
-is( $ret2->avs_code, 'Y', 'check avs_code' );
-is( $ret2->avs_code_raw, 'Y', 'check avs_code_raw' );
-is( $ret2->processor_response, '00', 'check processor_response');
-is( $ret2->auth_code, '831000', 'check auth_code exists');
+is( $auth_res2->decision, 'REJECT', 'check decision' );
+is( $auth_res2->reason_code, 200, 'check reason_code' );
+is( $auth_res2->avs_code, 'Y', 'check avs_code' );
+is( $auth_res2->avs_code_raw, 'Y', 'check avs_code_raw' );
+is( $auth_res2->processor_response, '00', 'check processor_response');
+is( $auth_res2->auth_code, '831000', 'check auth_code exists');
-ok( $ret2->request_id, 'check request_id exists' );
-ok( $ret2->request_token, 'check request_token exists' );
-ok( $ret2->auth_record, 'check auth_record exists' );
+ok( $auth_res2->request_id, 'check request_id exists' );
+ok( $auth_res2->request_token, 'check request_token exists' );
+ok( $auth_res2->auth_record, 'check auth_record exists' );
done_testing;

0 comments on commit b38ebeb

Please sign in to comment.