1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Redsys\Message; |
4
|
|
|
|
5
|
|
|
use SimpleXMLElement; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Redsys Webservice Purchase Request. |
9
|
|
|
*/ |
10
|
|
|
class RefundRequest extends AbstractRequest |
11
|
|
|
{ |
12
|
|
|
use WebserviceTrait; |
13
|
|
|
|
14
|
|
|
/** @var CatalogInterface */ |
|
|
|
|
15
|
|
|
protected $redsysMessages; |
16
|
|
|
|
17
|
3 |
|
public function getData() |
18
|
|
|
{ |
19
|
3 |
|
$this->validate('merchantId', 'terminalId', 'amount', 'currency', 'transactionId'); |
20
|
|
|
|
21
|
|
|
$data = [ |
22
|
3 |
|
'DS_MERCHANT_AMOUNT' => $this->getAmountInteger(), |
23
|
3 |
|
'DS_MERCHANT_ORDER' => $this->getTransactionId(), |
24
|
3 |
|
'DS_MERCHANT_MERCHANTCODE' => $this->getMerchantId(), |
25
|
3 |
|
'DS_MERCHANT_TERMINAL' => $this->getTerminalId(), |
26
|
3 |
|
'DS_MERCHANT_CURRENCY' => $this->getCurrencyNumeric(), // uses ISO-4217 codes |
27
|
3 |
|
'DS_MERCHANT_TRANSACTIONTYPE' => '3', // Refund |
|
|
|
|
28
|
|
|
// undocumented fields |
29
|
|
|
// 'DS_MERCHANT_MERCHANTDATA' => $this->getMerchantData(), |
30
|
|
|
// 'DS_MERCHANT_MERCHANTNAME' => $this->getMerchantName(), |
31
|
|
|
// 'DS_MERCHANT_CONSUMERLANGUAGE' => $this->getConsumerLanguage(), |
32
|
3 |
|
]; |
33
|
|
|
|
34
|
3 |
|
$request = new SimpleXMLElement('<REQUEST/>'); |
35
|
3 |
|
$requestData = $request->addChild('DATOSENTRADA'); |
36
|
3 |
|
foreach ($data as $tag => $value) { |
37
|
3 |
|
$requestData->addChild($tag, $value); |
38
|
3 |
|
} |
39
|
|
|
|
40
|
3 |
|
$security = new Security(); |
41
|
|
|
|
42
|
3 |
|
$request->addChild('DS_SIGNATUREVERSION', Security::VERSION); |
43
|
3 |
|
$request->addChild('DS_SIGNATURE', $security->createSignature( |
44
|
3 |
|
$requestData->asXML(), |
|
|
|
|
45
|
3 |
|
$data['DS_MERCHANT_ORDER'], |
46
|
3 |
|
$this->getHmacKey() |
47
|
3 |
|
)); |
48
|
|
|
|
49
|
|
|
// keep data as nested array for method signature compatibility |
50
|
|
|
return [ |
51
|
3 |
|
'DATOSENTRADA' => $data, |
52
|
3 |
|
'DS_SIGNATUREVERSION' => (string) $request->DS_SIGNATUREVERSION, |
53
|
3 |
|
'DS_SIGNATURE' => (string) $request->DS_SIGNATURE, |
54
|
3 |
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Send the data. |
59
|
|
|
* |
60
|
|
|
* Uses its own SOAP wrapper instead of PHP's SoapClient |
61
|
|
|
*/ |
62
|
2 |
|
public function sendData($data) |
63
|
|
|
{ |
64
|
|
|
// re-create the XML |
65
|
2 |
|
$request = new SimpleXMLElement('<REQUEST/>'); |
66
|
2 |
|
$requestData = $request->addChild('DATOSENTRADA'); |
67
|
2 |
|
foreach ($data['DATOSENTRADA'] as $tag => $value) { |
68
|
2 |
|
$requestData->addChild($tag, $value); |
69
|
2 |
|
} |
70
|
2 |
|
$request->addChild('DS_SIGNATUREVERSION', $data['DS_SIGNATUREVERSION']); |
71
|
2 |
|
$request->addChild('DS_SIGNATURE', $data['DS_SIGNATURE']); |
72
|
|
|
|
73
|
|
|
// wrap in SOAP envelope |
74
|
|
|
$requestEnvelope = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> |
75
|
|
|
<soapenv:Header/> |
76
|
|
|
<soapenv:Body> |
77
|
|
|
<impl:trataPeticion xmlns:impl='http://webservice.sis.sermepa.es'> |
78
|
|
|
<impl:datosEntrada> |
79
|
2 |
|
".htmlspecialchars($request->asXML()).' |
|
|
|
|
80
|
|
|
</impl:datosEntrada> |
81
|
|
|
</impl:trataPeticion> |
82
|
|
|
</soapenv:Body> |
83
|
2 |
|
</soapenv:Envelope>'; |
84
|
|
|
|
85
|
|
|
// send the actual SOAP request |
86
|
2 |
|
$httpResponse = $this->httpClient->request( |
87
|
2 |
|
'POST', |
88
|
2 |
|
$this->getEndpoint(), |
89
|
2 |
|
['SOAPAction' => 'trataPeticion'], |
90
|
|
|
$requestEnvelope |
91
|
2 |
|
); |
92
|
|
|
|
93
|
|
|
// unwrap httpResponse into actual data as SimpleXMLElement tree |
94
|
2 |
|
$responseEnvelope = simplexml_load_string($httpResponse->getBody()->getContents()); |
95
|
2 |
|
$responseData = new SimpleXMLElement(htmlspecialchars_decode( |
96
|
2 |
|
$responseEnvelope->children('http://schemas.xmlsoap.org/soap/envelope/') |
97
|
2 |
|
->Body->children('http://webservice.sis.sermepa.es') |
98
|
2 |
|
->trataPeticionResponse |
99
|
2 |
|
->trataPeticionReturn |
100
|
2 |
|
)); |
101
|
|
|
|
102
|
|
|
// remove any reflected request data (this happens on SIS errors, and includes card number) |
|
|
|
|
103
|
|
|
// if (isset($responseData->RECIBIDO)) { |
104
|
|
|
// unset($responseData->RECIBIDO); |
105
|
|
|
// } |
106
|
|
|
|
107
|
|
|
// convert to nested arrays (drop the 'true' to use simple objects) |
108
|
2 |
|
$responseData = json_decode(json_encode($responseData), true); |
109
|
|
|
|
110
|
2 |
|
return $this->response = new RefundResponse($this, $responseData); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths