-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsecpay.php
162 lines (122 loc) · 4.29 KB
/
secpay.php
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
<?
/*
* secpay.php
*
* PHP Secpay
* Some functions to help connect to Paypoint / Secpay's XMLRPC API.
*
* Requires: Zend Framework v1.8 or later
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2010 Paul Maunders (http://www.pyrosoft.co.uk/blog/)
*/
// Implements the SECVPN.validateCardFull method
// Documentation @ http://www.secpay.com/xmlrpc/realtimeTransaction.html
function ValidateCardFull(
// Argument list same as old function to be backwards compatible
$transId,
$ip,
$name,
$cardNumber,
$amount,
$expiryDate,
$card_type,
$options = array(),
$issueNumber ="",
$startDate ="",
$order ="",
$shipping ="",
$billing =""
) {
$options = http_build_query($options); // Convert array to query string
// http://www.secpay.com/xmlrpc/realtimeTransaction.html
$values = array(
SECPAY_USER, // mid - Merchant ID
SECPAY_VPN_PASSWORD, // vpn_pswd - VPN Password
(string) $transId, // trans_id - Transaction ID
(string) $ip, // ip - IP Address
(string) $name, // name - Cardholder Name
(string) $cardNumber, // card_number - Card Number
(string) $amount, // amount - Amount to charge
(string) $expiryDate, // expiry_date - Card Expiry Date
(string) $issueNumber, // issue_number - Card Issue Number
(string) $startDate, // start_date - Card Start Date
(string) $order, // order - Order Details
(string) $shipping, // shipping - Shipping Address Details
(string) $billing, // billing - Billing Address Details
(string) $options, // options - Optional Parameters
);
return secpay_xmlrpc_call('SECVPN.validateCardFull', $values);
}
// Implements the SECVPN.repeatCardFullAddr method
// Documentation @ http://www.secpay.com/xmlrpc/repeatTransaction.html
function RepeatCardFullAddr(
// Argument list same as old function to be backwards compatible
$orig_trans_id,
$amount,
$new_trans_id,
$exp_date = "",
$order ="",
$shipping ="",
$billing ="",
$options =""
) {
$options = http_build_query($options); // Convert array to query string
// http://www.secpay.com/xmlrpc/repeatTransaction.html
$values = array(
SECPAY_USER, // mid - Merchant ID
SECPAY_VPN_PASSWORD, // vpn_pswd - VPN Password
(string) $orig_trans_id, // trans_id - Transaction ID
(string) $amount, // amount - Amount to charge
SECPAY_REMOTE_PASSWORD, // remote_pswd - Remote Password
(string) $new_trans_id, // new_trans_id - New Transacton ID
(string) $exp_date, // exp_date - Expiry Date (optional)
(string) $order, // order - Order Details
(string) $shipping, // shipping - Shipping Address Details
(string) $billing, // billing - Billing Address Details
(string) $options, // options - Optional Parameters
);
return secpay_xmlrpc_call('SECVPN.repeatCardFullAddr', $values);
}
// Implements the SECVPN.refundCardFull method
// Documentation @ http://www.secpay.com/xmlrpc/refundTransaction.html
function RefundCardFull(
$orig_trans_id,
$amount,
$new_trans_id
) {
// http://www.secpay.com/xmlrpc/refundTransaction.html
$values = array(
SECPAY_USER, // mid - Merchant ID
SECPAY_VPN_PASSWORD, // vpn_pswd - VPN Password
(string) $orig_trans_id, // trans_id - Transaction ID
(string) $amount, // amount - Amount to charge
SECPAY_REMOTE_PASSWORD, // remote_pswd - Remote Password
(string) $new_trans_id, // new_trans_id - New Transacton ID
);
return secpay_xmlrpc_call('SECVPN.refundCardFull', $values);
}
// Wraps Zend XMLRPC Client and makes the call to SecPay
function secpay_xmlrpc_call ($call, $values) {
$client = new Zend_XmlRpc_Client('https://www.secpay.com/secxmlrpc/make_call');
//echo "<pre>"; var_dump($values); echo "</pre>";
try {
$response = $client->call($call, $values);
} catch (Zend_XmlRpc_Client_FaultException $e) {
echo 'ERROR ['.$e->getCode().']:'.$e->getMessage();
} catch (Zend_XmlRpc_Client_HttpException $e) {
echo 'ERROR ['.$e->getCode().']:'.$e->getMessage();
}
// echo "<pre>"; var_dump($response); echo "</pre>";
if ($response) {
parse_str($response, $result); // Convert response query string to array
return $result;
} else {
$result['?valid'] = false;
$result['message'] = "no valid response from SECpay";
$result['code'] = "no valid response from SECpay";
return $result;
}
}
?>