Gateway   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 98
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getAccessToken() 0 3 1
A setAccessToken() 0 3 1
A setMerchantId() 0 3 1
A purchase() 0 5 1
A getMerchantId() 0 3 1
A getPassword() 0 3 1
A setPassword() 0 3 1
A getName() 0 3 1
A getDefaultParameters() 0 6 1
1
<?php
2
3
namespace Omnipay\OCBC;
4
5
use Omnipay\Common\AbstractGateway;
6
7
/**
8
 * OCBC JSON Gateway
9
 *
10
 * @link https://api.ocbc.com/store/site/pages/api_documentation.jag?name=Transactional_MerchantCardPayments
11
 */
12
class Gateway extends AbstractGateway
13
{
14
    /**
15
     * Name of the gateway
16
     *
17
     * @return string
18
     */
19 1
    public function getName()
20
    {
21 1
        return 'OCBC JSON';
22
    }
23
24
    /**
25
     * Setup the default parameters
26
     *
27
     * @return string[]
28
     */
29 27
    public function getDefaultParameters()
30
    {
31
        return array(
32 27
            'accessToken' => '',
33 27
            'merchantId' => '',
34 27
            'password' => '',
35 27
        );
36
    }
37
38
    /**
39
     * Get the stored access token
40
     *
41
     * @return string
42
     */
43 1
    public function getAccessToken()
44
    {
45 1
        return $this->getParameter('accessToken');
46
    }
47
48
    /**
49
     * Set the stored access token
50
     *
51
     * @param string $value  Access token to store
52
     */
53 27
    public function setAccessToken($value)
54
    {
55 27
        return $this->setParameter('accessToken', $value);
56
    }
57
58
    /**
59
     * Get the stored merchant ID
60
     *
61
     * @return string
62
     */
63 1
    public function getMerchantId()
64
    {
65 1
        return $this->getParameter('merchantId');
66
    }
67
68
    /**
69
     * Set the stored merchant ID
70
     *
71
     * @param string $value  Merchant ID to store
72
     */
73 27
    public function setMerchantId($value)
74
    {
75 27
        return $this->setParameter('merchantId', $value);
76
    }
77
78
    /**
79
     * Get the stored merchant password
80
     *
81
     * @return string
82
     */
83 1
    public function getPassword()
84
    {
85 1
        return $this->getParameter('password');
86
    }
87
88
    /**
89
     * Set the stored merchant password
90
     *
91
     * @param string $value  Merchant password to store
92
     */
93 27
    public function setPassword($value)
94
    {
95 27
        return $this->setParameter('password', $value);
96
    }
97
98
    /**
99
     * Create purchase request
100
     *
101
     * @param array $parameters
102
     *
103
     * @return \Omnipay\OCBC\Message\PurchaseRequest
104
     */
105 3
    public function purchase(array $parameters = array())
106
    {
107
        // currency is always Singapore Dollars
108 3
        $parameters['currency'] = 'SGD';
109 3
        return $this->createRequest('\Omnipay\OCBC\Message\PurchaseRequest', $parameters);
110
    }
111
}
112