Module: Nicepay

Defined in:
lib/nicepay.rb,
lib/nicepay/api.rb,
lib/nicepay/version.rb

Defined Under Namespace

Modules: Api

Constant Summary collapse

REQ_VA_URL =

Static

'https://www.nicepay.co.id/nicepay/api/onePass.do'
REQ_CC_URL =
'https://www.nicepay.co.id/nicepay/api/orderRegist.do'
CANCEL_VA_URL =
'https://www.nicepay.co.id/nicepay/api/onePassAllCancel.do'
CHECK_STATUS_URL =
'https://www.nicepay.co.id/nicepay/api/onePassStatus.do'
VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.addCart(image, name, detail, amt) ⇒ Object



110
111
112
113
# File 'lib/nicepay.rb', line 110

def self.addCart(image, name, detail, amt)
    self.cart['item'] << { img_url: image , goods_name: name, goods_detail: detail, goods_amt: amt}
    self.cart['count'] = self.cart['item'].count
end

.autoCountTotalObject



139
140
141
142
143
144
145
146
# File 'lib/nicepay.rb', line 139

def self.autoCountTotal
    items = self.cart['item']
    total = 0
    items.each do |key, value|
        total += key[:goods_amt].to_i
    end
    @autoCountTotal = total
end

.callBackUrlObject



33
34
35
# File 'lib/nicepay.rb', line 33

def self.callBackUrl
    @callback_url
end

.callBackUrl=(callback_url) ⇒ Object



61
62
63
64
# File 'lib/nicepay.rb', line 61

def self.callBackUrl=(callback_url)
    @callback_url = callback_url
    true
end

.cartObject



115
116
117
# File 'lib/nicepay.rb', line 115

def self.cart
    @cart
end

.cartDataObject



119
120
121
# File 'lib/nicepay.rb', line 119

def self.cartData
    @cartData = self.cart.to_json
end

.connection_timeoutObject



53
54
55
# File 'lib/nicepay.rb', line 53

def self.connection_timeout
    @connection_timeout
end

.dbProcessUrlObject



37
38
39
# File 'lib/nicepay.rb', line 37

def self.dbProcessUrl
    @db_process_url
end

.dbProcessUrl=(db_process_url) ⇒ Object



66
67
68
69
# File 'lib/nicepay.rb', line 66

def self.dbProcessUrl=(db_process_url)
    @db_process_url = db_process_url
    true
end

.dumpParametersObject



131
132
133
134
135
136
137
# File 'lib/nicepay.rb', line 131

def self.dumpParameters
    @dumpedParameters = "\n///// [POST] Request Parameter Dump /////\n\n"
    @requestParam.each do |key, value|
        @dumpedParameters += key.to_s + ' = ' + value.to_s + "\n\n"
    end
@dumpedParameters
end

.flushParamObject



127
128
129
# File 'lib/nicepay.rb', line 127

def self.flushParam
    @requestParam =  nil
end

.iMidObject



45
46
47
# File 'lib/nicepay.rb', line 45

def self.iMid
    @i_mid
end

.iMid=(i_mid) ⇒ Object



76
77
78
79
# File 'lib/nicepay.rb', line 76

def self.iMid=(i_mid)
    @i_mid = i_mid
    true
end

.max_retryObject



49
50
51
# File 'lib/nicepay.rb', line 49

def self.max_retry
    @max_retry
end

.merchantKeyObject



41
42
43
# File 'lib/nicepay.rb', line 41

def self.merchantKey
    @merchant_key
end

.merchantKey=(merchant_key) ⇒ Object



71
72
73
74
# File 'lib/nicepay.rb', line 71

def self.merchantKey=(merchant_key)
    @merchant_key = merchant_key
    true
end

.merchantTokenObject



94
95
96
97
98
99
100
# File 'lib/nicepay.rb', line 94

def self.merchantToken
    sha256 = Digest::SHA256.new
    @merchantToken = sha256.hexdigest (self.iMid.to_s + \
                                       self.param('referenceNo').to_s + \
                                       self.param('amt').to_s + \
                                       self.merchantKey.to_s)
end

.merchantTokenCObject



102
103
104
105
106
107
108
# File 'lib/nicepay.rb', line 102

def self.merchantTokenC
    sha256 = Digest::SHA256.new
    @merchantToken = sha256.hexdigest (self.iMid.to_s + \
                                       self.param('tXid').to_s + \
                                       self.param('amt').to_s + \
                                       self.merchantKey.to_s)
end

.oneLiner(string) ⇒ Object



123
124
125
# File 'lib/nicepay.rb', line 123

def self.oneLiner(string)
    @oneLiner= string.gsub(/\s+/, "")
end

.param(name) ⇒ Object



86
87
88
# File 'lib/nicepay.rb', line 86

def self.param(name)
    self.requestParam[name]
end

.read_timeoutObject



57
58
59
# File 'lib/nicepay.rb', line 57

def self.read_timeout
    @read_timeout
end

.requestParamObject



90
91
92
# File 'lib/nicepay.rb', line 90

def self.requestParam
    @requestParam
end

.setRequestParam(paramName, paramValue) ⇒ Object



81
82
83
84
# File 'lib/nicepay.rb', line 81

def self.setRequestParam(paramName, paramValue)
    self.requestParam[paramName] = paramValue
    true
end

.userIpObject



158
159
160
161
# File 'lib/nicepay.rb', line 158

def self.userIp
    # @userIP = request.remote_ip
    @userIp = '127.0.0.1'
end

.vaExpiryDate(day) ⇒ Object



148
149
150
151
# File 'lib/nicepay.rb', line 148

def self.vaExpiryDate(day)
    d = Date.today
    @vaExpiryDate  = (d + day).strftime("%Y%m%d")
end

.vaExpiryTimeObject



153
154
155
156
# File 'lib/nicepay.rb', line 153

def self.vaExpiryTime
    t = Time.now
    @vaExpiryTime = t.strftime("%H%M%S")
end