Completed
Pull Request — master (#5)
by
unknown
15:21
created

AbstractRedirectRequest::setUseAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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
use Omnipay\Common\Message\ResponseInterface;
18
19
abstract class AbstractRedirectRequest extends AbstractRequest
20
{
21
    /**
22
     * @var array
23
     */
24
    protected $optionalParams = array(
25
        'uppReturnMaskedCC',
26
        'useAlias',
27
    );
28
29
    /**
30
     * @return array
31
     */
32 2
    public function getData()
33
    {
34 2
        $this->validate('merchantId', 'transactionId', 'sign');
35
36
        $data = array(
37 2
            'merchantId' => $this->getMerchantId(),
38 2
            'refno'      => $this->getTransactionId(),
39 2
            'amount'     => $this->getAmountInteger(),
40 2
            'currency'   => $this->getCurrency(),
41 2
            'sign'       => $this->getSign(),
42 2
        );
43
44 2
        foreach ($this->optionalParams as $param) {
45 2
            $value = $this->getParameter($param);
46
47 2
            if (!empty($value)) {
48 1
                $data[$param] = $value;
49 1
            }
50 2
        }
51
52 2
        $data['successUrl'] = $this->getReturnUrl();
53 2
        $data['cancelUrl'] = $this->getCancelUrl();
54 2
        $data['errorUrl'] = $this->getErrorUrl();
55 2
        $data['cancelUrl'] = $this->getCancelUrl();
56
57 2
        return $data;
58
    }
59
60
    /**
61
     * @param $value
62
     * @return string
63
     */
64 2
    public function setErrorUrl($value)
65
    {
66 2
        return $this->setParameter('errorUrl', $value);
67
    }
68
69
    /**
70
     * @return string
71
     */
72 2
    public function getErrorUrl()
73
    {
74 2
        return $this->getParameter('errorUrl');
75
    }
76
77
    /**
78
     * @return ResponseInterface
79
     */
80 1
    public function send()
81
    {
82 1
        return $this->sendData($this->getData());
83
    }
84
85
    /**
86
     * Send the request with specified data
87
     *
88
     * @param  mixed $data The data to send
89
     * @return ResponseInterface
90
     */
91 1
    public function sendData($data)
92
    {
93 1
        return $this->response = new PurchaseResponse($this, $data);
94
    }
95
96
    /**
97
     * @param $value
98
     * @return \Omnipay\Common\Message\AbstractRequest
99
     */
100 1
    public function setUppReturnMaskedCC($value)
101
    {
102 1
        return $this->setParameter('uppReturnMaskedCC', $value);
103
    }
104
105
    /**
106
     * @param $value
107
     * @return \Omnipay\Common\Message\AbstractRequest
108
     */
109 1
    public function setUseAlias($value)
110
    {
111 1
        return $this->setParameter('useAlias', $value);
112
    }
113
}
114