nicepay 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +401 -8
  3. data/lib/nicepay/version.rb +2 -2
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fe1757a33df554a4ce88d639078e024c95df1508
4
- data.tar.gz: d053f10a1ea55c7043ec758fe8ff685af4b8b153
3
+ metadata.gz: 0cfe49864ffbf37e3d60178a7ba8ae2dc3703c42
4
+ data.tar.gz: fb02d6bc04d6da8bd9a2633d4fe199dc61171654
5
5
  SHA512:
6
- metadata.gz: 3dbee5e40daac7384681f872c6885581186ea4c058b49e3929f3b7cf8dec53794196d3851054b687abb01f1b6886031553b23eb8c72de988d1f87392acf5de02
7
- data.tar.gz: 74f74d6dd41e5757c00438bee79c60cd0d2c281ae0f0170ccd3843cfaa5529c21a176a6e5b865e4468dfc63d6dd98a03a8adc5fa0200f330eada94d23807c21e
6
+ metadata.gz: b9814e4401a4cbc63e9ad1f54aef9c2c71155783b4a94114e4018ccecc954b65fc0994ee0b14652feff6ebbe77bc884b4a6ed7b0d0841e8c0aee7375b8d7eceb
7
+ data.tar.gz: d9d49941bc613767c8176294ea5eb79ace4e8135290ab51ebe643b8bb47f93851d41f3109f5936ef63e75b43f033a04a3d3197190bebbcd18c81110739b6eda0
data/README.md CHANGED
@@ -1,9 +1,182 @@
1
1
  # NICEPay Ruby Bindings
2
2
 
3
- ## Ruby SDK API Operation Test
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")
4
12
 
5
13
  ### Virtual Account
6
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 -v 0.0.1
23
+ ```
24
+
25
+ ### Add Nicepay Gem into GEMFILE
26
+
27
+ add following line
28
+ ```
29
+ gem 'nicepay', '~> 0.1.3'
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`
7
180
  ```
8
181
  $ ruby sample/test-va.rb
9
182
  ```
@@ -19,6 +192,129 @@ Transaction ID : VACCTCLOSE02201606061649584906
19
192
 
20
193
  ### Card Checkout
21
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
+
22
318
  ```
23
319
  $ ruby sample/test-card.rb
24
320
  ```
@@ -32,6 +328,103 @@ tXid : IONPAYTEST01201606061651114907
32
328
 
33
329
  ### Check Transaction Status
34
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
+
35
428
  ```
36
429
  $ ruby sample/test-status.rb
37
430
  ```
@@ -45,15 +438,9 @@ Transaction ID : VACCTCLOSE02201606061354204825
45
438
  ----------------------------------------------------------------------
46
439
  ```
47
440
 
441
+ <!---
48
442
  ## Ruby on Rails
49
443
 
50
- ### Add gem into Gemlock
51
-
52
- add following line
53
- ```
54
- gem 'nicepay', '~> 0.1.1'
55
- ```
56
-
57
444
  ### Generate Controller
58
445
 
59
446
  ```
@@ -82,3 +469,9 @@ add following line
82
469
  ```
83
470
  resources :checkout
84
471
  ```
472
+ !-->
473
+ ## Ruby on Rails
474
+
475
+ ```
476
+ Coming soon...
477
+ ```
@@ -1,3 +1,3 @@
1
1
  module Nicepay
2
- VERSION = "0.1.3"
3
- end
2
+ VERSION = "0.1.4"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nicepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arif Budiman