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
- .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
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 |
.autoCountTotal ⇒ Object
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 |
.callBackUrl ⇒ Object
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 |
.cart ⇒ Object
115 116 117 |
# File 'lib/nicepay.rb', line 115 def self.cart @cart end |
.cartData ⇒ Object
119 120 121 |
# File 'lib/nicepay.rb', line 119 def self.cartData @cartData = self.cart.to_json end |
.connection_timeout ⇒ Object
53 54 55 |
# File 'lib/nicepay.rb', line 53 def self.connection_timeout @connection_timeout end |
.dbProcessUrl ⇒ Object
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 |
.dumpParameters ⇒ Object
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 |
.flushParam ⇒ Object
127 128 129 |
# File 'lib/nicepay.rb', line 127 def self.flushParam @requestParam = nil end |
.iMid ⇒ Object
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_retry ⇒ Object
49 50 51 |
# File 'lib/nicepay.rb', line 49 def self.max_retry @max_retry end |
.merchantKey ⇒ Object
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 |
.merchantToken ⇒ Object
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 |
.merchantTokenC ⇒ Object
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_timeout ⇒ Object
57 58 59 |
# File 'lib/nicepay.rb', line 57 def self.read_timeout @read_timeout end |
.requestParam ⇒ Object
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 |
.userIp ⇒ Object
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 |
.vaExpiryTime ⇒ Object
153 154 155 156 |
# File 'lib/nicepay.rb', line 153 def self.vaExpiryTime t = Time.now @vaExpiryTime = t.strftime("%H%M%S") end |