blob: cef6a99ef8843886f23057e348be3d61dcd64847 (
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
|
use strict;
package Business::OnlinePayment::PPIPayMover::TransactionClient;
use Business::OnlinePayment::PPIPayMover::TransactionResponse;
use Business::OnlinePayment::PPIPayMover::TransactionRequest;
use Business::OnlinePayment::PPIPayMover::CreditCardRequest;
use Business::OnlinePayment::PPIPayMover::CreditCardResponse;
use Business::OnlinePayment::PPIPayMover::SecureHttp;
use Business::OnlinePayment::PPIPayMover::constants;
1;
# default constructor
sub new {
my $class = shift;
my $self = {};
$self->{strError} = "";
$self->{strResponse} = "";
bless $self, $class;
return $self;
}
sub doTransaction # take three arguements
{
my $self = shift;
my $TransactionKey = shift; # the first arguement(string)
my $transReq = shift; # the second arguement(class object)
my $AccountToken = shift; # the third arguement(string)
my $PostString = "";
my $ResponseString = "";
# write out account_token ...
$PostString .= "account_token=$AccountToken";
$PostString .= "&";
# write out transaction_key ...
#$PostString .= "transaction_key=$TransactionKey";
#$PostString .= "&";
# write out version_id ...
my $temp = VERSION;
$temp =~ tr/ /+/;
$PostString .= "version_id=$temp";
$PostString .= "&";
$transReq->WriteRequest(\$PostString); # get post information
my $ResponseContent;
my $secureHttp = new Business::OnlinePayment::PPIPayMover::SecureHttp;
my $strServer = PAY_HOST;
my $strPath = PAY_HOST_PATH;
my $iPort = PAY_HOST_PORT;
if(!$secureHttp->Init) {
$self->{strError} = $secureHttp->GetErrorString;
return undef;
}
if(!$secureHttp->Connect($strServer, $iPort)) {
$self->{strError} = $secureHttp->GetErrorString;
return undef;
}
if(!$secureHttp->DoSecurePost($strPath, $PostString, \$self->{strResponse})) {
$self->{strError} .= $secureHttp->GetErrorString;
return undef;
}
$secureHttp->DisconnectFromServer;
$secureHttp->CleanUp;
my $i = index($self->{strResponse}, "response_code");
if($i>=0) {
$ResponseContent = substr($self->{strResponse}, $i);
return $transReq->GetTransResponseObject(\$ResponseContent);
}
else {
return undef;
}
}
sub GetErrorString
{
my $self = shift;
return $self->{strError};
}
#JString TransactionClient::GetResponseString()
#{
# return m_jstrResponse;
#}
|