AbstractRequest::setTransactionMemo()   A
last analyzed

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 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Omnipay\Gtpay\Message;
3
4
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest
5
{
6
7
    const DEMO_WEBSERVICE_URL = "https://gtweb2.gtbank.com/GTPayService/gettransactionstatus.json";
8
    const LIVE_WEBSERVICE_URL = "https://ibank.gtbank.com/GTPayService/gettransactionstatus.json";
9
10
    /**
11
     * Generates transaction ID. Payment methods with a different need can extend this
12
     * @return string  Transaction reference delivered
13
     */
14
    public static function generateTransactionId()
15
    {
16
        return str_pad(time(), 14, '0', STR_PAD_LEFT);
17
    }
18
19
    /**
20
     * @return mixed
21
     */
22 13
    public function getMerchantId()
23
    {
24 13
        return $this->getParameter(Data::MERCHANT_ID);
25
    }
26
27 16
    public function setMerchantId($merchantId)
28
    {
29 16
        return $this->setParameter(Data::MERCHANT_ID, $merchantId);
30
    }
31
32
    /**
33
     * The value of this parameter will be the merchant-wide unique identifier of the customer.
34
     * For example, for a student paying for school fees online, this may be the student's School's Registration Number
35
     * @param $customerId
36
     * @return \Omnipay\Common\Message\AbstractRequest
37
     */
38 12
    public function setCustomerId($customerId)
39
    {
40 12
        return $this->setParameter(Data::CUSTOMER_ID, $customerId);
41
    }
42
43
    /**
44
     * @see AbstractRequest::setCustomerId()
45
     * @return mixed
46
     */
47 8
    public function getCustomerId()
48
    {
49 8
        return $this->getParameter(Data::CUSTOMER_ID) ;
50
    }
51
52
    /**
53
     * [Optional Parameter]
54
     * This describes the transaction to the customer.
55
     * For example, gtpay_tranx_memo = "John Adebisi (REG13762) : 2nd Term School Fees Payment"
56
     If not sent, "Purchasing from [Business-Name-Of-Merchant]" will be used
57
     * @param $memo
58
     * @return \Omnipay\Common\Message\AbstractRequest
59
     */
60 12
    public function setTransactionMemo($memo)
61
    {
62 12
        return $this->setParameter(Data::TRANSACTION_MEMO, $memo);
63
    }
64
65
    /**
66
     * @return mixed
67
     * @see AbstractRequest::setTransactionMemo()
68
     */
69
    public function getTransactionMemo()
70
    {
71
        return $this->getParameter(Data::TRANSACTION_MEMO);
72
    }
73
74
    /**
75
     * If specified, then customer cannot choose what gateway to use for the transaction.
76
     * Accepted values are "webpay" or "ibank" (Bank Transfer) only.
77
     * @param $gateway
78
     * @return \Omnipay\Common\Message\AbstractRequest
79
     */
80 16
    public function setGatewayName($gateway)
81
    {
82 16
        return $this->setParameter(Data::GATEWAY_NAME, $gateway);
83
    }
84
85
    /**
86
     * @see AbstractRequest::setGatewayName()
87
     * @return mixed
88
     */
89 3
    public function getGatewayName()
90
    {
91 3
        return $this->getParameter(Data::GATEWAY_NAME);
92
    }
93
94
    /**
95
     *  Merchant can store in this the name to be displayed on the payment page for the customer.
96
     * @param $customerName
97
     * @return \Omnipay\Common\Message\AbstractRequest Returns a fluent Interface
98
     */
99 12
    public function setCustomerName($customerName)
100
    {
101 12
        return $this->setParameter(Data::CUSTOMER_NAME, $customerName) ;
102
    }
103
104
    /**
105
     * @see AbstractRequest::getCustomerName()
106
     * @return mixed
107
     */
108 1
    public function getCustomerName()
109
    {
110 1
        return $this->getParameter(Data::CUSTOMER_NAME);
111
    }
112
113 1
    public function getTransactionHash()
114
    {
115
        //gtpay_mert_id,gtpay_tranx_id,gtpay_tranx_amt,gtpay_tranx_curr,gtpay_cust_id,gtpay_tranx_noti_url,hash
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
116
117 1
        $rawString = $this->getMerchantId().
118 1
            $this->getTransactionId().
119 1
            $this->getAmountInteger().
120 1
            $this->getCurrencyNumeric().
121 1
            $this->getCustomerId().
122 1
            $this->getNotifyUrl().
123 1
            $this->getHashKey();
124 1
        $hash = hash('sha512', $rawString);
125 1
        return $hash;
126
    }
127
128
    /**
129
     * set Gtpay Hash Key Given to Merchant at Setup
130
     * @param $hashKey
131
     * @return \Omnipay\Common\Message\AbstractRequest
132
     */
133 16
    public function setHashKey($hashKey)
134
    {
135 16
        return $this->setParameter(Data::HASH_KEY, $hashKey);
136
    }
137
138
    /**
139
     * @see Gateway::setHashKey()
140
     * @return mixed
141
     */
142 13
    public function getHashKey()
143
    {
144 13
        return $this->getParameter(Data::HASH_KEY);
145
    }
146
147
    /**
148
     * @param $value
149
     * @return \Omnipay\Common\Message\AbstractRequest
150
     */
151 16
    public function setGatewayFirst($value)
152
    {
153 16
        return $this->setParameter(Data::GATEWAY_FIRST, $value);
154
    }
155
156
    /**
157
     * @return mixed
158
     */
159 2
    public function getGatewayFirst()
160
    {
161 2
        return $this->getParameter(Data::GATEWAY_FIRST);
162
    }
163
164
165 10
    public function getWebserviceUrl()
166
    {
167 10
        return $this->getTestMode()?self::DEMO_WEBSERVICE_URL:self::LIVE_WEBSERVICE_URL;
168
    }
169
}
170