Skip to content

Commit

Permalink
update is_success and add is_reject
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Cushing <xenoterracide@gmail.com>
  • Loading branch information
xenoterracide committed Oct 4, 2012
1 parent f891c28 commit 3f1f5f9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/Business/CyberSource.pm
Expand Up @@ -129,7 +129,7 @@ A test credit card number provided by your your credit card processor
}
};
unless( $auth_response->is_accepted ) {
unless( $auth_response->is_accept ) {
carp $auth_response->reason_text;
}
else {
Expand Down Expand Up @@ -160,7 +160,7 @@ A test credit card number provided by your your credit card processor
}
};
if ( $capture_response->is_accepted ) {
if ( $capture_response->is_accept ) {
# you probably want to record this
say $capture_response->reconciliation_id;
}
Expand Down
42 changes: 37 additions & 5 deletions lib/Business/CyberSource/Response.pm
Expand Up @@ -48,18 +48,40 @@ has request_token => (
isa => subtype( NonEmptySimpleStr, where { length $_ <= 256 }),
);

has accepted => (
required => 0,
has is_success => (
isa => 'Bool',
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
my $self = shift;
return $self->decision eq 'ACCEPT' ? 1 : 0;
},
);

has is_accept => (
isa => 'Bool',
is => 'ro',
isa => Bool,
alias => [ qw( is_success is_accepted ) ],
lazy => 1,
init_arg => undef,
alias => [ qw( accepted is_accepted ) ],
default => sub {
my $self = shift;
return $self->decision eq 'ACCEPT' ? 1 : 0;
},
);

has is_reject => (
isa => 'Bool',
is => 'ro',
lazy => 1,
init_arg => undef,
default => sub {
my $self = shift;
return $self->decision eq 'REJECT' ? 1 : 0;
},
);

sub _build_reason_text {
my $self = shift;

Expand Down Expand Up @@ -201,10 +223,20 @@ Request token data created by CyberSource for each reply. The field is an
encoded string that contains no confidential information, such as an account
or card verification number. The string can contain up to 256 characters.
=attr accepted
=attr is_accept
boolean way of determining whether the transaction was accepted
=attr is_reject
boolean way of determining whether the transaction was rejected
=attr is_success
boolean way of determining whether the transaction was successful.
Currently an alias for L<is_accept|/"is_accept"> but will later mean a non
error status.
=attr amount
Type: Num
Expand Down

0 comments on commit 3f1f5f9

Please sign in to comment.