nicepay 0.1.4 → 0.1.6
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.
- checksums.yaml +5 -5
- data/.gitignore +9 -9
- data/.rspec +2 -2
- data/.travis.yml +12 -12
- data/Gemfile +3 -3
- data/LICENSE.txt +21 -21
- data/README.md +477 -477
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/lib/nicepay/version.rb +3 -3
- data/nicepay.gemspec +46 -46
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c9ab9063304258a2826b812e22c2f6d997dc8d606b74a4da6d0e7468ab5c700f
|
4
|
+
data.tar.gz: c4db553ac7ded7eb4f7546910bc0aac4a7ec05d821ce9d442d4ddad7f1a87b36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/.travis.yml
CHANGED
@@ -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
|
data/LICENSE.txt
CHANGED
@@ -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,477 +1,477 @@
|
|
1
|
-
# NICEPay Ruby Bindings
|
2
|
-
|
3
|
-
```
|
4
|
-
NICEPAY ♥ Ruby
|
5
|
-
```
|
6
|
-
|
7
|
-
## Payment Flow
|
8
|
-
|
9
|
-
### Credit Card
|
10
|
-
|
11
|
-

|
12
|
-
|
13
|
-
### Virtual Account
|
14
|
-
|
15
|
-

|
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.
|
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
|
-
```
|
1
|
+
# NICEPay Ruby Bindings
|
2
|
+
|
3
|
+
```
|
4
|
+
NICEPAY ♥ Ruby
|
5
|
+
```
|
6
|
+
|
7
|
+
## Payment Flow
|
8
|
+
|
9
|
+
### Credit Card
|
10
|
+
|
11
|
+

|
12
|
+
|
13
|
+
### Virtual Account
|
14
|
+
|
15
|
+

|
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
|
+
```
|