-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallReadTrxS2S.php
More file actions
101 lines (85 loc) · 3.09 KB
/
callReadTrxS2S.php
File metadata and controls
101 lines (85 loc) · 3.09 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
101
<?php
/**
* Created by Gestpay.
* Date: 08/03/17
* Time: 12:32
*
* This example shows a way to use callReadTrxS2S with the minimum required parameters.
* callReadTrxS2S is described here: http://docs.gestpay.it/adv/query-transaction-status.html
* the API: http://api.gestpay.it/#callreadtrxs2s
*
*/
//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: this is a code that identifies your account.
* amount: the amount of the transaction
* uicCode: the currency code
* shopTransactionId: a transaction identifier given by you
* bankTransactionId: a transaction identifier given by the bank
*****************************************************************/
$shopLogin = "GESPAY65987";
$bankTransactionId = "108";
$shopTransactionId = null;
/****************************************************************
* 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,
'bankTransactionId' => $bankTransactionId,
'shopTransactionId' => $shopTransactionId
);
/****************************************************************
* CALL callReadTrxS2S
****************************************************************/
$wsdl = null;
//setting up the WSDL url
if ($testEnv) {
//Test
$wsdl = "https://testecomm.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL";
} else {
//Production
$wsdl = "https://ecomms2s.sella.it/gestpay/gestpayws/WSs2s.asmx?WSDL";
}
//Soap client
$client = new SoapClient($wsdl);
//do the call to Encrypt method
try {
$objectResult = $client->callReadTrxS2S($param);
} //catch SOAP exceptions
catch (SoapFault $fault) {
die($fault);
}
//parse the XML result
$result = simplexml_load_string($objectResult->callReadTrxS2SResult->any);
//Error Check
$errCode = (string) $result->ErrorCode;
$errDesc = (string) $result->ErrorDescription;
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>';
}