-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallCheckCartaS2S.php
More file actions
100 lines (85 loc) · 3.01 KB
/
callCheckCartaS2S.php
File metadata and controls
100 lines (85 loc) · 3.01 KB
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
<?php
/**
* Created by Gestpay.
* Date: 08/03/17
* Time: 12:32
*
* This example shows a way to use callCheckCartaS2S with the minimum required parameters.
* callCheckCartaS2S is described here: http://docs.gestpay.it/adv/card-check.html
* the API: http://api.gestpay.it/#callcheckcartas2s
*
*/
//display errors.
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*****************************************************************
* TEST ENVIRONMENT: if set to false, this example will launch
* against the production server.
*****************************************************************/
$testEnv = true;
/*****************************************************************
* MANDATORY DATA
*****************************************************************/
$shopLogin = "GESPAY65987";
$shopTransactionId = "GESTPAY_S2S_".date("Y-m-d-H-i-s");
$withAuth = "Y";
$cardNumber = "4775718800001010";
$expMonth = "05";
$expYear = "17";
$CVV2 = "999";
/****************************************************************
* CREATING SOAP ARGUMENTS
* The $param variable will contain the argument for the S2S call.
* If you add more parameters you must add them here.
****************************************************************/
//Set up the parameters array. This array will be the argument for the SOAP call.
$param = array(
'shopLogin' => $shopLogin,
'shopTransactionId' => $shopTransactionId,
'withAuth' => $withAuth,
'cardNumber' => $cardNumber,
'expMonth' => $expMonth,
'expYear' => $expYear,
'CVV2' => $CVV2
);
/****************************************************************
* CALL callCheckCartaS2S
****************************************************************/
//setting up the WSDL url
$wsdl = "https://ecomms2s.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL";
if ($testEnv) {
//Test
$wsdl = "https://testecomm.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL";
}
//Soap client
$client = new SoapClient($wsdl);
//do the call to Encrypt method
try {
$objectResult = $client->callCheckCartaS2S($param);
} //catch SOAP exceptions
catch (SoapFault $fault) {
die($fault);
}
//parse the XML result
$result = simplexml_load_string($objectResult->callCheckCartaS2SResult->any);
//Error Check
$errCode = (string) $result->TransactionErrorCode;
$errDesc = (string) $result->TransactionErrorDescription;
if ($errCode !== "0") {
//An error has occurred; check ErrorCode and ErrorDescription
echo '<!DOCTYPE HTML><html><head><style>html,body{margin: 0;padding: 0;} .error{width:100%;margin:0;border-bottom:1px solid black;background-color:#FFEC8B;text-align:center;font-size:1em;font-weight:bold;color:red;padding: 0;}</style></head><html><body>';
echo '<div class="error">Error:';
echo $errCode;
echo '<br>ErrorDesc:';
echo $errDesc;
echo '</div></body></html>';
exit();
} else {
//Call went OK, see the parameters
echo '<!DOCTYPE HTML><html><body>';
echo '<pre>';
print_r($result);
echo '</pre>';
echo '</body></html>';
}