| @@ -7,13 +7,13 @@ | ||
| 7 | 7 | */ | 
| 8 | 8 | class CompletePurchaseRequest extends PurchaseRequest | 
| 9 | 9 |  { | 
| 10 | - public function getData() | |
| 11 | -    { | |
| 12 | - return $this->httpRequest->request->all(); | |
| 13 | - } | |
| 10 | + public function getData() | |
| 11 | +	{ | |
| 12 | + return $this->httpRequest->request->all(); | |
| 13 | + } | |
| 14 | 14 | |
| 15 | - public function sendData($data) | |
| 16 | -    { | |
| 17 | - return $this->response = new CompletePurchaseResponse($this, $data); | |
| 18 | - } | |
| 15 | + public function sendData($data) | |
| 16 | +	{ | |
| 17 | + return $this->response = new CompletePurchaseResponse($this, $data); | |
| 18 | + } | |
| 19 | 19 | } | 
| @@ -5,15 +5,12 @@ | ||
| 5 | 5 | /** | 
| 6 | 6 | * Redsys Complete Purchase Request | 
| 7 | 7 | */ | 
| 8 | -class CompletePurchaseRequest extends PurchaseRequest | |
| 9 | -{ | |
| 10 | - public function getData() | |
| 11 | -    { | |
| 8 | +class CompletePurchaseRequest extends PurchaseRequest { | |
| 9 | +    public function getData() { | |
| 12 | 10 | return $this->httpRequest->request->all(); | 
| 13 | 11 | } | 
| 14 | 12 | |
| 15 | - public function sendData($data) | |
| 16 | -    { | |
| 13 | +    public function sendData($data) { | |
| 17 | 14 | return $this->response = new CompletePurchaseResponse($this, $data); | 
| 18 | 15 | } | 
| 19 | 16 | } | 
| @@ -8,8 +8,7 @@ discard block | ||
| 8 | 8 | /** | 
| 9 | 9 | * Redsys Complete Purchase Response | 
| 10 | 10 | */ | 
| 11 | -class CompletePurchaseResponse extends AbstractResponse | |
| 12 | -{ | |
| 11 | +class CompletePurchaseResponse extends AbstractResponse { | |
| 13 | 12 | /** @var array */ | 
| 14 | 13 | protected $merchantParameters; | 
| 15 | 14 | /** @var string */ | 
| @@ -27,8 +26,7 @@ discard block | ||
| 27 | 26 | * | 
| 28 | 27 | * @throws InvalidResponseException If order number is missing or signature does not match | 
| 29 | 28 | */ | 
| 30 | - public function __construct(RequestInterface $request, $data) | |
| 31 | -    { | |
| 29 | +    public function __construct(RequestInterface $request, $data) { | |
| 32 | 30 | parent::__construct($request, $data); | 
| 33 | 31 | |
| 34 | 32 |          if (!empty($data['Ds_MerchantParameters'])) { | 
| @@ -65,8 +63,7 @@ discard block | ||
| 65 | 63 | * | 
| 66 | 64 | * @return boolean | 
| 67 | 65 | */ | 
| 68 | - public function isSuccessful() | |
| 69 | -    { | |
| 66 | +    public function isSuccessful() { | |
| 70 | 67 | $key = $this->usingUpcaseParameters ? 'DS_RESPONSE' : 'Ds_Response'; | 
| 71 | 68 | return isset($this->merchantParameters[$key]) | 
| 72 | 69 | && is_numeric($this->merchantParameters[$key]) | 
| @@ -79,8 +76,7 @@ discard block | ||
| 79 | 76 | * | 
| 80 | 77 | * @return mixed | 
| 81 | 78 | */ | 
| 82 | - public function getData() | |
| 83 | -    { | |
| 79 | +    public function getData() { | |
| 84 | 80 | $data = parent::getData(); | 
| 85 | 81 | return is_array($data) && is_array($this->merchantParameters) | 
| 86 | 82 | ? array_merge($data, $this->merchantParameters) | 
| @@ -92,8 +88,7 @@ discard block | ||
| 92 | 88 | * | 
| 93 | 89 | * @return null|mixed | 
| 94 | 90 | */ | 
| 95 | - protected function getKey($key) | |
| 96 | -    { | |
| 91 | +    protected function getKey($key) { | |
| 97 | 92 |          if ($this->usingUpcaseParameters) { | 
| 98 | 93 | $key = strtoupper($key); | 
| 99 | 94 | } | 
| @@ -105,8 +100,7 @@ discard block | ||
| 105 | 100 | * | 
| 106 | 101 | * @return null|string | 
| 107 | 102 | */ | 
| 108 | - public function getTransactionReference() | |
| 109 | -    { | |
| 103 | +    public function getTransactionReference() { | |
| 110 | 104 |          return $this->getKey('Ds_AuthorisationCode'); | 
| 111 | 105 | } | 
| 112 | 106 | |
| @@ -115,8 +109,7 @@ discard block | ||
| 115 | 109 | * | 
| 116 | 110 | * @return null|string | 
| 117 | 111 | */ | 
| 118 | - public function getMessage() | |
| 119 | -    { | |
| 112 | +    public function getMessage() { | |
| 120 | 113 |          return $this->getKey('Ds_Response'); | 
| 121 | 114 | } | 
| 122 | 115 | |
| @@ -125,8 +118,7 @@ discard block | ||
| 125 | 118 | * | 
| 126 | 119 | * @return null|string | 
| 127 | 120 | */ | 
| 128 | - public function getCardType() | |
| 129 | -    { | |
| 121 | +    public function getCardType() { | |
| 130 | 122 |          return $this->getKey('Ds_Card_Type'); | 
| 131 | 123 | } | 
| 132 | 124 | } | 
| @@ -11,127 +11,127 @@ | ||
| 11 | 11 | */ | 
| 12 | 12 | class CompletePurchaseResponse extends AbstractResponse | 
| 13 | 13 |  { | 
| 14 | - /** @var array */ | |
| 15 | - protected $merchantParameters; | |
| 16 | - /** @var string */ | |
| 17 | - protected $returnSignature; | |
| 18 | - /** @var boolean */ | |
| 19 | - protected $usingUpcaseParameters = false; | |
| 20 | - /** @var boolean */ | |
| 21 | - protected $usingUpcaseResponse = false; | |
| 14 | + /** @var array */ | |
| 15 | + protected $merchantParameters; | |
| 16 | + /** @var string */ | |
| 17 | + protected $returnSignature; | |
| 18 | + /** @var boolean */ | |
| 19 | + protected $usingUpcaseParameters = false; | |
| 20 | + /** @var boolean */ | |
| 21 | + protected $usingUpcaseResponse = false; | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * Constructor | |
| 25 | - * | |
| 26 | - * @param RequestInterface $request the initiating request. | |
| 27 | - * @param mixed $data | |
| 28 | - * | |
| 29 | - * @throws InvalidResponseException If merchant data or order number is missing, or signature does not match | |
| 30 | - */ | |
| 31 | - public function __construct(RequestInterface $request, $data) | |
| 32 | -    { | |
| 33 | - parent::__construct($request, $data); | |
| 23 | + /** | |
| 24 | + * Constructor | |
| 25 | + * | |
| 26 | + * @param RequestInterface $request the initiating request. | |
| 27 | + * @param mixed $data | |
| 28 | + * | |
| 29 | + * @throws InvalidResponseException If merchant data or order number is missing, or signature does not match | |
| 30 | + */ | |
| 31 | + public function __construct(RequestInterface $request, $data) | |
| 32 | +	{ | |
| 33 | + parent::__construct($request, $data); | |
| 34 | 34 | |
| 35 | - $security = new Security; | |
| 35 | + $security = new Security; | |
| 36 | 36 | |
| 37 | -        if (!empty($data['Ds_MerchantParameters'])) { | |
| 38 | - $this->merchantParameters = $security->decodeMerchantParameters($data['Ds_MerchantParameters']); | |
| 39 | -        } elseif (!empty($data['DS_MERCHANTPARAMETERS'])) { | |
| 40 | - $this->merchantParameters = $security->decodeMerchantParameters($data['DS_MERCHANTPARAMETERS']); | |
| 41 | - $this->usingUpcaseResponse = true; | |
| 42 | -        } else { | |
| 43 | -            throw new InvalidResponseException('Invalid response from payment gateway (no data)'); | |
| 44 | - } | |
| 37 | +		if (!empty($data['Ds_MerchantParameters'])) { | |
| 38 | + $this->merchantParameters = $security->decodeMerchantParameters($data['Ds_MerchantParameters']); | |
| 39 | +		} elseif (!empty($data['DS_MERCHANTPARAMETERS'])) { | |
| 40 | + $this->merchantParameters = $security->decodeMerchantParameters($data['DS_MERCHANTPARAMETERS']); | |
| 41 | + $this->usingUpcaseResponse = true; | |
| 42 | +		} else { | |
| 43 | +			throw new InvalidResponseException('Invalid response from payment gateway (no data)'); | |
| 44 | + } | |
| 45 | 45 | |
| 46 | -        if (!empty($this->merchantParameters['Ds_Order'])) { | |
| 47 | - $order = $this->merchantParameters['Ds_Order']; | |
| 48 | -        } elseif (!empty($this->merchantParameters['DS_ORDER'])) { | |
| 49 | - $order = $this->merchantParameters['DS_ORDER']; | |
| 50 | - $this->usingUpcaseParameters = true; | |
| 51 | -        } else { | |
| 52 | - throw new InvalidResponseException(); | |
| 53 | - } | |
| 46 | +		if (!empty($this->merchantParameters['Ds_Order'])) { | |
| 47 | + $order = $this->merchantParameters['Ds_Order']; | |
| 48 | +		} elseif (!empty($this->merchantParameters['DS_ORDER'])) { | |
| 49 | + $order = $this->merchantParameters['DS_ORDER']; | |
| 50 | + $this->usingUpcaseParameters = true; | |
| 51 | +		} else { | |
| 52 | + throw new InvalidResponseException(); | |
| 53 | + } | |
| 54 | 54 | |
| 55 | - $this->returnSignature = $security->createReturnSignature( | |
| 56 | - $data[$this->usingUpcaseResponse ? 'DS_MERCHANTPARAMETERS' : 'Ds_MerchantParameters'], | |
| 57 | - $order, | |
| 58 | - base64_decode($this->request->getHmacKey()) | |
| 59 | - ); | |
| 55 | + $this->returnSignature = $security->createReturnSignature( | |
| 56 | + $data[$this->usingUpcaseResponse ? 'DS_MERCHANTPARAMETERS' : 'Ds_MerchantParameters'], | |
| 57 | + $order, | |
| 58 | + base64_decode($this->request->getHmacKey()) | |
| 59 | + ); | |
| 60 | 60 | |
| 61 | -        if ($this->returnSignature != $data[$this->usingUpcaseResponse ? 'DS_SIGNATURE' : 'Ds_Signature']) { | |
| 62 | -            throw new InvalidResponseException('Invalid response from payment gateway (signature mismatch)'); | |
| 63 | - } | |
| 64 | - } | |
| 61 | +		if ($this->returnSignature != $data[$this->usingUpcaseResponse ? 'DS_SIGNATURE' : 'Ds_Signature']) { | |
| 62 | +			throw new InvalidResponseException('Invalid response from payment gateway (signature mismatch)'); | |
| 63 | + } | |
| 64 | + } | |
| 65 | 65 | |
| 66 | - /** | |
| 67 | - * Is the response successful? | |
| 68 | - * | |
| 69 | - * @return boolean | |
| 70 | - */ | |
| 71 | - public function isSuccessful() | |
| 72 | -    { | |
| 73 | - $key = $this->usingUpcaseParameters ? 'DS_RESPONSE' : 'Ds_Response'; | |
| 74 | - return isset($this->merchantParameters[$key]) | |
| 75 | - && is_numeric($this->merchantParameters[$key]) | |
| 76 | - && 0 <= $this->merchantParameters[$key] | |
| 77 | - && 100 > $this->merchantParameters[$key]; | |
| 78 | - } | |
| 66 | + /** | |
| 67 | + * Is the response successful? | |
| 68 | + * | |
| 69 | + * @return boolean | |
| 70 | + */ | |
| 71 | + public function isSuccessful() | |
| 72 | +	{ | |
| 73 | + $key = $this->usingUpcaseParameters ? 'DS_RESPONSE' : 'Ds_Response'; | |
| 74 | + return isset($this->merchantParameters[$key]) | |
| 75 | + && is_numeric($this->merchantParameters[$key]) | |
| 76 | + && 0 <= $this->merchantParameters[$key] | |
| 77 | + && 100 > $this->merchantParameters[$key]; | |
| 78 | + } | |
| 79 | 79 | |
| 80 | - /** | |
| 81 | - * Get the response data, included the decoded merchant parameters if available. | |
| 82 | - * | |
| 83 | - * @return mixed | |
| 84 | - */ | |
| 85 | - public function getData() | |
| 86 | -    { | |
| 87 | - $data = parent::getData(); | |
| 88 | - return is_array($data) && is_array($this->merchantParameters) | |
| 89 | - ? array_merge($data, $this->merchantParameters) | |
| 90 | - : $data; | |
| 91 | - } | |
| 80 | + /** | |
| 81 | + * Get the response data, included the decoded merchant parameters if available. | |
| 82 | + * | |
| 83 | + * @return mixed | |
| 84 | + */ | |
| 85 | + public function getData() | |
| 86 | +	{ | |
| 87 | + $data = parent::getData(); | |
| 88 | + return is_array($data) && is_array($this->merchantParameters) | |
| 89 | + ? array_merge($data, $this->merchantParameters) | |
| 90 | + : $data; | |
| 91 | + } | |
| 92 | 92 | |
| 93 | - /** | |
| 94 | - * Helper method to get a specific merchant parameter if available. | |
| 95 | - * | |
| 96 | - * @param string $key The key to look up | |
| 97 | - * | |
| 98 | - * @return null|mixed | |
| 99 | - */ | |
| 100 | - protected function getKey($key) | |
| 101 | -    { | |
| 102 | -        if ($this->usingUpcaseParameters) { | |
| 103 | - $key = strtoupper($key); | |
| 104 | - } | |
| 105 | - return isset($this->merchantParameters[$key]) ? $this->merchantParameters[$key] : null; | |
| 106 | - } | |
| 93 | + /** | |
| 94 | + * Helper method to get a specific merchant parameter if available. | |
| 95 | + * | |
| 96 | + * @param string $key The key to look up | |
| 97 | + * | |
| 98 | + * @return null|mixed | |
| 99 | + */ | |
| 100 | + protected function getKey($key) | |
| 101 | +	{ | |
| 102 | +		if ($this->usingUpcaseParameters) { | |
| 103 | + $key = strtoupper($key); | |
| 104 | + } | |
| 105 | + return isset($this->merchantParameters[$key]) ? $this->merchantParameters[$key] : null; | |
| 106 | + } | |
| 107 | 107 | |
| 108 | - /** | |
| 109 | - * Get the authorisation code if available. | |
| 110 | - * | |
| 111 | - * @return null|string | |
| 112 | - */ | |
| 113 | - public function getTransactionReference() | |
| 114 | -    { | |
| 115 | -        return $this->getKey('Ds_AuthorisationCode'); | |
| 116 | - } | |
| 108 | + /** | |
| 109 | + * Get the authorisation code if available. | |
| 110 | + * | |
| 111 | + * @return null|string | |
| 112 | + */ | |
| 113 | + public function getTransactionReference() | |
| 114 | +	{ | |
| 115 | +		return $this->getKey('Ds_AuthorisationCode'); | |
| 116 | + } | |
| 117 | 117 | |
| 118 | - /** | |
| 119 | - * Get the merchant response message if available. | |
| 120 | - * | |
| 121 | - * @return null|string | |
| 122 | - */ | |
| 123 | - public function getMessage() | |
| 124 | -    { | |
| 125 | -        return $this->getKey('Ds_Response'); | |
| 126 | - } | |
| 118 | + /** | |
| 119 | + * Get the merchant response message if available. | |
| 120 | + * | |
| 121 | + * @return null|string | |
| 122 | + */ | |
| 123 | + public function getMessage() | |
| 124 | +	{ | |
| 125 | +		return $this->getKey('Ds_Response'); | |
| 126 | + } | |
| 127 | 127 | |
| 128 | - /** | |
| 129 | - * Get the card type if available. | |
| 130 | - * | |
| 131 | - * @return null|string | |
| 132 | - */ | |
| 133 | - public function getCardType() | |
| 134 | -    { | |
| 135 | -        return $this->getKey('Ds_Card_Type'); | |
| 136 | - } | |
| 128 | + /** | |
| 129 | + * Get the card type if available. | |
| 130 | + * | |
| 131 | + * @return null|string | |
| 132 | + */ | |
| 133 | + public function getCardType() | |
| 134 | +	{ | |
| 135 | +		return $this->getKey('Ds_Card_Type'); | |
| 136 | + } | |
| 137 | 137 | } | 
| @@ -139,9 +139,9 @@ | ||
| 139 | 139 | // mandatory fields | 
| 140 | 140 | 'Ds_Merchant_MerchantCode' => $this->getMerchantId(), | 
| 141 | 141 | 'Ds_Merchant_Terminal' => $this->getTerminalId(), | 
| 142 | - 'Ds_Merchant_TransactionType' => '0', // Authorisation | |
| 142 | + 'Ds_Merchant_TransactionType' => '0', // Authorisation | |
| 143 | 143 | 'Ds_Merchant_Amount' => $this->getAmountInteger(), | 
| 144 | - 'Ds_Merchant_Currency' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 144 | + 'Ds_Merchant_Currency' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 145 | 145 | 'Ds_Merchant_Order' => $this->getTransactionId(), | 
| 146 | 146 | 'Ds_Merchant_MerchantUrl' => $this->getNotifyUrl(), | 
| 147 | 147 | // optional fields | 
| @@ -7,8 +7,7 @@ discard block | ||
| 7 | 7 | /** | 
| 8 | 8 | * Redsys Purchase Request | 
| 9 | 9 | */ | 
| 10 | -class PurchaseRequest extends AbstractRequest | |
| 11 | -{ | |
| 10 | +class PurchaseRequest extends AbstractRequest { | |
| 12 | 11 | protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago'; | 
| 13 | 12 | protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago'; | 
| 14 | 13 | protected static $consumerLanguages = array( | 
| @@ -26,18 +25,15 @@ discard block | ||
| 26 | 25 | 'eu' => '013', // Basque | 
| 27 | 26 | ); | 
| 28 | 27 | |
| 29 | - public function getCardholder() | |
| 30 | -    { | |
| 28 | +    public function getCardholder() { | |
| 31 | 29 |          return $this->getParameter('cardholder'); | 
| 32 | 30 | } | 
| 33 | 31 | |
| 34 | - public function setCardholder($value) | |
| 35 | -    { | |
| 32 | +    public function setCardholder($value) { | |
| 36 | 33 |          return $this->setParameter('cardholder', $value); | 
| 37 | 34 | } | 
| 38 | 35 | |
| 39 | - public function getConsumerLanguage() | |
| 40 | -    { | |
| 36 | +    public function getConsumerLanguage() { | |
| 41 | 37 |          return $this->getParameter('consumerLanguage'); | 
| 42 | 38 | } | 
| 43 | 39 | |
| @@ -46,8 +42,7 @@ discard block | ||
| 46 | 42 | * | 
| 47 | 43 | * @param string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code | 
| 48 | 44 | */ | 
| 49 | - public function setConsumerLanguage($value) | |
| 50 | -    { | |
| 45 | +    public function setConsumerLanguage($value) { | |
| 51 | 46 |          if (is_int($value)) { | 
| 52 | 47 |              if ($value < 0 || $value > 13) { | 
| 53 | 48 | $value = 1; | 
| @@ -60,53 +55,43 @@ discard block | ||
| 60 | 55 |          return $this->setParameter('consumerLanguage', $value); | 
| 61 | 56 | } | 
| 62 | 57 | |
| 63 | - public function getHmacKey() | |
| 64 | -    { | |
| 58 | +    public function getHmacKey() { | |
| 65 | 59 |          return $this->getParameter('hmacKey'); | 
| 66 | 60 | } | 
| 67 | 61 | |
| 68 | - public function setHmacKey($value) | |
| 69 | -    { | |
| 62 | +    public function setHmacKey($value) { | |
| 70 | 63 |          return $this->setParameter('hmacKey', $value); | 
| 71 | 64 | } | 
| 72 | 65 | |
| 73 | - public function getMerchantData() | |
| 74 | -    { | |
| 66 | +    public function getMerchantData() { | |
| 75 | 67 |          return $this->getParameter('merchantData'); | 
| 76 | 68 | } | 
| 77 | 69 | |
| 78 | - public function setMerchantData($value) | |
| 79 | -    { | |
| 70 | +    public function setMerchantData($value) { | |
| 80 | 71 |          return $this->setParameter('merchantData', $value); | 
| 81 | 72 | } | 
| 82 | 73 | |
| 83 | - public function getMerchantId() | |
| 84 | -    { | |
| 74 | +    public function getMerchantId() { | |
| 85 | 75 |          return $this->getParameter('merchantId'); | 
| 86 | 76 | } | 
| 87 | 77 | |
| 88 | - public function setMerchantId($value) | |
| 89 | -    { | |
| 78 | +    public function setMerchantId($value) { | |
| 90 | 79 |          return $this->setParameter('merchantId', $value); | 
| 91 | 80 | } | 
| 92 | 81 | |
| 93 | - public function getMerchantName() | |
| 94 | -    { | |
| 82 | +    public function getMerchantName() { | |
| 95 | 83 |          return $this->getParameter('merchantName'); | 
| 96 | 84 | } | 
| 97 | 85 | |
| 98 | - public function setMerchantName($value) | |
| 99 | -    { | |
| 86 | +    public function setMerchantName($value) { | |
| 100 | 87 |          return $this->setParameter('merchantName', $value); | 
| 101 | 88 | } | 
| 102 | 89 | |
| 103 | - public function getTerminalId() | |
| 104 | -    { | |
| 90 | +    public function getTerminalId() { | |
| 105 | 91 |          return $this->getParameter('terminalId'); | 
| 106 | 92 | } | 
| 107 | 93 | |
| 108 | - public function setTerminalId($value) | |
| 109 | -    { | |
| 94 | +    public function setTerminalId($value) { | |
| 110 | 95 |          return $this->setParameter('terminalId', $value); | 
| 111 | 96 | } | 
| 112 | 97 | |
| @@ -115,8 +100,7 @@ discard block | ||
| 115 | 100 | * | 
| 116 | 101 | * @param string|int $value The transaction ID (merchant order) to set for the transaction | 
| 117 | 102 | */ | 
| 118 | - public function setTransactionId($value) | |
| 119 | -    { | |
| 103 | +    public function setTransactionId($value) { | |
| 120 | 104 | $start = substr($value, 0, 4); | 
| 121 | 105 | $numerics = 0; | 
| 122 | 106 |          foreach (str_split($start) as $char) { | 
| @@ -131,8 +115,7 @@ discard block | ||
| 131 | 115 | parent::setTransactionId($value); | 
| 132 | 116 | } | 
| 133 | 117 | |
| 134 | - public function getData() | |
| 135 | -    { | |
| 118 | +    public function getData() { | |
| 136 | 119 |          $this->validate('merchantId', 'terminalId', 'amount', 'currency'); | 
| 137 | 120 | |
| 138 | 121 | return array( | 
| @@ -155,13 +138,11 @@ discard block | ||
| 155 | 138 | ); | 
| 156 | 139 | } | 
| 157 | 140 | |
| 158 | - public function sendData($data) | |
| 159 | -    { | |
| 141 | +    public function sendData($data) { | |
| 160 | 142 | return $this->response = new PurchaseResponse($this, $data); | 
| 161 | 143 | } | 
| 162 | 144 | |
| 163 | - public function getEndpoint() | |
| 164 | -    { | |
| 145 | +    public function getEndpoint() { | |
| 165 | 146 | return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; | 
| 166 | 147 | } | 
| 167 | 148 | } | 
| @@ -9,176 +9,176 @@ | ||
| 9 | 9 | */ | 
| 10 | 10 | class PurchaseRequest extends AbstractRequest | 
| 11 | 11 |  { | 
| 12 | - /** @var string */ | |
| 13 | - protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago'; | |
| 14 | - /** @var string */ | |
| 15 | - protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago'; | |
| 16 | - /** @var array */ | |
| 17 | - protected static $consumerLanguages = array( | |
| 18 | - 'es' => '001', // Spanish | |
| 19 | - 'en' => '002', // English | |
| 20 | - 'ca' => '003', // Catalan - same as Valencian (010) | |
| 21 | - 'fr' => '004', // French | |
| 22 | - 'de' => '005', // German | |
| 23 | - 'nl' => '006', // Dutch | |
| 24 | - 'it' => '007', // Italian | |
| 25 | - 'sv' => '008', // Swedish | |
| 26 | - 'pt' => '009', // Portuguese | |
| 27 | - 'pl' => '011', // Polish | |
| 28 | - 'gl' => '012', // Galician | |
| 29 | - 'eu' => '013', // Basque | |
| 30 | - ); | |
| 31 | - | |
| 32 | - public function getCardholder() | |
| 33 | -    { | |
| 34 | -        return $this->getParameter('cardholder'); | |
| 35 | - } | |
| 36 | - | |
| 37 | - public function setCardholder($value) | |
| 38 | -    { | |
| 39 | -        return $this->setParameter('cardholder', $value); | |
| 40 | - } | |
| 41 | - | |
| 42 | - public function getConsumerLanguage() | |
| 43 | -    { | |
| 44 | -        return $this->getParameter('consumerLanguage'); | |
| 45 | - } | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * Set the language presented to the consumer | |
| 49 | - * | |
| 50 | - * @param string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code | |
| 51 | - */ | |
| 52 | - public function setConsumerLanguage($value) | |
| 53 | -    { | |
| 54 | -        if (is_int($value)) { | |
| 55 | -            if ($value < 0 || $value > 13) { | |
| 56 | - $value = 1; | |
| 57 | - } | |
| 58 | - $value = str_pad($value, 3, '0', STR_PAD_LEFT); | |
| 59 | -        } elseif (!is_numeric($value)) { | |
| 60 | - $value = isset(self::$consumerLanguages[$value]) ? self::$consumerLanguages[$value] : '001'; | |
| 61 | - } | |
| 62 | - | |
| 63 | -        return $this->setParameter('consumerLanguage', $value); | |
| 64 | - } | |
| 65 | - | |
| 66 | - public function getHmacKey() | |
| 67 | -    { | |
| 68 | -        return $this->getParameter('hmacKey'); | |
| 69 | - } | |
| 70 | - | |
| 71 | - public function setHmacKey($value) | |
| 72 | -    { | |
| 73 | -        return $this->setParameter('hmacKey', $value); | |
| 74 | - } | |
| 75 | - | |
| 76 | - public function getMerchantData() | |
| 77 | -    { | |
| 78 | -        return $this->getParameter('merchantData'); | |
| 79 | - } | |
| 80 | - | |
| 81 | - public function setMerchantData($value) | |
| 82 | -    { | |
| 83 | -        return $this->setParameter('merchantData', $value); | |
| 84 | - } | |
| 85 | - | |
| 86 | - public function getMerchantId() | |
| 87 | -    { | |
| 88 | -        return $this->getParameter('merchantId'); | |
| 89 | - } | |
| 90 | - | |
| 91 | - public function setMerchantId($value) | |
| 92 | -    { | |
| 93 | -        return $this->setParameter('merchantId', $value); | |
| 94 | - } | |
| 95 | - | |
| 96 | - public function getMerchantName() | |
| 97 | -    { | |
| 98 | -        return $this->getParameter('merchantName'); | |
| 99 | - } | |
| 100 | - | |
| 101 | - public function setMerchantName($value) | |
| 102 | -    { | |
| 103 | -        return $this->setParameter('merchantName', $value); | |
| 104 | - } | |
| 105 | - | |
| 106 | - public function getTerminalId() | |
| 107 | -    { | |
| 108 | -        return $this->getParameter('terminalId'); | |
| 109 | - } | |
| 110 | - | |
| 111 | - public function setTerminalId($value) | |
| 112 | -    { | |
| 113 | -        return $this->setParameter('terminalId', $value); | |
| 114 | - } | |
| 115 | - | |
| 116 | - /** | |
| 117 | - * Override the abstract method to add requirement that it must start with 4 numeric characters | |
| 118 | - * | |
| 119 | - * @param string|int $value The transaction ID (merchant order) to set for the transaction | |
| 120 | - */ | |
| 121 | - public function setTransactionId($value) | |
| 122 | -    { | |
| 123 | - $start = substr($value, 0, 4); | |
| 124 | - $numerics = 0; | |
| 125 | -        foreach (str_split($start) as $char) { | |
| 126 | -            if (is_numeric($char)) { | |
| 127 | - $numerics++; | |
| 128 | -            } else { | |
| 129 | - break; | |
| 130 | - } | |
| 131 | - } | |
| 132 | - $value = str_pad(substr($start, 0, $numerics), 4, 0, STR_PAD_LEFT).substr($value, $numerics); | |
| 133 | - | |
| 134 | - parent::setTransactionId($value); | |
| 135 | - } | |
| 136 | - | |
| 137 | - public function getData() | |
| 138 | -    { | |
| 139 | -        $this->validate('merchantId', 'terminalId', 'amount', 'currency'); | |
| 140 | - | |
| 141 | - return array( | |
| 142 | - // mandatory fields | |
| 143 | - 'Ds_Merchant_MerchantCode' => $this->getMerchantId(), | |
| 144 | - 'Ds_Merchant_Terminal' => $this->getTerminalId(), | |
| 145 | - 'Ds_Merchant_TransactionType' => '0', // Authorisation | |
| 146 | - 'Ds_Merchant_Amount' => $this->getAmountInteger(), | |
| 147 | - 'Ds_Merchant_Currency' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 148 | - 'Ds_Merchant_Order' => $this->getTransactionId(), | |
| 149 | - 'Ds_Merchant_MerchantUrl' => $this->getNotifyUrl(), | |
| 150 | - // optional fields | |
| 151 | - 'Ds_Merchant_ProductDescription' => $this->getDescription(), | |
| 152 | - 'Ds_Merchant_Cardholder' => $this->getCardholder(), | |
| 153 | - 'Ds_Merchant_UrlOK' => $this->getReturnUrl(), | |
| 154 | - 'Ds_Merchant_UrlKO' => $this->getReturnUrl(), | |
| 155 | - 'Ds_Merchant_MerchantName' => $this->getMerchantName(), | |
| 156 | - 'Ds_Merchant_ConsumerLanguage' => $this->getConsumerLanguage(), | |
| 157 | - 'Ds_Merchant_MerchantData' => $this->getMerchantData(), | |
| 158 | - ); | |
| 159 | - } | |
| 160 | - | |
| 161 | - public function sendData($data) | |
| 162 | -    { | |
| 163 | - $security = new Security; | |
| 164 | - | |
| 165 | - $encoded_data = $security->encodeMerchantParameters($data); | |
| 166 | - | |
| 167 | - $response_data = array( | |
| 168 | - 'Ds_SignatureVersion' => Security::VERSION, | |
| 169 | - 'Ds_MerchantParameters' => $encoded_data, | |
| 170 | - 'Ds_Signature' => $security->createSignature( | |
| 171 | - $encoded_data, | |
| 172 | - $data['Ds_Merchant_Order'], | |
| 173 | - base64_decode($this->getHmacKey()) | |
| 174 | - ), | |
| 175 | - ); | |
| 176 | - | |
| 177 | - return $this->response = new PurchaseResponse($this, $response_data); | |
| 178 | - } | |
| 179 | - | |
| 180 | - public function getEndpoint() | |
| 181 | -    { | |
| 182 | - return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; | |
| 183 | - } | |
| 12 | + /** @var string */ | |
| 13 | + protected $liveEndpoint = 'https://sis.redsys.es/sis/realizarPago'; | |
| 14 | + /** @var string */ | |
| 15 | + protected $testEndpoint = 'https://sis-t.redsys.es:25443/sis/realizarPago'; | |
| 16 | + /** @var array */ | |
| 17 | + protected static $consumerLanguages = array( | |
| 18 | + 'es' => '001', // Spanish | |
| 19 | + 'en' => '002', // English | |
| 20 | + 'ca' => '003', // Catalan - same as Valencian (010) | |
| 21 | + 'fr' => '004', // French | |
| 22 | + 'de' => '005', // German | |
| 23 | + 'nl' => '006', // Dutch | |
| 24 | + 'it' => '007', // Italian | |
| 25 | + 'sv' => '008', // Swedish | |
| 26 | + 'pt' => '009', // Portuguese | |
| 27 | + 'pl' => '011', // Polish | |
| 28 | + 'gl' => '012', // Galician | |
| 29 | + 'eu' => '013', // Basque | |
| 30 | + ); | |
| 31 | + | |
| 32 | + public function getCardholder() | |
| 33 | +	{ | |
| 34 | +		return $this->getParameter('cardholder'); | |
| 35 | + } | |
| 36 | + | |
| 37 | + public function setCardholder($value) | |
| 38 | +	{ | |
| 39 | +		return $this->setParameter('cardholder', $value); | |
| 40 | + } | |
| 41 | + | |
| 42 | + public function getConsumerLanguage() | |
| 43 | +	{ | |
| 44 | +		return $this->getParameter('consumerLanguage'); | |
| 45 | + } | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * Set the language presented to the consumer | |
| 49 | + * | |
| 50 | + * @param string|int Either the ISO 639-1 code to be converted, or the gateway's own numeric language code | |
| 51 | + */ | |
| 52 | + public function setConsumerLanguage($value) | |
| 53 | +	{ | |
| 54 | +		if (is_int($value)) { | |
| 55 | +			if ($value < 0 || $value > 13) { | |
| 56 | + $value = 1; | |
| 57 | + } | |
| 58 | + $value = str_pad($value, 3, '0', STR_PAD_LEFT); | |
| 59 | +		} elseif (!is_numeric($value)) { | |
| 60 | + $value = isset(self::$consumerLanguages[$value]) ? self::$consumerLanguages[$value] : '001'; | |
| 61 | + } | |
| 62 | + | |
| 63 | +		return $this->setParameter('consumerLanguage', $value); | |
| 64 | + } | |
| 65 | + | |
| 66 | + public function getHmacKey() | |
| 67 | +	{ | |
| 68 | +		return $this->getParameter('hmacKey'); | |
| 69 | + } | |
| 70 | + | |
| 71 | + public function setHmacKey($value) | |
| 72 | +	{ | |
| 73 | +		return $this->setParameter('hmacKey', $value); | |
| 74 | + } | |
| 75 | + | |
| 76 | + public function getMerchantData() | |
| 77 | +	{ | |
| 78 | +		return $this->getParameter('merchantData'); | |
| 79 | + } | |
| 80 | + | |
| 81 | + public function setMerchantData($value) | |
| 82 | +	{ | |
| 83 | +		return $this->setParameter('merchantData', $value); | |
| 84 | + } | |
| 85 | + | |
| 86 | + public function getMerchantId() | |
| 87 | +	{ | |
| 88 | +		return $this->getParameter('merchantId'); | |
| 89 | + } | |
| 90 | + | |
| 91 | + public function setMerchantId($value) | |
| 92 | +	{ | |
| 93 | +		return $this->setParameter('merchantId', $value); | |
| 94 | + } | |
| 95 | + | |
| 96 | + public function getMerchantName() | |
| 97 | +	{ | |
| 98 | +		return $this->getParameter('merchantName'); | |
| 99 | + } | |
| 100 | + | |
| 101 | + public function setMerchantName($value) | |
| 102 | +	{ | |
| 103 | +		return $this->setParameter('merchantName', $value); | |
| 104 | + } | |
| 105 | + | |
| 106 | + public function getTerminalId() | |
| 107 | +	{ | |
| 108 | +		return $this->getParameter('terminalId'); | |
| 109 | + } | |
| 110 | + | |
| 111 | + public function setTerminalId($value) | |
| 112 | +	{ | |
| 113 | +		return $this->setParameter('terminalId', $value); | |
| 114 | + } | |
| 115 | + | |
| 116 | + /** | |
| 117 | + * Override the abstract method to add requirement that it must start with 4 numeric characters | |
| 118 | + * | |
| 119 | + * @param string|int $value The transaction ID (merchant order) to set for the transaction | |
| 120 | + */ | |
| 121 | + public function setTransactionId($value) | |
| 122 | +	{ | |
| 123 | + $start = substr($value, 0, 4); | |
| 124 | + $numerics = 0; | |
| 125 | +		foreach (str_split($start) as $char) { | |
| 126 | +			if (is_numeric($char)) { | |
| 127 | + $numerics++; | |
| 128 | +			} else { | |
| 129 | + break; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + $value = str_pad(substr($start, 0, $numerics), 4, 0, STR_PAD_LEFT).substr($value, $numerics); | |
| 133 | + | |
| 134 | + parent::setTransactionId($value); | |
| 135 | + } | |
| 136 | + | |
| 137 | + public function getData() | |
| 138 | +	{ | |
| 139 | +		$this->validate('merchantId', 'terminalId', 'amount', 'currency'); | |
| 140 | + | |
| 141 | + return array( | |
| 142 | + // mandatory fields | |
| 143 | + 'Ds_Merchant_MerchantCode' => $this->getMerchantId(), | |
| 144 | + 'Ds_Merchant_Terminal' => $this->getTerminalId(), | |
| 145 | + 'Ds_Merchant_TransactionType' => '0', // Authorisation | |
| 146 | + 'Ds_Merchant_Amount' => $this->getAmountInteger(), | |
| 147 | + 'Ds_Merchant_Currency' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 148 | + 'Ds_Merchant_Order' => $this->getTransactionId(), | |
| 149 | + 'Ds_Merchant_MerchantUrl' => $this->getNotifyUrl(), | |
| 150 | + // optional fields | |
| 151 | + 'Ds_Merchant_ProductDescription' => $this->getDescription(), | |
| 152 | + 'Ds_Merchant_Cardholder' => $this->getCardholder(), | |
| 153 | + 'Ds_Merchant_UrlOK' => $this->getReturnUrl(), | |
| 154 | + 'Ds_Merchant_UrlKO' => $this->getReturnUrl(), | |
| 155 | + 'Ds_Merchant_MerchantName' => $this->getMerchantName(), | |
| 156 | + 'Ds_Merchant_ConsumerLanguage' => $this->getConsumerLanguage(), | |
| 157 | + 'Ds_Merchant_MerchantData' => $this->getMerchantData(), | |
| 158 | + ); | |
| 159 | + } | |
| 160 | + | |
| 161 | + public function sendData($data) | |
| 162 | +	{ | |
| 163 | + $security = new Security; | |
| 164 | + | |
| 165 | + $encoded_data = $security->encodeMerchantParameters($data); | |
| 166 | + | |
| 167 | + $response_data = array( | |
| 168 | + 'Ds_SignatureVersion' => Security::VERSION, | |
| 169 | + 'Ds_MerchantParameters' => $encoded_data, | |
| 170 | + 'Ds_Signature' => $security->createSignature( | |
| 171 | + $encoded_data, | |
| 172 | + $data['Ds_Merchant_Order'], | |
| 173 | + base64_decode($this->getHmacKey()) | |
| 174 | + ), | |
| 175 | + ); | |
| 176 | + | |
| 177 | + return $this->response = new PurchaseResponse($this, $response_data); | |
| 178 | + } | |
| 179 | + | |
| 180 | + public function getEndpoint() | |
| 181 | +	{ | |
| 182 | + return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint; | |
| 183 | + } | |
| 184 | 184 | } | 
| @@ -9,65 +9,65 @@ discard block | ||
| 9 | 9 | */ | 
| 10 | 10 | class WebservicePurchaseRequest extends PurchaseRequest | 
| 11 | 11 |  { | 
| 12 | - /** @var string */ | |
| 13 | - protected $liveWsdl = __DIR__ . "/redsys-webservice-live.wsdl"; | |
| 14 | - /** @var string */ | |
| 15 | - protected $testWsdl = __DIR__ . "/redsys-webservice-test.wsdl"; | |
| 16 | - /** @var string */ | |
| 17 | - protected $liveEndpoint = "https://sis.redsys.es/sis/services/SerClsWSEntrada"; | |
| 18 | - /** @var string */ | |
| 19 | - protected $testEndpoint = "https://sis-t.redsys.es:25443/sis/services/SerClsWSEntrada"; | |
| 12 | + /** @var string */ | |
| 13 | + protected $liveWsdl = __DIR__ . "/redsys-webservice-live.wsdl"; | |
| 14 | + /** @var string */ | |
| 15 | + protected $testWsdl = __DIR__ . "/redsys-webservice-test.wsdl"; | |
| 16 | + /** @var string */ | |
| 17 | + protected $liveEndpoint = "https://sis.redsys.es/sis/services/SerClsWSEntrada"; | |
| 18 | + /** @var string */ | |
| 19 | + protected $testEndpoint = "https://sis-t.redsys.es:25443/sis/services/SerClsWSEntrada"; | |
| 20 | 20 | |
| 21 | - public function getData() | |
| 22 | -    { | |
| 23 | -        $this->validate('merchantId', 'terminalId', 'amount', 'currency', 'card'); | |
| 24 | - $card = $this->getCard(); | |
| 25 | - // @todo given test card doesn't validate? | |
| 26 | -        if (!$this->getTestMode()) { | |
| 27 | - $card->validate(); | |
| 28 | - } | |
| 29 | - | |
| 30 | - $data = array( | |
| 31 | - 'DS_MERCHANT_AMOUNT' => $this->getAmountInteger(), | |
| 32 | - 'DS_MERCHANT_ORDER' => $this->getTransactionId(), | |
| 33 | - 'DS_MERCHANT_MERCHANTCODE' => $this->getMerchantId(), | |
| 34 | - 'DS_MERCHANT_CURRENCY' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 35 | - 'DS_MERCHANT_PAN' => $card->getNumber(), | |
| 36 | - 'DS_MERCHANT_CVV2' => $card->getCvv(), | |
| 37 | - 'DS_MERCHANT_TRANSACTIONTYPE' => 'A', // 'Traditional payment' | |
| 38 | - 'DS_MERCHANT_TERMINAL' => $this->getTerminalId(), | |
| 39 | -            'DS_MERCHANT_EXPIRYDATE'      => $card->getExpiryDate('ym'), | |
| 40 | - ); | |
| 41 | - | |
| 42 | - | |
| 43 | -        $request = new SimpleXMLElement('<REQUEST/>'); | |
| 44 | -        $requestData = $request->addChild('DATOSENTRADA'); | |
| 45 | -        foreach ($data as $tag => $value) { | |
| 46 | - $requestData->addChild($tag, $value); | |
| 47 | - } | |
| 48 | - | |
| 49 | - $security = new Security; | |
| 50 | - | |
| 51 | -        $request->addChild('DS_SIGNATUREVERSION', Security::VERSION); | |
| 52 | -        $request->addChild('DS_SIGNATURE', $security->createSignature( | |
| 53 | - $requestData->asXML(), | |
| 54 | - $data['DS_MERCHANT_ORDER'], | |
| 55 | - base64_decode($this->getHmacKey()) | |
| 56 | - )); | |
| 57 | - | |
| 58 | - return $request; | |
| 59 | - // array( | |
| 60 | - // 'DATOSENTRADA' => $data, | |
| 61 | - // 'DS_SIGNATUREVERSION' => $request->DS_SIGNATUREVERSION, | |
| 62 | - // 'DS_SIGNATURE' => $request->DS_SIGNATURE, | |
| 63 | - // ); | |
| 64 | - } | |
| 65 | - | |
| 66 | - public function sendData($data) | |
| 67 | -    { | |
| 68 | - | |
| 69 | - // @todo either use SOAP client here, or wrap in soap yourself and just guzzle it | |
| 70 | - /* | |
| 21 | + public function getData() | |
| 22 | +	{ | |
| 23 | +		$this->validate('merchantId', 'terminalId', 'amount', 'currency', 'card'); | |
| 24 | + $card = $this->getCard(); | |
| 25 | + // @todo given test card doesn't validate? | |
| 26 | +		if (!$this->getTestMode()) { | |
| 27 | + $card->validate(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + $data = array( | |
| 31 | + 'DS_MERCHANT_AMOUNT' => $this->getAmountInteger(), | |
| 32 | + 'DS_MERCHANT_ORDER' => $this->getTransactionId(), | |
| 33 | + 'DS_MERCHANT_MERCHANTCODE' => $this->getMerchantId(), | |
| 34 | + 'DS_MERCHANT_CURRENCY' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 35 | + 'DS_MERCHANT_PAN' => $card->getNumber(), | |
| 36 | + 'DS_MERCHANT_CVV2' => $card->getCvv(), | |
| 37 | + 'DS_MERCHANT_TRANSACTIONTYPE' => 'A', // 'Traditional payment' | |
| 38 | + 'DS_MERCHANT_TERMINAL' => $this->getTerminalId(), | |
| 39 | +			'DS_MERCHANT_EXPIRYDATE'      => $card->getExpiryDate('ym'), | |
| 40 | + ); | |
| 41 | + | |
| 42 | + | |
| 43 | +		$request = new SimpleXMLElement('<REQUEST/>'); | |
| 44 | +		$requestData = $request->addChild('DATOSENTRADA'); | |
| 45 | +		foreach ($data as $tag => $value) { | |
| 46 | + $requestData->addChild($tag, $value); | |
| 47 | + } | |
| 48 | + | |
| 49 | + $security = new Security; | |
| 50 | + | |
| 51 | +		$request->addChild('DS_SIGNATUREVERSION', Security::VERSION); | |
| 52 | +		$request->addChild('DS_SIGNATURE', $security->createSignature( | |
| 53 | + $requestData->asXML(), | |
| 54 | + $data['DS_MERCHANT_ORDER'], | |
| 55 | + base64_decode($this->getHmacKey()) | |
| 56 | + )); | |
| 57 | + | |
| 58 | + return $request; | |
| 59 | + // array( | |
| 60 | + // 'DATOSENTRADA' => $data, | |
| 61 | + // 'DS_SIGNATUREVERSION' => $request->DS_SIGNATUREVERSION, | |
| 62 | + // 'DS_SIGNATURE' => $request->DS_SIGNATURE, | |
| 63 | + // ); | |
| 64 | + } | |
| 65 | + | |
| 66 | + public function sendData($data) | |
| 67 | +	{ | |
| 68 | + | |
| 69 | + // @todo either use SOAP client here, or wrap in soap yourself and just guzzle it | |
| 70 | + /* | |
| 71 | 71 | use SoapClient; | 
| 72 | 72 |              $s = new SoapClient($fs, array('trace' => $this->debug, 'exceptions' => true)); | 
| 73 | 73 | $result = $s->trataPeticion( | 
| @@ -76,8 +76,8 @@ discard block | ||
| 76 | 76 | |
| 77 | 77 | */ | 
| 78 | 78 | |
| 79 | - // DIY SOAP WRAPPER | |
| 80 | - $envelope = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> | |
| 79 | + // DIY SOAP WRAPPER | |
| 80 | + $envelope = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> | |
| 81 | 81 | <soapenv:Header/> | 
| 82 | 82 | <soapenv:Body> | 
| 83 | 83 | <impl:trataPeticion xmlns:impl='http://webservice.sis.sermepa.es'> | 
| @@ -88,27 +88,27 @@ discard block | ||
| 88 | 88 | </soapenv:Body> | 
| 89 | 89 | </soapenv:Envelope>"; | 
| 90 | 90 | |
| 91 | - $httpResponse = $this->httpClient->post( | |
| 92 | - $this->getEndpoint(), | |
| 93 | -            array('SOAPAction' => 'trataPeticion'), | |
| 94 | - $envelope | |
| 95 | - )->send(); | |
| 96 | - | |
| 97 | - // unwrap httpResponse into actual data as SimpleXMLElement tree | |
| 98 | - $envelope = $httpResponse->xml(); | |
| 99 | - $response_data = new SimpleXMLElement(htmlspecialchars_decode( | |
| 100 | -            $envelope->children("http://schemas.xmlsoap.org/soap/envelope/") | |
| 101 | -            ->Body->children("http://webservice.sis.sermepa.es") | |
| 102 | - ->trataPeticionResponse | |
| 103 | - ->trataPeticionReturn | |
| 104 | - )); | |
| 105 | - | |
| 106 | - // remove any reflected request data (this happens on error, including card number) | |
| 107 | -        // if (isset($response_data->RECIBIDO)) { | |
| 108 | - // unset($response_data->RECIBIDO); | |
| 109 | - // } | |
| 110 | - | |
| 111 | - | |
| 112 | - return $this->response = new WebservicePurchaseResponse($this, $response_data); | |
| 113 | - } | |
| 91 | + $httpResponse = $this->httpClient->post( | |
| 92 | + $this->getEndpoint(), | |
| 93 | +			array('SOAPAction' => 'trataPeticion'), | |
| 94 | + $envelope | |
| 95 | + )->send(); | |
| 96 | + | |
| 97 | + // unwrap httpResponse into actual data as SimpleXMLElement tree | |
| 98 | + $envelope = $httpResponse->xml(); | |
| 99 | + $response_data = new SimpleXMLElement(htmlspecialchars_decode( | |
| 100 | +			$envelope->children("http://schemas.xmlsoap.org/soap/envelope/") | |
| 101 | +			->Body->children("http://webservice.sis.sermepa.es") | |
| 102 | + ->trataPeticionResponse | |
| 103 | + ->trataPeticionReturn | |
| 104 | + )); | |
| 105 | + | |
| 106 | + // remove any reflected request data (this happens on error, including card number) | |
| 107 | +		// if (isset($response_data->RECIBIDO)) { | |
| 108 | + // unset($response_data->RECIBIDO); | |
| 109 | + // } | |
| 110 | + | |
| 111 | + | |
| 112 | + return $this->response = new WebservicePurchaseResponse($this, $response_data); | |
| 113 | + } | |
| 114 | 114 | } | 
| @@ -10,9 +10,9 @@ discard block | ||
| 10 | 10 | class WebservicePurchaseRequest extends PurchaseRequest | 
| 11 | 11 |  { | 
| 12 | 12 | /** @var string */ | 
| 13 | - protected $liveWsdl = __DIR__ . "/redsys-webservice-live.wsdl"; | |
| 13 | + protected $liveWsdl = __DIR__."/redsys-webservice-live.wsdl"; | |
| 14 | 14 | /** @var string */ | 
| 15 | - protected $testWsdl = __DIR__ . "/redsys-webservice-test.wsdl"; | |
| 15 | + protected $testWsdl = __DIR__."/redsys-webservice-test.wsdl"; | |
| 16 | 16 | /** @var string */ | 
| 17 | 17 | protected $liveEndpoint = "https://sis.redsys.es/sis/services/SerClsWSEntrada"; | 
| 18 | 18 | /** @var string */ | 
| @@ -31,10 +31,10 @@ discard block | ||
| 31 | 31 | 'DS_MERCHANT_AMOUNT' => $this->getAmountInteger(), | 
| 32 | 32 | 'DS_MERCHANT_ORDER' => $this->getTransactionId(), | 
| 33 | 33 | 'DS_MERCHANT_MERCHANTCODE' => $this->getMerchantId(), | 
| 34 | - 'DS_MERCHANT_CURRENCY' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 34 | + 'DS_MERCHANT_CURRENCY' => $this->getCurrencyNumeric(), // uses ISO-4217 codes | |
| 35 | 35 | 'DS_MERCHANT_PAN' => $card->getNumber(), | 
| 36 | 36 | 'DS_MERCHANT_CVV2' => $card->getCvv(), | 
| 37 | - 'DS_MERCHANT_TRANSACTIONTYPE' => 'A', // 'Traditional payment' | |
| 37 | + 'DS_MERCHANT_TRANSACTIONTYPE' => 'A', // 'Traditional payment' | |
| 38 | 38 | 'DS_MERCHANT_TERMINAL' => $this->getTerminalId(), | 
| 39 | 39 |              'DS_MERCHANT_EXPIRYDATE'      => $card->getExpiryDate('ym'), | 
| 40 | 40 | ); | 
| @@ -7,8 +7,7 @@ discard block | ||
| 7 | 7 | /** | 
| 8 | 8 | * Redsys Webservice Purchase Request | 
| 9 | 9 | */ | 
| 10 | -class WebservicePurchaseRequest extends PurchaseRequest | |
| 11 | -{ | |
| 10 | +class WebservicePurchaseRequest extends PurchaseRequest { | |
| 12 | 11 | /** @var string */ | 
| 13 | 12 | protected $liveWsdl = __DIR__ . "/redsys-webservice-live.wsdl"; | 
| 14 | 13 | /** @var string */ | 
| @@ -18,8 +17,7 @@ discard block | ||
| 18 | 17 | /** @var string */ | 
| 19 | 18 | protected $testEndpoint = "https://sis-t.redsys.es:25443/sis/services/SerClsWSEntrada"; | 
| 20 | 19 | |
| 21 | - public function getData() | |
| 22 | -    { | |
| 20 | +    public function getData() { | |
| 23 | 21 |          $this->validate('merchantId', 'terminalId', 'amount', 'currency', 'card'); | 
| 24 | 22 | $card = $this->getCard(); | 
| 25 | 23 | // @todo given test card doesn't validate? | 
| @@ -63,8 +61,7 @@ discard block | ||
| 63 | 61 | // ); | 
| 64 | 62 | } | 
| 65 | 63 | |
| 66 | - public function sendData($data) | |
| 67 | -    { | |
| 64 | +    public function sendData($data) { | |
| 68 | 65 | |
| 69 | 66 | // @todo either use SOAP client here, or wrap in soap yourself and just guzzle it | 
| 70 | 67 | /* | 
| @@ -10,47 +10,47 @@ | ||
| 10 | 10 | */ | 
| 11 | 11 | class WebservicePurchaseResponse extends AbstractResponse | 
| 12 | 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 | - // } | |
| 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 | 56 | } | 
| @@ -8,10 +8,8 @@ discard block | ||
| 8 | 8 | /** | 
| 9 | 9 | * Redsys Purchase Response | 
| 10 | 10 | */ | 
| 11 | -class WebservicePurchaseResponse extends AbstractResponse | |
| 12 | -{ | |
| 13 | - public function isSuccessful() | |
| 14 | -    { | |
| 11 | +class WebservicePurchaseResponse extends AbstractResponse { | |
| 12 | +    public function isSuccessful() { | |
| 15 | 13 | // check for field existence as well as value | 
| 16 | 14 | return !empty($this->data->CODIGO) | 
| 17 | 15 | && $this->data->CODIGO == '0' | 
| @@ -21,14 +19,12 @@ discard block | ||
| 21 | 19 | } | 
| 22 | 20 | |
| 23 | 21 | // @todo Other methods required for abstract response | 
| 24 | - public function getTransactionReference() | |
| 25 | -    { | |
| 22 | +    public function getTransactionReference() { | |
| 26 | 23 | return "WOOT"; | 
| 27 | 24 | } | 
| 28 | 25 | |
| 29 | 26 | // @todo Switch to just returning the error code (no message supplied in package) | 
| 30 | - public function getMessage() | |
| 31 | -    { | |
| 27 | +    public function getMessage() { | |
| 32 | 28 |          if ($this->data instanceof SimpleXMLElement) { | 
| 33 | 29 | $out = $this->data->asXML(); | 
| 34 | 30 |          } else { | 
| @@ -15,87 +15,87 @@ | ||
| 15 | 15 | */ | 
| 16 | 16 | class Security | 
| 17 | 17 |  { | 
| 18 | - /** @var string */ | |
| 19 | - const VERSION = 'HMAC_SHA256_V1'; | |
| 18 | + /** @var string */ | |
| 19 | + const VERSION = 'HMAC_SHA256_V1'; | |
| 20 | 20 | |
| 21 | - /** | |
| 22 | - * Encode merchant parameters | |
| 23 | - * | |
| 24 | - * @param array $data The parameters to encode | |
| 25 | - * | |
| 26 | - * @return string Encoded data | |
| 27 | - */ | |
| 28 | - public function encodeMerchantParameters($data) | |
| 29 | -    { | |
| 30 | - return base64_encode(json_encode($data)); | |
| 31 | - } | |
| 21 | + /** | |
| 22 | + * Encode merchant parameters | |
| 23 | + * | |
| 24 | + * @param array $data The parameters to encode | |
| 25 | + * | |
| 26 | + * @return string Encoded data | |
| 27 | + */ | |
| 28 | + public function encodeMerchantParameters($data) | |
| 29 | +	{ | |
| 30 | + return base64_encode(json_encode($data)); | |
| 31 | + } | |
| 32 | 32 | |
| 33 | - /** | |
| 34 | - * Decode merchant parameters | |
| 35 | - * | |
| 36 | - * @param string $data The encoded string of parameters | |
| 37 | - * | |
| 38 | - * @return array Decoded data | |
| 39 | - */ | |
| 40 | - public function decodeMerchantParameters($data) | |
| 41 | -    { | |
| 42 | - return (array)json_decode(base64_decode(strtr($data, '-_', '+/'))); | |
| 43 | - } | |
| 33 | + /** | |
| 34 | + * Decode merchant parameters | |
| 35 | + * | |
| 36 | + * @param string $data The encoded string of parameters | |
| 37 | + * | |
| 38 | + * @return array Decoded data | |
| 39 | + */ | |
| 40 | + public function decodeMerchantParameters($data) | |
| 41 | +	{ | |
| 42 | + return (array)json_decode(base64_decode(strtr($data, '-_', '+/'))); | |
| 43 | + } | |
| 44 | 44 | |
| 45 | - /** | |
| 46 | - * Encrypt message with given key and default IV | |
| 47 | - * | |
| 48 | - * @param string $message The message to encrypt | |
| 49 | - * @param string $key The key used to encrypt the message | |
| 50 | - * | |
| 51 | - * @return string Encrypted message | |
| 52 | - * | |
| 53 | - * @throws RuntimeException | |
| 54 | - */ | |
| 55 | - protected function encryptMessage($message, $key) | |
| 56 | -    { | |
| 57 | -        $iv = implode(array_map('chr', array(0, 0, 0, 0, 0, 0, 0, 0))); | |
| 45 | + /** | |
| 46 | + * Encrypt message with given key and default IV | |
| 47 | + * | |
| 48 | + * @param string $message The message to encrypt | |
| 49 | + * @param string $key The key used to encrypt the message | |
| 50 | + * | |
| 51 | + * @return string Encrypted message | |
| 52 | + * | |
| 53 | + * @throws RuntimeException | |
| 54 | + */ | |
| 55 | + protected function encryptMessage($message, $key) | |
| 56 | +	{ | |
| 57 | +		$iv = implode(array_map('chr', array(0, 0, 0, 0, 0, 0, 0, 0))); | |
| 58 | 58 | |
| 59 | -        if ($this->hasValidEncryptionMethod()) { | |
| 60 | - $ciphertext = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); | |
| 61 | -        } else { | |
| 62 | -            throw new RuntimeException('No valid encryption extension installed'); | |
| 63 | - } | |
| 59 | +		if ($this->hasValidEncryptionMethod()) { | |
| 60 | + $ciphertext = mcrypt_encrypt(MCRYPT_3DES, $key, $message, MCRYPT_MODE_CBC, $iv); | |
| 61 | +		} else { | |
| 62 | +			throw new RuntimeException('No valid encryption extension installed'); | |
| 63 | + } | |
| 64 | 64 | |
| 65 | - return $ciphertext; | |
| 66 | - } | |
| 65 | + return $ciphertext; | |
| 66 | + } | |
| 67 | 67 | |
| 68 | - /** | |
| 69 | - * Check if the system has a valid encryption method available | |
| 70 | - * | |
| 71 | - * @todo add or switch to extension_loaded()? | |
| 72 | - * | |
| 73 | - * @return bool | |
| 74 | - */ | |
| 75 | - public function hasValidEncryptionMethod() | |
| 76 | -    { | |
| 77 | -        return function_exists('mcrypt_encrypt'); | |
| 78 | - } | |
| 68 | + /** | |
| 69 | + * Check if the system has a valid encryption method available | |
| 70 | + * | |
| 71 | + * @todo add or switch to extension_loaded()? | |
| 72 | + * | |
| 73 | + * @return bool | |
| 74 | + */ | |
| 75 | + public function hasValidEncryptionMethod() | |
| 76 | +	{ | |
| 77 | +		return function_exists('mcrypt_encrypt'); | |
| 78 | + } | |
| 79 | 79 | |
| 80 | - /** | |
| 81 | - * Create signature hash used to verify messages | |
| 82 | - * | |
| 83 | - * @todo Add if-check on algorithm to match against signature version as new param? | |
| 84 | - * | |
| 85 | - * @param string $message The message to encrypt | |
| 86 | - * @param string $salt Unique salt used to generate the ciphertext | |
| 87 | - * @param string $key The key used to encrypt the message | |
| 88 | - * | |
| 89 | - * @return string Generated signature | |
| 90 | - */ | |
| 91 | - public function createSignature($message, $salt, $key) | |
| 92 | -    { | |
| 93 | - $ciphertext = $this->encryptMessage($salt, $key); | |
| 94 | -        return base64_encode(hash_hmac('sha256', $message, $ciphertext, true)); | |
| 95 | - } | |
| 80 | + /** | |
| 81 | + * Create signature hash used to verify messages | |
| 82 | + * | |
| 83 | + * @todo Add if-check on algorithm to match against signature version as new param? | |
| 84 | + * | |
| 85 | + * @param string $message The message to encrypt | |
| 86 | + * @param string $salt Unique salt used to generate the ciphertext | |
| 87 | + * @param string $key The key used to encrypt the message | |
| 88 | + * | |
| 89 | + * @return string Generated signature | |
| 90 | + */ | |
| 91 | + public function createSignature($message, $salt, $key) | |
| 92 | +	{ | |
| 93 | + $ciphertext = $this->encryptMessage($salt, $key); | |
| 94 | +		return base64_encode(hash_hmac('sha256', $message, $ciphertext, true)); | |
| 95 | + } | |
| 96 | 96 | |
| 97 | - public function createReturnSignature($message, $salt, $key) | |
| 98 | -    { | |
| 99 | - return strtr($this->createSignature($message, $salt, $key), '+/', '-_'); | |
| 100 | - } | |
| 97 | + public function createReturnSignature($message, $salt, $key) | |
| 98 | +	{ | |
| 99 | + return strtr($this->createSignature($message, $salt, $key), '+/', '-_'); | |
| 100 | + } | |
| 101 | 101 | } | 
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | */ | 
| 35 | 35 | protected function decodeMerchantParameters($data) | 
| 36 | 36 |      { | 
| 37 | - return (array)json_decode(base64_decode(strtr($data, '-_', '+/'))); | |
| 37 | + return (array) json_decode(base64_decode(strtr($data, '-_', '+/'))); | |
| 38 | 38 | } | 
| 39 | 39 | |
| 40 | 40 | /** | 
| @@ -13,8 +13,7 @@ discard block | ||
| 13 | 13 | * encryption methods are provided later, the VERSION const can be | 
| 14 | 14 | * switched to a constructor option (and validated against a whitelist). | 
| 15 | 15 | */ | 
| 16 | -class Security | |
| 17 | -{ | |
| 16 | +class Security { | |
| 18 | 17 | /** @var string */ | 
| 19 | 18 | const VERSION = 'HMAC_SHA256_V1'; | 
| 20 | 19 | |
| @@ -25,8 +24,7 @@ discard block | ||
| 25 | 24 | * | 
| 26 | 25 | * @return string Encoded data | 
| 27 | 26 | */ | 
| 28 | - public function encodeMerchantParameters($data) | |
| 29 | -    { | |
| 27 | +    public function encodeMerchantParameters($data) { | |
| 30 | 28 | return base64_encode(json_encode($data)); | 
| 31 | 29 | } | 
| 32 | 30 | |
| @@ -37,8 +35,7 @@ discard block | ||
| 37 | 35 | * | 
| 38 | 36 | * @return array Decoded data | 
| 39 | 37 | */ | 
| 40 | - public function decodeMerchantParameters($data) | |
| 41 | -    { | |
| 38 | +    public function decodeMerchantParameters($data) { | |
| 42 | 39 | return (array)json_decode(base64_decode(strtr($data, '-_', '+/'))); | 
| 43 | 40 | } | 
| 44 | 41 | |
| @@ -52,8 +49,7 @@ discard block | ||
| 52 | 49 | * | 
| 53 | 50 | * @throws RuntimeException | 
| 54 | 51 | */ | 
| 55 | - protected function encryptMessage($message, $key) | |
| 56 | -    { | |
| 52 | +    protected function encryptMessage($message, $key) { | |
| 57 | 53 |          $iv = implode(array_map('chr', array(0, 0, 0, 0, 0, 0, 0, 0))); | 
| 58 | 54 | |
| 59 | 55 |          if ($this->hasValidEncryptionMethod()) { | 
| @@ -72,8 +68,7 @@ discard block | ||
| 72 | 68 | * | 
| 73 | 69 | * @return bool | 
| 74 | 70 | */ | 
| 75 | - public function hasValidEncryptionMethod() | |
| 76 | -    { | |
| 71 | +    public function hasValidEncryptionMethod() { | |
| 77 | 72 |          return function_exists('mcrypt_encrypt'); | 
| 78 | 73 | } | 
| 79 | 74 | |
| @@ -88,14 +83,12 @@ discard block | ||
| 88 | 83 | * | 
| 89 | 84 | * @return string Generated signature | 
| 90 | 85 | */ | 
| 91 | - public function createSignature($message, $salt, $key) | |
| 92 | -    { | |
| 86 | +    public function createSignature($message, $salt, $key) { | |
| 93 | 87 | $ciphertext = $this->encryptMessage($salt, $key); | 
| 94 | 88 |          return base64_encode(hash_hmac('sha256', $message, $ciphertext, true)); | 
| 95 | 89 | } | 
| 96 | 90 | |
| 97 | - public function createReturnSignature($message, $salt, $key) | |
| 98 | -    { | |
| 91 | +    public function createReturnSignature($message, $salt, $key) { | |
| 99 | 92 | return strtr($this->createSignature($message, $salt, $key), '+/', '-_'); | 
| 100 | 93 | } | 
| 101 | 94 | } | 
| @@ -9,28 +9,28 @@ | ||
| 9 | 9 | */ | 
| 10 | 10 | class PurchaseResponse extends AbstractResponse | 
| 11 | 11 |  { | 
| 12 | - public function isSuccessful() | |
| 13 | -    { | |
| 14 | - return false; | |
| 15 | - } | |
| 12 | + public function isSuccessful() | |
| 13 | +	{ | |
| 14 | + return false; | |
| 15 | + } | |
| 16 | 16 | |
| 17 | - public function isRedirect() | |
| 18 | -    { | |
| 19 | - return true; | |
| 20 | - } | |
| 17 | + public function isRedirect() | |
| 18 | +	{ | |
| 19 | + return true; | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - public function getRedirectUrl() | |
| 23 | -    { | |
| 24 | - return $this->getRequest()->getEndpoint(); | |
| 25 | - } | |
| 22 | + public function getRedirectUrl() | |
| 23 | +	{ | |
| 24 | + return $this->getRequest()->getEndpoint(); | |
| 25 | + } | |
| 26 | 26 | |
| 27 | - public function getRedirectMethod() | |
| 28 | -    { | |
| 29 | - return 'POST'; | |
| 30 | - } | |
| 27 | + public function getRedirectMethod() | |
| 28 | +	{ | |
| 29 | + return 'POST'; | |
| 30 | + } | |
| 31 | 31 | |
| 32 | - public function getRedirectData() | |
| 33 | -    { | |
| 34 | - return $this->data; | |
| 35 | - } | |
| 32 | + public function getRedirectData() | |
| 33 | +	{ | |
| 34 | + return $this->data; | |
| 35 | + } | |
| 36 | 36 | } | 
| @@ -7,30 +7,24 @@ | ||
| 7 | 7 | /** | 
| 8 | 8 | * Redsys Purchase Response | 
| 9 | 9 | */ | 
| 10 | -class PurchaseResponse extends AbstractResponse | |
| 11 | -{ | |
| 12 | - public function isSuccessful() | |
| 13 | -    { | |
| 10 | +class PurchaseResponse extends AbstractResponse { | |
| 11 | +    public function isSuccessful() { | |
| 14 | 12 | return false; | 
| 15 | 13 | } | 
| 16 | 14 | |
| 17 | - public function isRedirect() | |
| 18 | -    { | |
| 15 | +    public function isRedirect() { | |
| 19 | 16 | return true; | 
| 20 | 17 | } | 
| 21 | 18 | |
| 22 | - public function getRedirectUrl() | |
| 23 | -    { | |
| 19 | +    public function getRedirectUrl() { | |
| 24 | 20 | return $this->getRequest()->getEndpoint(); | 
| 25 | 21 | } | 
| 26 | 22 | |
| 27 | - public function getRedirectMethod() | |
| 28 | -    { | |
| 23 | +    public function getRedirectMethod() { | |
| 29 | 24 | return 'POST'; | 
| 30 | 25 | } | 
| 31 | 26 | |
| 32 | - public function getRedirectData() | |
| 33 | -    { | |
| 27 | +    public function getRedirectData() { | |
| 34 | 28 | return $this->data; | 
| 35 | 29 | } | 
| 36 | 30 | } | 
| @@ -13,69 +13,69 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | class RedirectGateway extends AbstractGateway | 
| 15 | 15 |  { | 
| 16 | - public function getName() | |
| 17 | -    { | |
| 18 | - return 'Redsys Redirect'; | |
| 19 | - } | |
| 16 | + public function getName() | |
| 17 | +	{ | |
| 18 | + return 'Redsys Redirect'; | |
| 19 | + } | |
| 20 | 20 | |
| 21 | - public function getDefaultParameters() | |
| 22 | -    { | |
| 23 | - return array( | |
| 24 | - 'merchantId' => '', | |
| 25 | - 'merchantName' => '', | |
| 26 | - 'terminalId' => '', | |
| 27 | - 'hmacKey' => '', | |
| 28 | - 'testMode' => false, | |
| 29 | - ); | |
| 30 | - } | |
| 21 | + public function getDefaultParameters() | |
| 22 | +	{ | |
| 23 | + return array( | |
| 24 | + 'merchantId' => '', | |
| 25 | + 'merchantName' => '', | |
| 26 | + 'terminalId' => '', | |
| 27 | + 'hmacKey' => '', | |
| 28 | + 'testMode' => false, | |
| 29 | + ); | |
| 30 | + } | |
| 31 | 31 | |
| 32 | - public function getMerchantId() | |
| 33 | -    { | |
| 34 | -        return $this->getParameter('merchantId'); | |
| 35 | - } | |
| 32 | + public function getMerchantId() | |
| 33 | +	{ | |
| 34 | +		return $this->getParameter('merchantId'); | |
| 35 | + } | |
| 36 | 36 | |
| 37 | - public function setMerchantId($value) | |
| 38 | -    { | |
| 39 | -        return $this->setParameter('merchantId', $value); | |
| 40 | - } | |
| 37 | + public function setMerchantId($value) | |
| 38 | +	{ | |
| 39 | +		return $this->setParameter('merchantId', $value); | |
| 40 | + } | |
| 41 | 41 | |
| 42 | - public function getMerchantName() | |
| 43 | -    { | |
| 44 | -        return $this->getParameter('merchantName'); | |
| 45 | - } | |
| 42 | + public function getMerchantName() | |
| 43 | +	{ | |
| 44 | +		return $this->getParameter('merchantName'); | |
| 45 | + } | |
| 46 | 46 | |
| 47 | - public function setMerchantName($value) | |
| 48 | -    { | |
| 49 | -        return $this->setParameter('merchantName', $value); | |
| 50 | - } | |
| 47 | + public function setMerchantName($value) | |
| 48 | +	{ | |
| 49 | +		return $this->setParameter('merchantName', $value); | |
| 50 | + } | |
| 51 | 51 | |
| 52 | - public function getTerminalId() | |
| 53 | -    { | |
| 54 | -        return $this->getParameter('terminalId'); | |
| 55 | - } | |
| 52 | + public function getTerminalId() | |
| 53 | +	{ | |
| 54 | +		return $this->getParameter('terminalId'); | |
| 55 | + } | |
| 56 | 56 | |
| 57 | - public function setTerminalId($value) | |
| 58 | -    { | |
| 59 | -        return $this->setParameter('terminalId', $value); | |
| 60 | - } | |
| 57 | + public function setTerminalId($value) | |
| 58 | +	{ | |
| 59 | +		return $this->setParameter('terminalId', $value); | |
| 60 | + } | |
| 61 | 61 | |
| 62 | - public function getHmacKey() | |
| 63 | -    { | |
| 64 | -        return $this->getParameter('hmacKey'); | |
| 65 | - } | |
| 62 | + public function getHmacKey() | |
| 63 | +	{ | |
| 64 | +		return $this->getParameter('hmacKey'); | |
| 65 | + } | |
| 66 | 66 | |
| 67 | - public function setHmacKey($value) | |
| 68 | -    { | |
| 69 | -        return $this->setParameter('hmacKey', $value); | |
| 70 | - } | |
| 67 | + public function setHmacKey($value) | |
| 68 | +	{ | |
| 69 | +		return $this->setParameter('hmacKey', $value); | |
| 70 | + } | |
| 71 | 71 | |
| 72 | - public function purchase(array $parameters = array()) | |
| 73 | -    { | |
| 74 | -        return $this->createRequest('\Omnipay\Redsys\Message\PurchaseRequest', $parameters); | |
| 75 | - } | |
| 72 | + public function purchase(array $parameters = array()) | |
| 73 | +	{ | |
| 74 | +		return $this->createRequest('\Omnipay\Redsys\Message\PurchaseRequest', $parameters); | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - public function completePurchase(array $parameters = array()) | |
| 78 | -    { | |
| 79 | -        return $this->createRequest('\Omnipay\Redsys\Message\CompletePurchaseRequest', $parameters); | |
| 80 | - } | |
| 77 | + public function completePurchase(array $parameters = array()) | |
| 78 | +	{ | |
| 79 | +		return $this->createRequest('\Omnipay\Redsys\Message\CompletePurchaseRequest', $parameters); | |
| 80 | + } | |
| 81 | 81 | } | 
| @@ -11,15 +11,12 @@ discard block | ||
| 11 | 11 | * | 
| 12 | 12 | * @link http://www.redsys.es/ | 
| 13 | 13 | */ | 
| 14 | -class RedirectGateway extends AbstractGateway | |
| 15 | -{ | |
| 16 | - public function getName() | |
| 17 | -    { | |
| 14 | +class RedirectGateway extends AbstractGateway { | |
| 15 | +    public function getName() { | |
| 18 | 16 | return 'Redsys Redirect'; | 
| 19 | 17 | } | 
| 20 | 18 | |
| 21 | - public function getDefaultParameters() | |
| 22 | -    { | |
| 19 | +    public function getDefaultParameters() { | |
| 23 | 20 | return array( | 
| 24 | 21 | 'merchantId' => '', | 
| 25 | 22 | 'merchantName' => '', | 
| @@ -29,53 +26,43 @@ discard block | ||
| 29 | 26 | ); | 
| 30 | 27 | } | 
| 31 | 28 | |
| 32 | - public function getMerchantId() | |
| 33 | -    { | |
| 29 | +    public function getMerchantId() { | |
| 34 | 30 |          return $this->getParameter('merchantId'); | 
| 35 | 31 | } | 
| 36 | 32 | |
| 37 | - public function setMerchantId($value) | |
| 38 | -    { | |
| 33 | +    public function setMerchantId($value) { | |
| 39 | 34 |          return $this->setParameter('merchantId', $value); | 
| 40 | 35 | } | 
| 41 | 36 | |
| 42 | - public function getMerchantName() | |
| 43 | -    { | |
| 37 | +    public function getMerchantName() { | |
| 44 | 38 |          return $this->getParameter('merchantName'); | 
| 45 | 39 | } | 
| 46 | 40 | |
| 47 | - public function setMerchantName($value) | |
| 48 | -    { | |
| 41 | +    public function setMerchantName($value) { | |
| 49 | 42 |          return $this->setParameter('merchantName', $value); | 
| 50 | 43 | } | 
| 51 | 44 | |
| 52 | - public function getTerminalId() | |
| 53 | -    { | |
| 45 | +    public function getTerminalId() { | |
| 54 | 46 |          return $this->getParameter('terminalId'); | 
| 55 | 47 | } | 
| 56 | 48 | |
| 57 | - public function setTerminalId($value) | |
| 58 | -    { | |
| 49 | +    public function setTerminalId($value) { | |
| 59 | 50 |          return $this->setParameter('terminalId', $value); | 
| 60 | 51 | } | 
| 61 | 52 | |
| 62 | - public function getHmacKey() | |
| 63 | -    { | |
| 53 | +    public function getHmacKey() { | |
| 64 | 54 |          return $this->getParameter('hmacKey'); | 
| 65 | 55 | } | 
| 66 | 56 | |
| 67 | - public function setHmacKey($value) | |
| 68 | -    { | |
| 57 | +    public function setHmacKey($value) { | |
| 69 | 58 |          return $this->setParameter('hmacKey', $value); | 
| 70 | 59 | } | 
| 71 | 60 | |
| 72 | - public function purchase(array $parameters = array()) | |
| 73 | -    { | |
| 61 | +    public function purchase(array $parameters = array()) { | |
| 74 | 62 |          return $this->createRequest('\Omnipay\Redsys\Message\PurchaseRequest', $parameters); | 
| 75 | 63 | } | 
| 76 | 64 | |
| 77 | - public function completePurchase(array $parameters = array()) | |
| 78 | -    { | |
| 65 | +    public function completePurchase(array $parameters = array()) { | |
| 79 | 66 |          return $this->createRequest('\Omnipay\Redsys\Message\CompletePurchaseRequest', $parameters); | 
| 80 | 67 | } | 
| 81 | 68 | } | 
| @@ -13,13 +13,13 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | class WebserviceGateway extends RedirectGateway | 
| 15 | 15 |  { | 
| 16 | - public function getName() | |
| 17 | -    { | |
| 18 | - return 'Redsys Webservice'; | |
| 19 | - } | |
| 16 | + public function getName() | |
| 17 | +	{ | |
| 18 | + return 'Redsys Webservice'; | |
| 19 | + } | |
| 20 | 20 | |
| 21 | - public function purchase(array $parameters = array()) | |
| 22 | -    { | |
| 23 | -        return $this->createRequest('\Omnipay\Redsys\Message\WebservicePurchaseRequest', $parameters); | |
| 24 | - } | |
| 21 | + public function purchase(array $parameters = array()) | |
| 22 | +	{ | |
| 23 | +		return $this->createRequest('\Omnipay\Redsys\Message\WebservicePurchaseRequest', $parameters); | |
| 24 | + } | |
| 25 | 25 | } | 
| @@ -11,15 +11,12 @@ | ||
| 11 | 11 | * | 
| 12 | 12 | * @link http://www.redsys.es/ | 
| 13 | 13 | */ | 
| 14 | -class WebserviceGateway extends RedirectGateway | |
| 15 | -{ | |
| 16 | - public function getName() | |
| 17 | -    { | |
| 14 | +class WebserviceGateway extends RedirectGateway { | |
| 15 | +    public function getName() { | |
| 18 | 16 | return 'Redsys Webservice'; | 
| 19 | 17 | } | 
| 20 | 18 | |
| 21 | - public function purchase(array $parameters = array()) | |
| 22 | -    { | |
| 19 | +    public function purchase(array $parameters = array()) { | |
| 23 | 20 |          return $this->createRequest('\Omnipay\Redsys\Message\WebservicePurchaseRequest', $parameters); | 
| 24 | 21 | } | 
| 25 | 22 | } |