File Coverage

blib/lib/Business/OnlinePayment/PPIPayMover/TransactionClient.pm
Criterion Covered Total %
statement 55 63 87.3
branch 4 8 50.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 69 84 82.1


line stmt bran cond sub pod time code
1 6     6   31 use strict;
  6         11  
  6         285  
2             package Business::OnlinePayment::PPIPayMover::TransactionClient;
3 6     6   3534 use Business::OnlinePayment::PPIPayMover::TransactionResponse;
  6         15  
  6         194  
4 6     6   7368 use Business::OnlinePayment::PPIPayMover::TransactionRequest;
  6         16  
  6         165  
5 6     6   6287 use Business::OnlinePayment::PPIPayMover::CreditCardRequest;
  6         20  
  6         359  
6 6     6   86 use Business::OnlinePayment::PPIPayMover::CreditCardResponse;
  6         11  
  6         145  
7 6     6   4451 use Business::OnlinePayment::PPIPayMover::SecureHttp;
  6         29  
  6         207  
8 6     6   53 use Business::OnlinePayment::PPIPayMover::constants;
  6         11  
  6         5855  
9             1;
10            
11             # default constructor
12             sub new {
13 6     6 0 18 my $class = shift;
14 6         15 my $self = {};
15 6         17 $self->{strError} = "";
16 6         17 $self->{strResponse} = "";
17 6         21 bless $self, $class;
18 6         25 return $self;
19             }
20            
21             sub doTransaction # take three arguements
22             {
23 4     4 0 9 my $self = shift;
24 4         7 my $TransactionKey = shift; # the first arguement(string)
25 4         10 my $transReq = shift; # the second arguement(class object)
26 4         7 my $AccountToken = shift; # the third arguement(string)
27            
28 4         14 my $PostString = "";
29 4         6 my $ResponseString = "";
30            
31             # write out account_token ...
32 4         15 $PostString .= "account_token=$AccountToken";
33 4         6 $PostString .= "&";
34            
35             # write out transaction_key ...
36             #$PostString .= "transaction_key=$TransactionKey";
37             #$PostString .= "&";
38            
39             # write out version_id ...
40 4         24 my $temp = VERSION;
41 4         12 $temp =~ tr/ /+/;
42 4         10 $PostString .= "version_id=$temp";
43 4         9 $PostString .= "&";
44            
45 4         21 $transReq->WriteRequest(\$PostString); # get post information
46            
47 4         7 my $ResponseContent;
48 4         29 my $secureHttp = new Business::OnlinePayment::PPIPayMover::SecureHttp;
49 4         19 my $strServer = PAY_HOST;
50 4         17 my $strPath = PAY_HOST_PATH;
51 4         19 my $iPort = PAY_HOST_PORT;
52            
53            
54 4 50       57 if(!$secureHttp->Init) {
55 0         0 $self->{strError} = $secureHttp->GetErrorString;
56 0         0 return undef;
57             }
58            
59 4 50       39 if(!$secureHttp->Connect($strServer, $iPort)) {
60 0         0 $self->{strError} = $secureHttp->GetErrorString;
61 0         0 return undef;
62             }
63 4 50       96 if(!$secureHttp->DoSecurePost($strPath, $PostString, \$self->{strResponse})) {
64 0         0 $self->{strError} .= $secureHttp->GetErrorString;
65 0         0 return undef;
66             }
67            
68 4         36 $secureHttp->DisconnectFromServer;
69 4         30 $secureHttp->CleanUp;
70            
71 4         23 my $i = index($self->{strResponse}, "response_code");
72 4 50       34 if($i>=0) {
73 0         0 $ResponseContent = substr($self->{strResponse}, $i);
74 0         0 return $transReq->GetTransResponseObject(\$ResponseContent);
75             }
76             else {
77 4         133 return undef;
78             }
79             }
80            
81            
82            
83             sub GetErrorString
84             {
85 4     4 0 13 my $self = shift;
86 4           return $self->{strError};
87             }
88            
89             #JString TransactionClient::GetResponseString()
90             #{
91             # return m_jstrResponse;
92             #}