1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* w-vision |
4
|
|
|
* |
5
|
|
|
* LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the GNU General Public License version 3 (GPLv3) |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt |
9
|
|
|
* files that are distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright Copyright (c) 2016 Woche-Pass AG (http://www.w-vision.ch) |
12
|
|
|
* @license GNU General Public License version 3 (GPLv3) |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Omnipay\Datatrans\Message; |
16
|
|
|
|
17
|
|
|
use Omnipay\Common\Message\ResponseInterface; |
18
|
|
|
|
19
|
|
|
abstract class AbstractRedirectRequest extends AbstractRequest |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $optionalParams = array( |
25
|
|
|
|
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @return array |
30
|
|
|
*/ |
31
|
|
|
public function getData() |
32
|
|
|
{ |
33
|
|
|
$this->validate('merchantId', 'transactionId', 'sign'); |
34
|
|
|
|
35
|
|
|
$data = array( |
36
|
|
|
'merchantId' => $this->getMerchantId(), |
37
|
|
|
'refno' => $this->getTransactionId(), |
38
|
|
|
'amount' => $this->getAmountInteger(), |
39
|
|
|
'currency' => $this->getCurrency(), |
40
|
|
|
'sign' => $this->getSign() |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
foreach ($this->optionalParams as $param) { |
44
|
|
|
$value = $this->getParameter($param); |
45
|
|
|
|
46
|
|
|
if ($value !== '') { |
47
|
|
|
$data[$param] = $value; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
$data['successUrl'] = $this->getReturnUrl(); |
52
|
|
|
$data['cancelUrl'] = $this->getCancelUrl(); |
53
|
|
|
$data['errorUrl'] = $this->getErrorUrl(); |
54
|
|
|
$data['cancelUrl'] = $this->getCancelUrl(); |
55
|
|
|
|
56
|
|
|
return $data; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param $value |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function setErrorUrl($value) |
64
|
|
|
{ |
65
|
|
|
return $this->setParameter('errorUrl', $value); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getErrorUrl() |
72
|
|
|
{ |
73
|
|
|
return $this->getParameter('errorUrl'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return ResponseInterface |
78
|
|
|
*/ |
79
|
|
|
public function send() |
80
|
|
|
{ |
81
|
|
|
return $this->sendData($this->getData()); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Send the request with specified data |
86
|
|
|
* |
87
|
|
|
* @param mixed $data The data to send |
88
|
|
|
* @return ResponseInterface |
89
|
|
|
*/ |
90
|
|
|
public function sendData($data) |
91
|
|
|
{ |
92
|
|
|
return $this->response = new PurchaseResponse($this, $data); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|