summaryrefslogtreecommitdiff
path: root/lib/Business/OnlinePayment/PPIPayMover/CreditCardResponse.pm
blob: 3cf5ae3715062e744a0a5ce74e9e493cba5cfc8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
package Business::OnlinePayment::PPIPayMover::CreditCardResponse;

use strict;
use vars qw(@ISA);
use Business::OnlinePayment::PPIPayMover::TransactionResponse;
use Business::OnlinePayment::PPIPayMover::PayerAuthenticationResponse;
use Business::OnlinePayment::PPIPayMover::constants;

@ISA = qw(Business::OnlinePayment::PPIPayMover::TransactionResponse);

sub new {
  my $class = shift;
  my $InString = shift;
  my $self = $class->SUPER::new($InString);
   
  $self->{oPayerAuthenticationResponse} = undef;
  $self->{strReferenceId} = undef;
  $self->{strBatchId} = undef;
  $self->{strBankTransactionId} = undef;
  $self->{strBankApprovalCode} = undef;
  $self->{strState} = undef;
  $self->{strAuthorizedAmount} = undef;
  $self->{strOriginalAuthorizedAmount} = undef;
  $self->{strCapturedAmount} = undef;
  $self->{strCreditedAmount} = undef;
  $self->{strTimeStampCreated} = undef;
  $self->{strOrderId} = undef;
  $self->{strIsoCode} = undef;
  $self->{strAVSCode} = "None";    # v1.5
  $self->{strCreditCardVerificationResponse} = undef;
  
  if ($self->{iResponseCode} == TRANSACTION_SERVER_ERROR || $self->{iResponseCode} == INVALID_VERSION) {
    return $self;
  }
  if (!($$InString) && !($self->{iResponseCode} == SUCCESSFUL_TRANSACTION)) {
    return $self;
  }
  
  my @temp = split(/\n/, $$InString);
  my $size = @temp;
  if ($size < 10) {
    $self->{strError} .= "input string is in wrong format";
    $self->{iRetVal} = 0;
    return $self;
  }
  
  # Looking to see if there is a nested Payer Authentication Response
  my $payerAuthResponse = new Business::OnlinePayment::PPIPayMover::TransactionResponse($InString,AUTHENTICATION_PREFIX);
  
  if (defined($payerAuthResponse->GetResponseCode)){
  	$self->{oPayerAuthenticationResponse} = new Business::OnlinePayment::PPIPayMover::PayerAuthenticationResponse($InString,AUTHENTICATION_PREFIX);
  }
  
  my $name;
  my $value;
  foreach (@temp) {
  
    ($name, $value) = split(/=/, $_, 2);
    
    if ($name eq "capture_reference_id") {
      $self->{strReferenceId} = $value;
    }
    elsif ($name eq "order_id") {
      $self->{strOrderId} = $value;
    }
    elsif ($name eq "iso_code") {
      $self->{strIsoCode} = $value;
    }
    elsif ($name eq "bank_approval_code") {
      $self->{strBankApprovalCode} = $value;
    }
    elsif ($name eq "state") {
      $self->{strState} = $value;
    }
    elsif ($name eq "authorized_amount") {
      $self->{strAuthorizedAmount} = $value;
    }
    elsif ($name eq "original_authorized_amount") {
      $self->{strOriginalAuthorizedAmount} = $value;
    }
    elsif ($name eq "captured_amount") {
      $self->{strCapturedAmount} = $value;
    }
    elsif ($name eq "credited_amount") {
      $self->{strCreditedAmount} = $value;
    }
    elsif ($name eq "time_stamp_created") {
      $self->{strTimeStampCreated} = $value;
    }
    elsif ($name eq "bank_transaction_id") {
      $self->{strBankTransactionId} = $value;
    }
    elsif ($name eq "batch_id") {
      $self->{strBatchId } = $value;
    }
    elsif ($name eq "avs_code") {
      $self->{strAVSCode} = $value;
    }
    elsif ($name eq "credit_card_verification_response") {
      $self->{strCreditCardVerificationResponse} = $value;
    }
    else {
      $self->{strError} .= "Invalid data name: ";
    }
  }
  return $self;
}


sub GetBatchId
{
  my $self = shift;
  $self->{strBatchId};
}

sub GetBankTransactionId
{
  my $self = shift;
  $self->{strBankTransactionId};
}

sub GetBankApprovalCode
{
  my $self = shift;
  $self->{strBankApprovalCode};
}

sub GetState
{
  my $self = shift;
  $self->{strState};
}

sub GetAuthorizedAmount
{
  my $self = shift;
  $self->{strAuthorizedAmount};
}

sub GetOriginalAuthorizedAmount
{
  my $self = shift;
  $self->{strOriginalAuthorizedAmount};
}

sub GetCapturedAmount
{
  my $self = shift;
  $self->{strCapturedAmount};
}

sub GetCreditedAmount
{
  my $self = shift;
  $self->{strCreditedAmount};
}

sub GetTimeStampCreated
{
  my $self = shift;
  $self->{strTimeStampCreated};
}

sub GetOrderId
{
  my $self = shift;
  $self->{strOrderId};
}

sub GetIsoCode
{
  my $self = shift;
  $self->{strIsoCode};
}

sub GetCaptureReferenceId
{
  my $self = shift;
  $self->{strReferenceId};
}

sub GetReferenceId
{
  my $self = shift;
  $self->{strReferenceId};
}

sub GetAVSCode {
    my $self = shift;
    $self->{strAVSCode};
}

sub GetCreditCardVerificationResponse {
    my $self = shift;
    $self->{strCreditCardVerificationResponse};
}

sub GetPayerAuthenticationResponse {
    my $self = shift;
    $self->{oPayerAuthenticationResponse};
}