-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallDeleteS2S.php
More file actions
105 lines (88 loc) · 3.12 KB
/
callDeleteS2S.php
File metadata and controls
105 lines (88 loc) · 3.12 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
102
103
104
105
<?php
/**
* Created by Gestpay.
* Date: 08/03/17
* Time: 12:32
*
* This example shows a way to use callDeleteS2S with the minimum required parameters.
* callDeleteS2S is described here: http://docs.gestpay.it/adv/withdrawal.html
* the API: http://api.gestpay.it/#calldeletes2s
*
*/
//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
* bankTransID: a transaction identifier returned by the bank
*
* You can also use the shopTransID, the Id that you gave to the
* transaction.
*****************************************************************/
$shopLogin = "GESPAY65987";
$bankTransactionId = "111";
//shopTransactionId = "...";
$cancelReason = "Clicked BUY by error";
/****************************************************************
* 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,
'CancelReason' => $cancelReason
);
/****************************************************************
* CALL callDeleteS2S
****************************************************************/
$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->callDeleteS2S($param);
} //catch SOAP exceptions
catch (SoapFault $fault) {
die($fault);
}
//parse the XML result
$result = simplexml_load_string($objectResult->callDeleteS2SResult->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>';
}