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