use vars qw($VERSION $DEBUG @ISA $me);
@ISA = qw(Business::OnlinePayment::HTTPS);
-$VERSION = '2.03_01';
+$VERSION = '2.03_02';
$DEBUG = 0;
$me='Business::OnlinePayment::PaymenTech';
$self->build_subs(qw(
order_number
- ProcStatus
- ApprovalStatus
- StatusMsg
- Response
- RespCode
- AuthCode
- AVSRespCode
- CVV2RespCode
- ));
-
+ ));
+
+ #leaking gateway-specific anmes? need to be mapped to B:OP standards :)
+ # ProcStatus
+ # ApprovalStatus
+ # StatusMsg
+ # RespCode
+ # AuthCode
+ # AVSRespCode
+ # CVV2RespCode
+ # Response
}
sub build {
warn $page if $DEBUG;
- my $response;
- my $error = '';
- if ($server_response =~ /200/){
- $response = XMLin($page, KeepRoot => 0);
- $self->Response($response);
- my ($r) = values(%$response);
- foreach(qw(ProcStatus RespCode AuthCode AVSRespCode CVV2RespCode)) {
- if(exists($r->{$_}) and
- !ref($r->{$_})) {
- $self->$_($r->{$_});
- }
- }
- if(!exists($r->{'ProcStatus'})) {
- $error = "Malformed response: '$page'";
+ my $response = XMLin($page, KeepRoot => 0);
+ #$self->Response($response);
+
+ #use Data::Dumper;
+ #warn Dumper($response) if $DEBUG;
+
+ my ($r) = values(%$response);
+ #foreach(qw(ProcStatus RespCode AuthCode AVSRespCode CVV2RespCode)) {
+ # if(exists($r->{$_}) and
+ # !ref($r->{$_})) {
+ # $self->$_($r->{$_});
+ # }
+ #}
+
+ foreach (keys %$r) {
+
+ #turn empty hashrefs into the empty string
+ $r->{$_} = '' if ref($r->{$_}) && ! keys %{ $r->{$_} };
+
+ #turn hashrefs with content into scalars
+ $r->{$_} = $r->{$_}{'content'}
+ if ref($r->{$_}) && exists($r->{$_}{'content'});
+ }
+
+ if ($server_response !~ /^200/) {
+
+ $self->is_success(0);
+ my $error = "Server error: '$server_response'";
+ $error .= " / Transaction error: '".
+ ($r->{'ProcStatusMsg'} || $r->{'StatusMsg'}) . "'"
+ if $r->{'ProcStatus'} != 0;
+ $self->error_message($error);
+
+ } else {
+
+ if ( !exists($r->{'ProcStatus'}) ) {
+
$self->is_success(0);
- }
- elsif( $r->{'ProcStatus'} != 0 or
- # NewOrders get ApprovalStatus, Reversals don't.
- ( exists($r->{'ApprovalStatus'}) ?
- $r->{'ApprovalStatus'} != 1 :
- $r->{'StatusMsg'} ne 'Approved' )
- ) {
- $error = "Transaction error: '". ($r->{'ProcStatusMsg'} || $r->{'StatusMsg'}) . "'";
+ $self->error_message( "Malformed response: '$page'" );
+
+ } elsif ( $r->{'ProcStatus'} != 0 or
+ # NewOrders get ApprovalStatus, Reversals don't.
+ ( exists($r->{'ApprovalStatus'}) ?
+ $r->{'ApprovalStatus'} != 1 :
+ $r->{'StatusMsg'} ne 'Approved' )
+ )
+ {
+
$self->is_success(0);
- }
- else {
- # success!
+ $self->error_message( "Transaction error: '".
+ ($r->{'ProcStatusMsg'} || $r->{'StatusMsg'}) . "'"
+ );
+
+ } else { # success!
+
$self->is_success(1);
# For credits, AuthCode is empty and gets converted to a hashref.
$self->authorization($r->{'AuthCode'}) if !ref($r->{'AuthCode'});
$self->order_number($r->{'TxRefNum'});
}
- } else {
- $error = "Server error: '$server_response'";
+
}
- $self->error_message($error);
+
}
1;
=head1 NOTES
-The only supported transaction types are Normal Authorization and Credit. Paymentech
-supports separate Authorize and Capture actions as well as recurring billing, but
-those are not yet implemented.
+The only supported transaction types are Normal Authorization and Credit.
+Paymentech supports separate Authorize and Capture actions as well as recurring
+billing, but those are not yet implemented.
Electronic check processing is not yet supported.