1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* w-vision |
4
|
|
|
* |
5
|
|
|
* LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the MIT License |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that are distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright Copyright (c) 2016 Woche-Pass AG (http://www.w-vision.ch) |
12
|
|
|
* @license MIT License |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Omnipay\Datatrans\Message; |
16
|
|
|
|
17
|
|
|
class PurchaseRequest extends AbstractRedirectRequest |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
protected $optionalParams = array( |
23
|
|
|
'useAlias', |
24
|
|
|
'uppReturnMaskedCC', |
25
|
|
|
'uppRememberMe', |
26
|
|
|
'paymentMethod' |
27
|
|
|
); |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
2 |
|
public function getData() |
33
|
|
|
{ |
34
|
2 |
|
$data = parent::getData(); |
35
|
|
|
|
36
|
|
|
//set customer details if set |
37
|
2 |
|
if (($customerDetails = $this->getParameter('uppCustomerDetails')) && is_array($customerDetails)) { |
38
|
|
|
$data['uppCustomerDetails'] = 'yes'; |
39
|
|
|
foreach ($customerDetails as $key => $value) { |
40
|
|
|
$data[$key] = $value; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
// card data for prefilling redirect form |
45
|
2 |
|
$this->addCardData($data); |
46
|
|
|
|
47
|
2 |
|
return $data; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param $value |
52
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
53
|
|
|
*/ |
54
|
1 |
|
public function setUppReturnMaskedCC($value) |
55
|
|
|
{ |
56
|
1 |
|
return $this->setParameter('uppReturnMaskedCC', $value); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param $value |
61
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
62
|
|
|
*/ |
63
|
1 |
|
public function setUseAlias($value) |
64
|
|
|
{ |
65
|
1 |
|
return $this->setParameter('useAlias', $value); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param $value |
70
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
71
|
|
|
*/ |
72
|
|
|
public function setUppCustomerDetails($value) |
73
|
|
|
{ |
74
|
|
|
return $this->setParameter('uppCustomerDetails', $value); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param $value |
79
|
|
|
* @return \Omnipay\Common\Message\AbstractRequest |
80
|
|
|
*/ |
81
|
|
|
public function setUppRememberMe($value) |
82
|
|
|
{ |
83
|
|
|
return $this->setParameter('uppRememberMe', $value); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* enable functionality to prefill datatrans form in redirect mode |
88
|
|
|
* |
89
|
|
|
* @param $data |
90
|
|
|
*/ |
91
|
2 |
|
private function addCardData(&$data) |
92
|
|
|
{ |
93
|
|
|
// rename paymentmethod if set |
94
|
2 |
|
if (isset($data['paymentMethod'])) { |
95
|
|
|
$data['paymentmethod'] = $data['paymentMethod']; |
96
|
|
|
unset($data['paymentMethod']); |
97
|
|
|
} |
98
|
|
|
|
99
|
2 |
|
if ($card = $this->getCard()) { |
100
|
|
|
if ($expMonth = $card->getExpiryMonth()) { |
101
|
|
|
$data['expm'] = $expMonth; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
if ($expYear = $card->getExpiryDate('y')) { |
105
|
|
|
$data['expy'] = $expYear; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if ($number = $card->getNumber()) { |
109
|
|
|
$data['aliasCC'] = $number; |
110
|
|
|
} |
111
|
|
|
} |
112
|
2 |
|
} |
113
|
|
|
} |
114
|
|
|
|