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.1"
Class Method Summary collapse
- .addCart(image, name, detail, amt) ⇒ Object
- .autoCountTotal ⇒ Object
- .callBackUrl ⇒ Object
- .callBackUrl=(callback_url) ⇒ Object
- .cart ⇒ Object
- .cartData ⇒ Object
- .connection_timeout ⇒ Object
- .dbProcessUrl ⇒ Object
- .dbProcessUrl=(db_process_url) ⇒ Object
- .dumpParameters ⇒ Object
- .flushParam ⇒ Object
- .iMid ⇒ Object
- .iMid=(i_mid) ⇒ Object
- .max_retry ⇒ Object
- .merchantKey ⇒ Object
- .merchantKey=(merchant_key) ⇒ Object
- .merchantToken ⇒ Object
- .merchantTokenC ⇒ Object
- .oneLiner(string) ⇒ Object
- .param(name) ⇒ Object
- .read_timeout ⇒ Object
- .requestParam ⇒ Object
- .setRequestParam(paramName, paramValue) ⇒ Object
- .userIp ⇒ Object
- .vaExpiryDate(day) ⇒ Object
- .vaExpiryTime ⇒ Object
Class Method Details
.addCart(image, name, detail, amt) ⇒ Object
109 110 111 112 |
# File 'lib/nicepay.rb', line 109 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 |
.autoCountTotal ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/nicepay.rb', line 138 def self.autoCountTotal items = self.cart['item'] total = 0 items.each do |key, value| total += key[:goods_amt].to_i end @autoCountTotal = total end |
.callBackUrl ⇒ Object
32 33 34 |
# File 'lib/nicepay.rb', line 32 def self.callBackUrl @callback_url end |
.callBackUrl=(callback_url) ⇒ Object
60 61 62 63 |
# File 'lib/nicepay.rb', line 60 def self.callBackUrl=(callback_url) @callback_url = callback_url true end |
.cart ⇒ Object
114 115 116 |
# File 'lib/nicepay.rb', line 114 def self.cart @cart end |
.cartData ⇒ Object
118 119 120 |
# File 'lib/nicepay.rb', line 118 def self.cartData @cartData = self.cart.to_json end |
.connection_timeout ⇒ Object
52 53 54 |
# File 'lib/nicepay.rb', line 52 def self.connection_timeout @connection_timeout end |
.dbProcessUrl ⇒ Object
36 37 38 |
# File 'lib/nicepay.rb', line 36 def self.dbProcessUrl @db_process_url end |
.dbProcessUrl=(db_process_url) ⇒ Object
65 66 67 68 |
# File 'lib/nicepay.rb', line 65 def self.dbProcessUrl=(db_process_url) @db_process_url = db_process_url true end |
.dumpParameters ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/nicepay.rb', line 130 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 |
.flushParam ⇒ Object
126 127 128 |
# File 'lib/nicepay.rb', line 126 def self.flushParam @requestParam = nil end |
.iMid ⇒ Object
44 45 46 |
# File 'lib/nicepay.rb', line 44 def self.iMid @i_mid end |
.iMid=(i_mid) ⇒ Object
75 76 77 78 |
# File 'lib/nicepay.rb', line 75 def self.iMid=(i_mid) @i_mid = i_mid true end |
.max_retry ⇒ Object
48 49 50 |
# File 'lib/nicepay.rb', line 48 def self.max_retry @max_retry end |
.merchantKey ⇒ Object
40 41 42 |
# File 'lib/nicepay.rb', line 40 def self.merchantKey @merchant_key end |
.merchantKey=(merchant_key) ⇒ Object
70 71 72 73 |
# File 'lib/nicepay.rb', line 70 def self.merchantKey=(merchant_key) @merchant_key = merchant_key true end |
.merchantToken ⇒ Object
93 94 95 96 97 98 99 |
# File 'lib/nicepay.rb', line 93 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 |
.merchantTokenC ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/nicepay.rb', line 101 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
122 123 124 |
# File 'lib/nicepay.rb', line 122 def self.oneLiner(string) @oneLiner= string.gsub(/\s+/, "") end |
.param(name) ⇒ Object
85 86 87 |
# File 'lib/nicepay.rb', line 85 def self.param(name) self.requestParam[name] end |
.read_timeout ⇒ Object
56 57 58 |
# File 'lib/nicepay.rb', line 56 def self.read_timeout @read_timeout end |
.requestParam ⇒ Object
89 90 91 |
# File 'lib/nicepay.rb', line 89 def self.requestParam @requestParam end |
.setRequestParam(paramName, paramValue) ⇒ Object
80 81 82 83 |
# File 'lib/nicepay.rb', line 80 def self.setRequestParam(paramName, paramValue) self.requestParam[paramName] = paramValue true end |
.userIp ⇒ Object
157 158 159 160 |
# File 'lib/nicepay.rb', line 157 def self.userIp # @userIP = request.remote_ip @userIp = '127.0.0.1' end |
.vaExpiryDate(day) ⇒ Object
147 148 149 150 |
# File 'lib/nicepay.rb', line 147 def self.vaExpiryDate(day) d = Date.today @vaExpiryDate = (d + day).strftime("%Y%m%d") end |
.vaExpiryTime ⇒ Object
152 153 154 155 |
# File 'lib/nicepay.rb', line 152 def self.vaExpiryTime t = Time.now @vaExpiryTime = t.strftime("%H%M%S") end |