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.1.6"

Class Method Summary collapse

Class Method Details

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



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

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



134
135
136
137
138
139
140
141
# File 'lib/nicepay.rb', line 134

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



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

def self.callBackUrl
    @callback_url
end

.callBackUrl=(callback_url) ⇒ Object



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

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

.cartObject



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

def self.cart
    @cart
end

.cartDataObject



113
114
115
# File 'lib/nicepay.rb', line 113

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

.connection_timeoutObject



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

def self.connection_timeout
    @connection_timeout
end

.dbProcessUrlObject



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

def self.dbProcessUrl
    @db_process_url
end

.dbProcessUrl=(db_process_url) ⇒ Object



64
65
66
# File 'lib/nicepay.rb', line 64

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

.dumpParametersObject



126
127
128
129
130
131
132
# File 'lib/nicepay.rb', line 126

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



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

def self.flushParam
    @cart = @cart.clear
    @requestParam = @requestParam.clear
end

.iMidObject



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

def self.iMid
    @i_mid
end

.iMid=(i_mid) ⇒ Object



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

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

.max_retryObject



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

def self.max_retry
    @max_retry
end

.merchantKeyObject



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

def self.merchantKey
    @merchant_key
end

.merchantKey=(merchant_key) ⇒ Object



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

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

.merchantTokenObject



88
89
90
91
92
93
94
# File 'lib/nicepay.rb', line 88

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



96
97
98
99
100
101
102
# File 'lib/nicepay.rb', line 96

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



117
118
119
# File 'lib/nicepay.rb', line 117

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

.param(name) ⇒ Object



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

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

.read_timeoutObject



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

def self.read_timeout
    @read_timeout
end

.requestParamObject



84
85
86
# File 'lib/nicepay.rb', line 84

def self.requestParam
    @requestParam
end

.setRequestParam(paramName, paramValue) ⇒ Object



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

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

.userIpObject



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

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

.vaExpiryDate(day) ⇒ Object



143
144
145
146
# File 'lib/nicepay.rb', line 143

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

.vaExpiryTimeObject



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

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