1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\Redsys\Message; |
4
|
|
|
|
5
|
|
|
use SimpleXMLElement; |
6
|
|
|
use Omnipay\Common\Message\AbstractResponse; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Redsys Purchase Response |
10
|
|
|
*/ |
11
|
|
|
class WebservicePurchaseResponse extends AbstractResponse |
12
|
|
|
{ |
13
|
|
|
public function isSuccessful() |
14
|
|
|
{ |
15
|
|
|
// check for field existence as well as value |
16
|
|
|
return !empty($this->data->CODIGO) |
17
|
|
|
&& $this->data->CODIGO == '0' |
18
|
|
|
&& !empty($this->data->OPERACION->Ds_Response) |
19
|
|
|
&& $this->data->OPERACION->Ds_Response == '0000'; |
20
|
|
|
// @todo && verify signature |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
// @todo Other methods required for abstract response |
24
|
|
|
public function getTransactionReference() |
25
|
|
|
{ |
26
|
|
|
return "WOOT"; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// @todo Switch to just returning the error code (no message supplied in package) |
30
|
|
|
public function getMessage() |
31
|
|
|
{ |
32
|
|
|
if ($this->data instanceof SimpleXMLElement) { |
33
|
|
|
$out = $this->data->asXML(); |
34
|
|
|
} else { |
35
|
|
|
$out = json_encode($this->data); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
return is_string($out) ? $out : 'nope'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// @todo Pull out signature methods for use in webservice request/response validation |
42
|
|
|
// public function getRedirectData() |
43
|
|
|
// { |
44
|
|
|
// $security = new Security; |
45
|
|
|
// $redirect_data = array(); |
46
|
|
|
// $redirect_data['Ds_SignatureVersion'] = Security::VERSION; |
47
|
|
|
// $redirect_data['Ds_MerchantParameters'] = $security->encodeMerchantParameters($this->data); |
48
|
|
|
// $redirect_data['Ds_Signature'] = $security->createSignature( |
49
|
|
|
// $redirect_data['Ds_MerchantParameters'], |
50
|
|
|
// $this->data['Ds_Merchant_Order'], |
51
|
|
|
// base64_decode($this->request->getHmacKey()) |
52
|
|
|
// ); |
53
|
|
|
|
54
|
|
|
// return $redirect_data; |
55
|
|
|
// } |
56
|
|
|
} |
57
|
|
|
|