nicepay 0.1.0 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6458582fd02ea05457e7bd27d6293c232384a896
4
- data.tar.gz: d6e62baa8fea18b841704dc975f89e800ad7e365
2
+ SHA256:
3
+ metadata.gz: c9ab9063304258a2826b812e22c2f6d997dc8d606b74a4da6d0e7468ab5c700f
4
+ data.tar.gz: c4db553ac7ded7eb4f7546910bc0aac4a7ec05d821ce9d442d4ddad7f1a87b36
5
5
  SHA512:
6
- metadata.gz: f90278ab8dec887cbf8d519b20b792145de99477d71cee21672f4e5801b9a57572a2f098c82ce1d3d6eab33a9ec1a20050e8deb2fa2cc4e1418d98cb10018e21
7
- data.tar.gz: 01b582b8e8ea93ad797970e3c931ae022d6f941de53f726049d09529ff9474369eff83d6cf9dd54b3e9be6b17e2cfd43c7be99c07917f233a7230e446848f86d
6
+ metadata.gz: 67df9cf8623d953db2e5b8ed1f911fce6b13a0855e68059a1310316f09784c0f7d7e37ba240a7bbe40df3b6e59ba38be4573d8d24a48da1f19a62c0f592f93be
7
+ data.tar.gz: a832559bb987dd9b56d7c065f51c75830a5ec566b19df465347995d6a3a56a0ad68e4563e0e50358944e0a78645d8c41c8a865a899238253b62582b3ec21040f
data/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
@@ -1,13 +1,13 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1
6
- - 2.2
7
- - 2.3.0
8
- - jruby-19mode
9
- - jruby-9.0.5.0
10
- - 2.2.4
11
- before_install: gem install bundler -v 1.11.2
12
-
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2
7
+ - 2.3.0
8
+ - jruby-19mode
9
+ - jruby-9.0.5.0
10
+ - 2.2.4
11
+ before_install: gem install bundler -v 1.11.2
12
+
13
13
  sudo: false
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in nicepay.gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nicepay.gemspec
4
4
  gemspec
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 NICEPay Indonesia
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 NICEPay Indonesia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,107 +1,477 @@
1
- # NICEPay Ruby Binding
2
-
3
- ## Ruby SDK API Operation Test
4
-
5
- ### Virtual Account
6
-
7
- ```
8
- $ ruby test-va.rb
9
- ```
10
-
11
- ```
12
- ----------------------------------------------------------------------
13
- Virtual Account Number : 7001400000000631
14
- Description : Payment of Invoice-7834
15
- Reference No : Invoice-7834
16
- Transaction ID : VACCTCLOSE02201606061649584906
17
- ----------------------------------------------------------------------
18
- ```
19
-
20
- ### Card Checkout
21
-
22
- ```
23
- $ ruby test-card.rb
24
- ```
25
-
26
- ```
27
- -----------------------------------------------------------------------------------------------------
28
- Redirect Customer to : https://www.nicepay.co.id/nicepay/api/orderInquiry.do?tXid=IONPAYTEST01201606061651114907
29
- tXid : IONPAYTEST01201606061651114907
30
- -----------------------------------------------------------------------------------------------------
31
- ```
32
-
33
- ### Check Transaction Status
34
-
35
- ```
36
- $ ruby test-status.rb
37
- ```
38
-
39
- ```
40
- ----------------------------------------------------------------------
41
- Transaction Status : 3
42
- Amount : 3000
43
- Reference No : Invoice-7834
44
- Transaction ID : VACCTCLOSE02201606061354204825
45
- ----------------------------------------------------------------------
46
- ```
47
-
48
- ## Ruby on Rails
49
-
50
- 1. Install NICEPay Gem
51
-
52
- ```
53
- $ gem install nicepay
54
- ```
55
- or build from source
56
- ```
57
- $ gem build nicepay.gemspec
58
- ```
59
- 2. Create checkout controller
60
- ```
61
- $ rails g controller checkout
62
- ```
63
- 3. Add action to controller
64
- ```
65
- def new
66
- end
67
-
68
- def create
69
- # Amount in cents
70
- @amount = 500
71
-
72
- requestVa= Nicepay::Api::RequestVa.new(Nicepay.requestParam)
73
- chargeCard= Nicepay::Api::ChargeCard.new(Nicepay.requestParam)
74
- checkStatus=Nicepay::Api::CheckStatus.new(Nicepay.requestParam)
75
-
76
- end
77
- ```
78
- 4. Define Route
79
- ```
80
- resources :checkout
81
- ```
82
- 5. Configure application
83
- ```
84
- Rails.configuration.nicepay = {
85
- :iMid=> ENV['I_MID'],
86
- :merchantKey=> ENV['MERCHANT_KEY']
87
- }
88
-
89
- Nicepay.merchantKey= Rails.configuration.nicepay[:merchantKey]
90
- Nicepay.iMid= Rails.configuration.nicepay[:iMid]
91
- ```
92
-
93
- 6. Create view
94
-
95
- Create a checkout.html.erb layout under app/views/layouts:
96
- ```
97
- <!DOCTYPE html>
98
- <html>
99
- <head>
100
- </head>
101
- <body>
102
- <%= yield %>
103
- </body>
104
- </html>
105
- ```
106
-
107
- and so on...
1
+ # NICEPay Ruby Bindings
2
+
3
+ ```
4
+ NICEPAY ♥ Ruby
5
+ ```
6
+
7
+ ## Payment Flow
8
+
9
+ ### Credit Card
10
+
11
+ ![Card Flow](https://drive.google.com/uc?export=view&id=0BwDN_OMoONYMaHlLRnBfY1RVZGM "Card Flow")
12
+
13
+ ### Virtual Account
14
+
15
+ ![VA Flow](https://drive.google.com/uc?export=view&id=0BwDN_OMoONYMREpvVmNlNDhOeGc "VA Flow")
16
+
17
+ ## Nicepay Ruby SDK Installation
18
+
19
+ ### Install Nicepay Ruby Gem
20
+
21
+ ```
22
+ gem install nicepay
23
+ ```
24
+
25
+ ### Add Nicepay Gem into GEMFILE
26
+
27
+ add following line
28
+ ```
29
+ gem 'nicepay', '~> 0.1.6'
30
+ ```
31
+
32
+ ## Nicepay API Operation
33
+
34
+ ### Generate Virtual Account
35
+
36
+ #### Sample Code `sample/test-va.rb`
37
+
38
+ ```
39
+ =begin
40
+ Nicepay Ruby Bindings
41
+ Virtual Account Sample Code
42
+ Have a Nicepay!
43
+ =end
44
+ require 'nicepay'
45
+ # require 'nicepay'
46
+ # Configuration
47
+
48
+ # MID
49
+ Nicepay.iMid=('VACCTCLOSE')
50
+ # Merchant Key
51
+ Nicepay.merchantKey=('33F49GnCMS1mFYlGXisbUDzVf2ATWCl9k3R++d5hDd3Frmuos/XLx8XhXpe+LDYAbpGKZYSwtlyyLOtS/8aD7A==')
52
+ # Webhook/Notification Handler URL
53
+ Nicepay.dbProcessUrl=('http://httpresponder.com/nicepay')
54
+ Nicepay.callBackUrl=('http://www.example.com/')
55
+
56
+ # API Operation
57
+ requestVa = Nicepay::Api::RequestVa.new(Nicepay.requestParam)
58
+
59
+ # Set Request Parameter for Virtual Account
60
+
61
+ # Merchant Id
62
+ Nicepay.setRequestParam('iMid', Nicepay.iMid)
63
+
64
+ # Bank Transfer -> payMethod = 02
65
+ Nicepay.setRequestParam('payMethod', '02')
66
+
67
+ # Set Bank
68
+ # BCA -> CENA
69
+ # BNI -> BNIN
70
+ # Mandiri -> BMRI
71
+ # Hana Bank -> HNBN
72
+ # Maybank -> IBBK
73
+ # Permata -> BBBA
74
+ Nicepay.setRequestParam('bankCd', 'CENA')
75
+
76
+ # Reference Number / Order Number / Invoice Number, generated by merchant
77
+ Nicepay.setRequestParam('referenceNo','Invoice-7834')
78
+
79
+ # Transaction Description
80
+ Nicepay.setRequestParam('description','Payment of ' + Nicepay.param('referenceNo')) # Description
81
+ Nicepay.setRequestParam('goodsNm', Nicepay.param('description')) # goodsNm = Description
82
+
83
+ # Add cart information mandatory at least one cart data
84
+ # Nicepay.addCart('image_location','product_name','product_description', 'sub_total_amount')
85
+ Nicepay.addCart('https://www.nicepay.co.id/nicepay/images/cart.png', 'Glasses', 'Jumlah: 3', 1000)
86
+ Nicepay.addCart('https://www.nicepay.co.id/nicepay/images/cart.png', 'Glasses', 'Jumlah: 1', 2000)
87
+
88
+ # Set cartData as request parameter
89
+ Nicepay.setRequestParam('cartData', Nicepay.cartData)
90
+
91
+ # Amount -> auto count from cartData
92
+ Nicepay.setRequestParam('amt', Nicepay.autoCountTotal)
93
+
94
+ # Currency -> Indonesian Rupiah
95
+ Nicepay.setRequestParam('currency', 'IDR')
96
+
97
+ # Set customer information
98
+ Nicepay.setRequestParam('billingNm', 'John Doe')
99
+ Nicepay.setRequestParam('billingPhone', '02112341234')
100
+ Nicepay.setRequestParam('billingEmail', 'john.doe@example.com')
101
+ Nicepay.setRequestParam('billingAddr', 'Jl. Jend Sudirman')
102
+ Nicepay.setRequestParam('billingCity', 'Jakarta Pusat')
103
+ Nicepay.setRequestParam('billingState', 'DKI Jakarta')
104
+ Nicepay.setRequestParam('billingPostCd', '10210')
105
+ Nicepay.setRequestParam('billingCountry', 'Indonesia')
106
+
107
+ Nicepay.setRequestParam('deliveryNm', 'John Doe')
108
+ Nicepay.setRequestParam('deliveryPhone', '02112341234')
109
+ Nicepay.setRequestParam('deliveryEmail', 'john.doe@example.com')
110
+ Nicepay.setRequestParam('deliveryAddr', 'Jl. Jend Sudirman')
111
+ Nicepay.setRequestParam('deliveryCity', 'Jakarta Pusat')
112
+ Nicepay.setRequestParam('deliveryState', 'DKI Jakarta')
113
+ Nicepay.setRequestParam('deliveryPostCd', '10210')
114
+ Nicepay.setRequestParam('deliveryCountry', 'Indonesia')
115
+
116
+ # Set User Customer IP
117
+ Nicepay.setRequestParam('userIP', Nicepay.userIp)
118
+
119
+ # Set dbProcessUrl (Notification Handler / Web Hook URL)
120
+ Nicepay.setRequestParam('dbProcessUrl', Nicepay.dbProcessUrl)
121
+
122
+ # Set callbackUrl (Redirection page after payment URL)
123
+ Nicepay.setRequestParam('callBackUrl', Nicepay.callBackUrl)
124
+
125
+ # Set vat, fee & noTaxAmt -> reserved for future feature, only set 0 for now
126
+ Nicepay.setRequestParam('vat', 0)
127
+ Nicepay.setRequestParam('fee', 0)
128
+ Nicepay.setRequestParam('notaxAmt', 0)
129
+
130
+ # Set VA expiry date -> 2 days from now
131
+ Nicepay.setRequestParam('vacctValidDt', Nicepay.vaExpiryDate(2)) # format: %Y%m%d
132
+ # You can also set like this
133
+ # Nicepay.setRequestParam('vacctValidDt', '20160608') # format: %Y%m%d
134
+
135
+ # Set VA expiry time -> time as now
136
+ Nicepay.setRequestParam('vacctValidTm', Nicepay.vaExpiryTime) # format: %H%M%S
137
+ # You can also set like this
138
+ # Nicepay.setRequestParam('vacctValidTm', '095519') # format: %H%M%S
139
+
140
+ # Merchant Token
141
+ Nicepay.setRequestParam('merchantToken', Nicepay.merchantToken)
142
+
143
+ # If you want to dump POST parameters and review it
144
+ # puts Nicepay.dumpParameters
145
+ # abort("Exit")
146
+
147
+ # Inspect Response
148
+ # puts requestVa.response.inspect
149
+
150
+ response = requestVa.response
151
+
152
+ # Inspect response
153
+ # puts response.inspect
154
+
155
+ # If success, show and email VA information including customer journey to customer
156
+
157
+ if response["resultCd"].to_s == "0000"
158
+ puts "\n"
159
+ puts "----------------------------------------------------------------------"
160
+ puts "Virtual Account Number : " + response["bankVacctNo"].to_s
161
+ puts "Description : " + response["description"].to_s
162
+ puts "Reference No : " + response["referenceNo"].to_s
163
+ puts "Transaction ID : " + response["tXid"].to_s # Save tXid in your database
164
+ puts "----------------------------------------------------------------------"
165
+
166
+ else response["resultCd"].to_s
167
+ # If error, you can redirect back to checkout page
168
+ # In this sample, we only puts error message
169
+ puts "\nOops! Virtual Account failed to generate! We have recorded the event. \nPlease try again later.\n\n"
170
+ puts "Result Code : " + response["resultCd"]
171
+ puts "Result Message : " + response["resultMsg"]
172
+ end
173
+
174
+
175
+ # Flush request parameter
176
+ Nicepay.flushParam
177
+ ```
178
+
179
+ #### Run `sample/test-va.rb`
180
+ ```
181
+ $ ruby sample/test-va.rb
182
+ ```
183
+
184
+ ```
185
+ ----------------------------------------------------------------------
186
+ Virtual Account Number : 7001400000000631
187
+ Description : Payment of Invoice-7834
188
+ Reference No : Invoice-7834
189
+ Transaction ID : VACCTCLOSE02201606061649584906
190
+ ----------------------------------------------------------------------
191
+ ```
192
+
193
+ ### Card Checkout
194
+
195
+ #### Sample Code `sample/test-card.rb`
196
+
197
+ ```
198
+ =begin
199
+ Nicepay Ruby Bindings
200
+ Virtual Account Sample Code
201
+ Have a Nicepay!
202
+ =end
203
+ require 'nicepay'
204
+
205
+ # Configuration
206
+
207
+ Nicepay.iMid=('IONPAYTEST')
208
+ Nicepay.merchantKey=('33F49GnCMS1mFYlGXisbUDzVf2ATWCl9k3R++d5hDd3Frmuos/XLx8XhXpe+LDYAbpGKZYSwtlyyLOtS/8aD7A==')
209
+ Nicepay.dbProcessUrl=('http://httpresponder.com/nicepay')
210
+ Nicepay.callBackUrl=('http://www.example.com/')
211
+
212
+ # API Operation
213
+ chargeCard = Nicepay::Api::ChargeCard.new(Nicepay.requestParam)
214
+
215
+ # Set Request Parameter for Card Payment
216
+
217
+ # Merchant Id
218
+ Nicepay.setRequestParam('iMid', Nicepay.iMid)
219
+
220
+ # Card -> payMethod = 01
221
+ Nicepay.setRequestParam('payMethod', '01')
222
+
223
+ # No Installment - Do not use installment feature before get rights from bank
224
+ Nicepay.setRequestParam('instmntMon', '1')
225
+ Nicepay.setRequestParam('instmntType', '1')
226
+
227
+ # Reference Number / Order Number / Invoice Number, generated by merchant
228
+ Nicepay.setRequestParam('referenceNo','Invoice-7833')
229
+
230
+ # Transaction Description
231
+ Nicepay.setRequestParam('description','Payment of ' + Nicepay.param('referenceNo')) # Description
232
+ Nicepay.setRequestParam('goodsNm', Nicepay.param('description')) # goodsNm = Description
233
+
234
+ # Add cart information mandatory at least one cart data
235
+ # Nicepay.addCart('image_location','product_name','product_description', 'sub_total_amount')
236
+ Nicepay.addCart('https://www.nicepay.co.id/nicepay/images/cart.png', 'Glasses', 'Jumlah: 3', 1000)
237
+ Nicepay.addCart('https://www.nicepay.co.id/nicepay/images/cart.png', 'Glasses', 'Jumlah: 1', 2000)
238
+ Nicepay.addCart('https://www.nicepay.co.id/nicepay/images/cart.png', 'Discount', 'Jumlah: 50%', -1500)
239
+ # Set cartData as request parameter
240
+ Nicepay.setRequestParam('cartData', Nicepay.cartData)
241
+ # Total Amount -> auto count from cartData
242
+ Nicepay.setRequestParam('amt', Nicepay.autoCountTotal)
243
+
244
+ # Currency -> Indonesian Rupiah
245
+ Nicepay.setRequestParam('currency', 'IDR')
246
+
247
+ # Set customer information
248
+ Nicepay.setRequestParam('billingNm', 'John Doe')
249
+ Nicepay.setRequestParam('billingPhone', '02112341234')
250
+ Nicepay.setRequestParam('billingEmail', 'john.doe@example.com')
251
+ Nicepay.setRequestParam('billingAddr', 'Jl. Jend Sudirman')
252
+ Nicepay.setRequestParam('billingCity', 'Jakarta Pusat')
253
+ Nicepay.setRequestParam('billingState', 'DKI Jakarta')
254
+ Nicepay.setRequestParam('billingPostCd', '10210')
255
+ Nicepay.setRequestParam('billingCountry', 'Indonesia')
256
+
257
+ Nicepay.setRequestParam('deliveryNm', 'John Doe')
258
+ Nicepay.setRequestParam('deliveryPhone', '02112341234')
259
+ Nicepay.setRequestParam('deliveryEmail', 'john.doe@example.com')
260
+ Nicepay.setRequestParam('deliveryAddr', 'Jl. Jend Sudirman')
261
+ Nicepay.setRequestParam('deliveryCity', 'Jakarta Pusat')
262
+ Nicepay.setRequestParam('deliveryState', 'DKI Jakarta')
263
+ Nicepay.setRequestParam('deliveryPostCd', '10210')
264
+ Nicepay.setRequestParam('deliveryCountry', 'Indonesia')
265
+
266
+ # Set User Customer IP
267
+ Nicepay.setRequestParam('userIP', Nicepay.userIp)
268
+
269
+ # Set dbProcessUrl (Notification Handler / Web Hook URL)
270
+ Nicepay.setRequestParam('dbProcessUrl', Nicepay.dbProcessUrl)
271
+
272
+ # Set callbackUrl (Redirection page after payment URL)
273
+ Nicepay.setRequestParam('callBackUrl', Nicepay.callBackUrl)
274
+
275
+ # Set vat, fee & noTaxAmt -> reserved for future feature, only set 0 for now
276
+ Nicepay.setRequestParam('vat', 0)
277
+ Nicepay.setRequestParam('fee', 0)
278
+ Nicepay.setRequestParam('notaxAmt', 0)
279
+
280
+ # Merchant Token
281
+ Nicepay.setRequestParam('merchantToken', Nicepay.merchantToken)
282
+
283
+ # If you want to dump POST parameters and review it
284
+ # puts Nicepay.dumpParameters
285
+ # abort("Exit")
286
+
287
+ # Inspect Response
288
+ # puts chargeCard.response.inspect
289
+
290
+ response = chargeCard.response
291
+
292
+ # Inspect response
293
+ # puts response
294
+
295
+ # If success, redirect to payment page
296
+ if response["resultCd"].to_s == "0000"
297
+ puts "\n"
298
+ puts "-----------------------------------------------------------------------------------------------------"
299
+ puts "Redirect Customer to : " + response["requestURL"].to_s + "?tXid=" + response["tXid"].to_s
300
+ puts "tXid : " + response["tXid"].to_s # Save tXid in your database
301
+ puts "-----------------------------------------------------------------------------------------------------"
302
+
303
+ else
304
+ # If error, you can redirect back to checkout page
305
+ # In this sample, we only puts error message
306
+ puts "\nOops! Payment Page failed to generate! We have recorded the event. \nPlease try again later.\n\n"
307
+ puts "Result Code : " + response["resultCd"]
308
+ puts "Result Message : " + response["resultMsg"]
309
+ end
310
+
311
+
312
+ # Flush request parameter
313
+ Nicepay.flushParam
314
+ ```
315
+
316
+ #### Run `sample/test-card.rb`
317
+
318
+ ```
319
+ $ ruby sample/test-card.rb
320
+ ```
321
+
322
+ ```
323
+ -----------------------------------------------------------------------------------------------------
324
+ Redirect Customer to : https://www.nicepay.co.id/nicepay/api/orderInquiry.do?tXid=IONPAYTEST01201606061651114907
325
+ tXid : IONPAYTEST01201606061651114907
326
+ -----------------------------------------------------------------------------------------------------
327
+ ```
328
+
329
+ ### Check Transaction Status
330
+
331
+ #### Sample Code `sample/test-status.rb`
332
+
333
+ ```
334
+ =begin
335
+ Nicepay Ruby Bindings
336
+ Virtual Account Sample Code
337
+ Have a Nicepay!
338
+ =end
339
+ require 'nicepay'
340
+
341
+ # Configuration
342
+
343
+ # MID
344
+ Nicepay.iMid=('VACCTCLOSE')
345
+ # Merchant Key
346
+ Nicepay.merchantKey=('33F49GnCMS1mFYlGXisbUDzVf2ATWCl9k3R++d5hDd3Frmuos/XLx8XhXpe+LDYAbpGKZYSwtlyyLOtS/8aD7A==')
347
+ # Webhook/Notification Handler URL
348
+ Nicepay.dbProcessUrl=('http://httpresponder.com/nicepay')
349
+ # Redirection URL after customer made payment in Nicepay Payment Page
350
+ Nicepay.callBackUrl=('http://www.example.com/')
351
+
352
+ # API Operation
353
+ checkStatus = Nicepay::Api::CheckStatus.new(Nicepay.requestParam)
354
+
355
+ # Set Request Parameter for Check Status
356
+
357
+ # Merchant Id
358
+ Nicepay.setRequestParam('iMid', Nicepay.iMid)
359
+
360
+ # Reference Number / Order Number / Invoice Number, generated by merchant
361
+ Nicepay.setRequestParam('referenceNo','Invoice-7834')
362
+
363
+ # Total Amount
364
+ Nicepay.setRequestParam('amt', '3000')
365
+
366
+ # Set VA expiry date -> 2 days from now
367
+ Nicepay.setRequestParam('tXid', 'VACCTCLOSE02201606061354204825')
368
+ # You can also set like this
369
+
370
+ # Merchant Token
371
+ Nicepay.setRequestParam('merchantToken', Nicepay.merchantTokenC)
372
+
373
+ # If you want to dump POST parameters and review it
374
+ # puts Nicepay.dumpParameters
375
+ # abort("Exit")
376
+
377
+ # Inspect Response
378
+ # puts requestVa.response.inspect
379
+
380
+ response = checkStatus.response
381
+
382
+ # Inspect response
383
+ # puts response.inspect
384
+
385
+ =begin
386
+ **=========================================================================================================
387
+ ** Credit Card
388
+ **=========================================================================================================
389
+ ** $paymentStatus->status == 0 // Success
390
+ ** $paymentStatus->status == 1 // Failed
391
+ ** $paymentStatus->status == 2 // Void or Refund
392
+ ** $paymentStatus->status == 9 // Initialization or Unpaid
393
+ **=========================================================================================================
394
+ *
395
+ **=========================================================================================================
396
+ ** Virtual Account
397
+ **=========================================================================================================
398
+ ** $paymentStatus->status == 0 // Paid
399
+ ** $paymentStatus->status == 3 // Unpaid
400
+ ** $paymentStatus->status == 4 // Expired
401
+ **=========================================================================================================
402
+ =end
403
+ # If success, show VA information to customer
404
+ if response["resultCd"].to_s == "0000"
405
+ puts "\n"
406
+ puts "----------------------------------------------------------------------"
407
+ puts "Transaction Status : " + response["status"].to_s
408
+ puts "Amount : " + response["amt"].to_s
409
+ puts "Reference No : " + response["referenceNo"].to_s
410
+ puts "Transaction ID : " + response["tXid"].to_s
411
+ puts "----------------------------------------------------------------------"
412
+
413
+ else
414
+ # If error, you can redirect back to checkout page
415
+ # In this sample, we only puts error message
416
+ puts "\nOops! Check Status failed to generate! We have recorded the event. \nPlease try again later.\n\n"
417
+ puts "Result Code : " + response["resultCd"]
418
+ puts "Result Message : " + response["resultMsg"]
419
+ end
420
+
421
+
422
+ # Flush request parameter
423
+ Nicepay.flushParam
424
+ ```
425
+
426
+ #### Run `sample/test-status.rb`
427
+
428
+ ```
429
+ $ ruby sample/test-status.rb
430
+ ```
431
+
432
+ ```
433
+ ----------------------------------------------------------------------
434
+ Transaction Status : 3
435
+ Amount : 3000
436
+ Reference No : Invoice-7834
437
+ Transaction ID : VACCTCLOSE02201606061354204825
438
+ ----------------------------------------------------------------------
439
+ ```
440
+
441
+ <!---
442
+ ## Ruby on Rails
443
+
444
+ ### Generate Controller
445
+
446
+ ```
447
+ $ rails generate controller checkout
448
+ ```
449
+
450
+ ```
451
+ create app/controllers/checkout_controller.rb
452
+ invoke erb
453
+ create app/views/checkout
454
+ invoke test_unit
455
+ create test/controllers/checkout_controller_test.rb
456
+ invoke helper
457
+ create app/helpers/checkout_helper.rb
458
+ invoke test_unit
459
+ invoke assets
460
+ invoke coffee
461
+ create app/assets/javascripts/checkout.coffee
462
+ invoke scss
463
+ create app/assets/stylesheets/checkout.scss
464
+ ```
465
+
466
+ ### Configure routes (config/routes.rb)
467
+
468
+ add following line
469
+ ```
470
+ resources :checkout
471
+ ```
472
+ !-->
473
+ ## Ruby on Rails
474
+
475
+ ```
476
+ Coming soon...
477
+ ```
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "nicepay"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nicepay"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -6,7 +6,6 @@
6
6
  require 'rubygems' if RUBY_VERSION < '1.9'
7
7
  require 'rest-client'
8
8
  require 'json'
9
- require 'digest'
10
9
  require "retries"
11
10
  require 'nicepay/api'
12
11
  require 'nicepay/version'
@@ -60,27 +59,22 @@ module Nicepay
60
59
 
61
60
  def self.callBackUrl=(callback_url)
62
61
  @callback_url = callback_url
63
- true
64
62
  end
65
63
 
66
64
  def self.dbProcessUrl=(db_process_url)
67
65
  @db_process_url = db_process_url
68
- true
69
66
  end
70
67
 
71
68
  def self.merchantKey=(merchant_key)
72
69
  @merchant_key = merchant_key
73
- true
74
70
  end
75
71
 
76
72
  def self.iMid=(i_mid)
77
73
  @i_mid = i_mid
78
- true
79
74
  end
80
75
 
81
76
  def self.setRequestParam(paramName, paramValue)
82
77
  self.requestParam[paramName] = paramValue
83
- true
84
78
  end
85
79
 
86
80
  def self.param(name)
@@ -125,7 +119,8 @@ module Nicepay
125
119
  end
126
120
 
127
121
  def self.flushParam
128
- @requestParam = nil
122
+ @cart = @cart.clear
123
+ @requestParam = @requestParam.clear
129
124
  end
130
125
 
131
126
  def self.dumpParameters
@@ -259,7 +259,6 @@ module Nicepay
259
259
  @parametersToCheck = Array[
260
260
  'iMid',
261
261
  'payMethod',
262
- # 'referenceNo',
263
262
  'amt',
264
263
  'tXid',
265
264
  'merchantToken',
@@ -1,3 +1,3 @@
1
1
  module Nicepay
2
- VERSION = "0.1.0"
3
- end
2
+ VERSION = "0.1.6"
3
+ end
@@ -1,47 +1,46 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'rubygems' if RUBY_VERSION < '1.9'
5
- require 'rest-client'
6
- require 'json'
7
- require 'digest'
8
- require "retries"
9
- require 'nicepay/api'
10
- require 'nicepay/version'
11
-
12
- Gem::Specification.new do |spec|
13
- spec.name = "nicepay"
14
- spec.version = Nicepay::VERSION
15
- spec.authors = ["Arif Budiman"]
16
- spec.email = ["arif.budiman@nicepay.co.id"]
17
- spec.required_ruby_version = '>= 1.9.3'
18
- spec.summary = 'Nicepay Ruby Bindings'
19
- spec.description = 'Nicepay Indonesia'
20
- spec.homepage = "http://nicepay.co.id"
21
- spec.license = "MIT"
22
-
23
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
24
- # delete this section to allow pushing this gem to any host.
25
- # if spec.respond_to?(:metadata)
26
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
27
- # else
28
- # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
29
- # end
30
-
31
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
- spec.bindir = "exe"
33
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
- spec.require_paths = ["lib"]
35
-
36
- spec.add_development_dependency "bundler", "~> 1.11"
37
- spec.add_development_dependency "rake", "~> 10.0"
38
- spec.add_development_dependency "rspec", "~> 3.0"
39
-
40
- # dependencies
41
- spec.add_dependency('rest-client', '~> 1.4')
42
- spec.add_dependency 'digest'
43
- spec.add_dependency 'json'
44
- spec.add_dependency 'retries'
45
- spec.add_dependency 'rubygems' if RUBY_VERSION < '1.9'
46
-
47
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rubygems' if RUBY_VERSION < '1.9'
5
+ require 'rest-client'
6
+ require 'json'
7
+ require 'digest'
8
+ require "retries"
9
+ require 'nicepay/api'
10
+ require 'nicepay/version'
11
+
12
+ Gem::Specification.new do |spec|
13
+ spec.name = "nicepay"
14
+ spec.version = Nicepay::VERSION
15
+ spec.authors = ["Arif Budiman"]
16
+ spec.email = ["arif.budiman@nicepay.co.id"]
17
+ spec.required_ruby_version = '>= 1.9.3'
18
+ spec.summary = 'Nicepay Ruby Bindings'
19
+ spec.description = 'Nicepay Indonesia'
20
+ spec.homepage = "http://nicepay.co.id"
21
+ spec.license = "MIT"
22
+
23
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
24
+ # delete this section to allow pushing this gem to any host.
25
+ # if spec.respond_to?(:metadata)
26
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
27
+ # else
28
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
29
+ # end
30
+
31
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 1.11"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rspec", "~> 3.0"
39
+
40
+ # dependencies
41
+ spec.add_dependency('rest-client', '~> 1.4')
42
+ spec.add_dependency('json', '~> 1.8.3')
43
+ spec.add_dependency('retries', '~> 0.0.5')
44
+ spec.add_dependency 'rubygems' if RUBY_VERSION < '1.9'
45
+
46
+ end
@@ -4,7 +4,7 @@
4
4
  Virtual Account Sample Code
5
5
  Have a Nicepay!
6
6
  =end
7
- require_relative 'lib/nicepay'
7
+ require 'nicepay'
8
8
 
9
9
  # Configuration
10
10
  # MID
@@ -4,7 +4,7 @@
4
4
  Virtual Account Sample Code
5
5
  Have a Nicepay!
6
6
  =end
7
- require_relative 'lib/nicepay'
7
+ require 'nicepay'
8
8
 
9
9
  # Configuration
10
10
 
@@ -4,7 +4,7 @@
4
4
  Virtual Account Sample Code
5
5
  Have a Nicepay!
6
6
  =end
7
- require_relative 'lib/nicepay'
7
+ require 'nicepay'
8
8
 
9
9
  # Configuration
10
10
 
@@ -4,8 +4,8 @@
4
4
  Virtual Account Sample Code
5
5
  Have a Nicepay!
6
6
  =end
7
- require_relative 'lib/nicepay'
8
-
7
+ require 'nicepay'
8
+ # require 'nicepay'
9
9
  # Configuration
10
10
 
11
11
  # MID
@@ -55,7 +55,7 @@ Nicepay.setRequestParam('cartData', Nicepay.cartData)
55
55
  Nicepay.setRequestParam('amt', Nicepay.autoCountTotal)
56
56
 
57
57
  # Currency -> Indonesian Rupiah
58
- Nicepay.setRequestParam('currency', 'IRD')
58
+ Nicepay.setRequestParam('currency', 'IDR')
59
59
 
60
60
  # Set customer information
61
61
  Nicepay.setRequestParam('billingNm', 'John Doe')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nicepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arif Budiman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-09 00:00:00.000000000 Z
11
+ date: 2020-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,48 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.4'
69
- - !ruby/object:Gem::Dependency
70
- name: digest
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: json
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: 1.8.3
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: 1.8.3
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: retries
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - ">="
87
+ - - "~>"
102
88
  - !ruby/object:Gem::Version
103
- version: '0'
89
+ version: 0.0.5
104
90
  type: :runtime
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - ">="
94
+ - - "~>"
109
95
  - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: 0.0.5
111
97
  description: Nicepay Indonesia
112
98
  email:
113
99
  - arif.budiman@nicepay.co.id
@@ -152,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
154
140
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.4.5.1
141
+ rubygems_version: 3.1.2
157
142
  signing_key:
158
143
  specification_version: 4
159
144
  summary: Nicepay Ruby Bindings