paygate-ruby 0.1.8 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +53 -38
- data/LICENSE.txt +21 -21
- data/README.md +327 -343
- data/Rakefile +3 -2
- data/data/cdbn.20230401.unl.xlsx +0 -0
- data/data/config.yml +3347 -2744
- data/lib/paygate/action_view/form_helper.rb +159 -0
- data/lib/paygate/aes.rb +152 -150
- data/lib/paygate/aes_ctr.rb +136 -133
- data/lib/paygate/configuration.rb +20 -16
- data/lib/paygate/member.rb +24 -21
- data/lib/paygate/profile.rb +33 -30
- data/lib/paygate/response.rb +27 -25
- data/lib/paygate/transaction.rb +60 -58
- data/lib/paygate/version.rb +5 -3
- data/lib/paygate-ruby.rb +3 -48
- data/lib/paygate.rb +43 -0
- data/vendor/assets/javascripts/paygate.js +86 -86
- metadata +17 -49
- data/.gitignore +0 -9
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -4
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/data/card_bin_20191001.xlsx +0 -0
- data/lib/paygate/helpers/form_helper.rb +0 -155
- data/paygate-ruby.gemspec +0 -24
data/README.md
CHANGED
@@ -1,343 +1,327 @@
|
|
1
|
-
# paygate-ruby
|
2
|
-
|
3
|
-
`paygate-ruby` is a simple Ruby wrapper for [PayGate payment gateway](http://www.paygate.net/)'s OpenPayAPI.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'paygate-ruby'
|
11
|
-
```
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
```
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
```slim
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
-
|
79
|
-
-
|
80
|
-
-
|
81
|
-
-
|
82
|
-
-
|
83
|
-
-
|
84
|
-
-
|
85
|
-
-
|
86
|
-
|
87
|
-
|
88
|
-
-
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
**
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
```
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
```
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
**
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
```
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
// This is called when a response is returned from
|
181
|
-
function
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
```
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
response
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
```
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
response.
|
269
|
-
=> :
|
270
|
-
|
271
|
-
response.
|
272
|
-
|
273
|
-
|
274
|
-
response.
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
```
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
response.
|
304
|
-
=> :
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
-
|
318
|
-
-
|
319
|
-
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
330
|
-
|
331
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
332
|
-
|
333
|
-
## Contributing
|
334
|
-
|
335
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/jagdeepsingh/paygate-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
336
|
-
|
337
|
-
## License
|
338
|
-
|
339
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
340
|
-
|
341
|
-
## Code of Conduct
|
342
|
-
|
343
|
-
Everyone interacting in the Paygate project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jagdeepsingh/paygate-ruby/blob/master/CODE_OF_CONDUCT.md).
|
1
|
+
# paygate-ruby
|
2
|
+
|
3
|
+
`paygate-ruby` is a simple Ruby wrapper for [PayGate Korean payment gateway](http://www.paygate.net/)'s OpenPayAPI.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'paygate-ruby'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
You can pass a block to the `configure` method to make changes to the `Paygate` configuration.
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
Paygate.configure do |config|
|
19
|
+
config.mode = :sandbox
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
Default value for `mode` is `:live`. It uses different API urls in different modes for making payments.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
To start making the transactions on PayGate, you will need a Member ID and a Secret,
|
28
|
+
for which you can register [here](https://admin.paygate.net/front/regist/registMember.jsp?lang=us).
|
29
|
+
|
30
|
+
After a successful registration, you will have access to the [dashboard](https://admin.paygate.net/front/board/welcome.jsp).
|
31
|
+
|
32
|
+
NOTE: Unless otherwise stated, all the following documentation is for making payments
|
33
|
+
with Korean local credit cards in currency 'WON'.
|
34
|
+
|
35
|
+
Contents:
|
36
|
+
- [1. Purchase](#1-purchase)
|
37
|
+
- [2. Verify](#2-verify)
|
38
|
+
- [3. Refund](#3-refund)
|
39
|
+
- [4. Profile Pay](#4-profile-pay)
|
40
|
+
- [5. JavaScript helpers](#5-javascript-helpers)
|
41
|
+
|
42
|
+
### 1. Purchase
|
43
|
+
|
44
|
+
#### 1.1. Include JavaScript
|
45
|
+
|
46
|
+
Include the _OpenPayAPI.js_ in `<head>` of your payment page.
|
47
|
+
|
48
|
+
```slim
|
49
|
+
= javascript_include_tag paygate_open_pay_api_js_url
|
50
|
+
```
|
51
|
+
|
52
|
+
#### 1.2 Payment form
|
53
|
+
|
54
|
+
Render the PayGate payment form in your view file.
|
55
|
+
|
56
|
+
```slim
|
57
|
+
= paygate_open_pay_api_form
|
58
|
+
```
|
59
|
+
|
60
|
+
You will see a form with all the necessary fields for making payment with a credit card. Some of the fields have default values set. You can also set the value and placeholder for almost all the fields while rendering the form. See example below:
|
61
|
+
|
62
|
+
```slim
|
63
|
+
/ payment.html.slim
|
64
|
+
= paygate_open_pay_api_form(\
|
65
|
+
mid: { value: 'testmid', placeholder: 'Merchant ID' },
|
66
|
+
currency: { value: 'USD' },
|
67
|
+
amount: { value: 2000 }\
|
68
|
+
)
|
69
|
+
```
|
70
|
+
|
71
|
+
Here is a list of all the form fields which you can set:
|
72
|
+
- mid
|
73
|
+
- locale (default: 'US')
|
74
|
+
- charset (default: 'UTF-8')
|
75
|
+
- title
|
76
|
+
- currency (default: 'WON')
|
77
|
+
- amount
|
78
|
+
- meta1, meta2, meta3, meta4, meta5
|
79
|
+
- pay_method (default: 'card')
|
80
|
+
- customer_name
|
81
|
+
- customer_email
|
82
|
+
- card_number
|
83
|
+
- expiry_year
|
84
|
+
- expiry_month
|
85
|
+
- cvv
|
86
|
+
|
87
|
+
The form also contains some fields which are filled after the response is returned by the API. They are:
|
88
|
+
- card_auth_code
|
89
|
+
- response_code
|
90
|
+
- response_message
|
91
|
+
- tid
|
92
|
+
- profile_no
|
93
|
+
- hash_result
|
94
|
+
|
95
|
+
Lets explore some of these fields more.
|
96
|
+
|
97
|
+
**mid**
|
98
|
+
|
99
|
+
You need to set your Member ID in this field.
|
100
|
+
|
101
|
+
If you have setup separate Member IDs for Korean and International cards, you can fill the value of `mid` accordingly. To know whether the credit card number entered by a customer is Korean or not, you can check the first 6 digits of card number to match Korean BIN numbers. Full list is available as `Paygate::KOREA_BIN_NUMBERS`.
|
102
|
+
|
103
|
+
**pay_method**
|
104
|
+
|
105
|
+
Value of `pay_method` for Korean cards should be set to "card" and for international cards, it should be "104".
|
106
|
+
|
107
|
+
**locale**
|
108
|
+
|
109
|
+
Use `Paygate.mapped_locale` to get the locale in correct format for the form input.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
Paygate.mapped_locale(:en)
|
113
|
+
#=> 'US'
|
114
|
+
|
115
|
+
Paygate.mapped_locale('ko')
|
116
|
+
#=> 'KR'
|
117
|
+
```
|
118
|
+
|
119
|
+
Valid inputs are "en", "en-US", "ko", "ko-KR", "ja", "zh-CN" and their symbolized versions. Passing `nil` would return default locale i.e. "US".
|
120
|
+
|
121
|
+
**currency**
|
122
|
+
|
123
|
+
Use `Paygate.mapped_currency` to get the currency in the correct format.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
Paygate.mapped_currency('USD')
|
127
|
+
#=> 'USD'
|
128
|
+
|
129
|
+
Paygate.mapped_currency('KRW')
|
130
|
+
#=> 'WON'
|
131
|
+
```
|
132
|
+
|
133
|
+
Passing `nil` above would return default currency i.e. "WON".
|
134
|
+
|
135
|
+
**amount**
|
136
|
+
|
137
|
+
You need to contact PayGate to know the correct amount for making a successful transaction in test mode.
|
138
|
+
|
139
|
+
Remember, in test mode too, PayGate makes real transactions and you need to `refund` them.
|
140
|
+
|
141
|
+
**meta1, meta2, meta3, meta4, meta5**
|
142
|
+
|
143
|
+
These fields can be used to pass any additional data to PayGate. If server-to-server callbacks are enabled, the gateway then sends all of these back when making a callback request to your server.
|
144
|
+
|
145
|
+
**tid**
|
146
|
+
|
147
|
+
For every transaction a `tid` is created by PayGate JS before making a request to the API.
|
148
|
+
|
149
|
+
**response_code**
|
150
|
+
|
151
|
+
This is filled automatically by PayGate JS when response is returned. A `response_code` of "0000" means successful transaction.
|
152
|
+
|
153
|
+
**response_message**
|
154
|
+
|
155
|
+
In case of failure, you can see the error message returned by the API here.
|
156
|
+
|
157
|
+
**profile_no**
|
158
|
+
|
159
|
+
If Profile Payment Service is enabled on your Member ID, then you will get a subscription ID for customer in this field. You can use this `profile_no` to make payments for the same customer in future.
|
160
|
+
|
161
|
+
#### 1.3. Response screen
|
162
|
+
|
163
|
+
You also need to add a screen at the same HTML level as above form. OpenPayAPI popups for further authentication as well as the response from the API is displayed in this screen.
|
164
|
+
|
165
|
+
```slim
|
166
|
+
= paygate_open_pay_api_screen
|
167
|
+
```
|
168
|
+
|
169
|
+
#### 1.4. JavaScript callback
|
170
|
+
|
171
|
+
You also need to implement a few callbacks to handle the API response. Add these to your JavaScript.
|
172
|
+
|
173
|
+
```js
|
174
|
+
// This is called when a response is returned from PayGate API
|
175
|
+
function getPGIOresult() {
|
176
|
+
displayStatus(getPGIOElement('ResultScreen'));
|
177
|
+
verifyReceived(getPGIOElement('tid'), 'callbacksuccess', 'callbackfail');
|
178
|
+
}
|
179
|
+
|
180
|
+
// This is called when a response (success/failure) is returned from the API
|
181
|
+
function callbacksuccess() {
|
182
|
+
var replycode = getPGIOElement('replycode');
|
183
|
+
|
184
|
+
if (replycode == '0000') {
|
185
|
+
alert('Payment was successful');
|
186
|
+
} else {
|
187
|
+
alert('Payment failed with code: ' + replycode);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
// This is called when there is a system error
|
192
|
+
function callbackfail() {
|
193
|
+
alert('System error. Please try again.');
|
194
|
+
}
|
195
|
+
```
|
196
|
+
|
197
|
+
#### 1.5. Submit the form
|
198
|
+
|
199
|
+
Now finally, lets add an event to make a call to OpenPayAPI on submit of the form. If you are using jQuery, you can do it as follows:
|
200
|
+
|
201
|
+
```js
|
202
|
+
$('form[name="PGIOForm"]').on('submit', function(event){
|
203
|
+
event.preventDefault();
|
204
|
+
doTransaction(document.PGIOForm);
|
205
|
+
})
|
206
|
+
```
|
207
|
+
|
208
|
+
And, your payment form is all set to make payments.
|
209
|
+
|
210
|
+
### 2. Verify
|
211
|
+
|
212
|
+
If enabled, PayGate will send a server-to-server callback on every successful transaction to the URL provided by you. The same request is sent every 5 minutes (for 10 days) until your server responds with success.
|
213
|
+
|
214
|
+
This feature can be helpful if your JavaScript failed to receive the message from PayGate after a successful payment due to network issues.
|
215
|
+
|
216
|
+
So, once you receive a successful JavaScript callback (`replycode == '0000'`), to prevent PayGate from sending any callback requests for that transaction (`tid`), you need to make a verification request as follows:
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
txn = Paygate::Transaction.new('testmid_123456.654321')
|
220
|
+
response = txn.verify
|
221
|
+
#=> #<Paygate::Response:0x007fd4898f14b0 ... >
|
222
|
+
|
223
|
+
response.transaction_type
|
224
|
+
#=> :verify
|
225
|
+
|
226
|
+
response.http_code
|
227
|
+
#=> "200"
|
228
|
+
```
|
229
|
+
|
230
|
+
Here, _testmid_123456.654321_ is `tid` of the transaction you want to verify.
|
231
|
+
|
232
|
+
### 3. Refund
|
233
|
+
|
234
|
+
Initialize a `Paygate::Member` instance using the Member ID and Secret you have.
|
235
|
+
|
236
|
+
```ruby
|
237
|
+
member = Paygate::Member.new('testmid', 'secret')
|
238
|
+
#=> #<Paygate::Member:0x007f96bdb70f38 @mid="testmid", @secret="secret">
|
239
|
+
```
|
240
|
+
|
241
|
+
`member` responds to methods `mid`, and `secret`.
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
member.mid
|
245
|
+
#=> "testmid"
|
246
|
+
|
247
|
+
member.secret
|
248
|
+
#=> "secret"
|
249
|
+
```
|
250
|
+
|
251
|
+
#### 3.1. Full refund
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
response = member.refund_transaction('testmid_123456.654321')
|
255
|
+
#=> #<Paygate::Response:0x007fbf3d111940 @transaction_type=:refund, @http_code="200", @message="OK", @body="callback({\"replyCode\":\"0000\",\"replyMessage\":\"Response has been completed\",\"content\":{\"object\":\"CancelAPI tid:testmid_123456.654321 SUCCESS payRsltCode:0000\"}})", @json={"replyCode"=>"0000", "replyMessage"=>"Response has been completed", "content"=>{"object"=>"CancelAPI tid:testmid_123456.654321 SUCCESS payRsltCode:0000"}}, @raw_info=
|
256
|
+
#<OpenStruct tid="testmid_123456.654321", tid_enc="AES256XQIdNnkzFwMQmhF7fuJhS3m0\n", request_url="https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=F">>
|
257
|
+
```
|
258
|
+
|
259
|
+
`response` provides some helpful accessor methods too.
|
260
|
+
|
261
|
+
```ruby
|
262
|
+
response.transaction_type
|
263
|
+
#=> :refund
|
264
|
+
|
265
|
+
response.http_code
|
266
|
+
#=> "200"
|
267
|
+
|
268
|
+
response.json
|
269
|
+
#=> {"replyCode"=>"0000", "replyMessage"=>"Response has been completed", "content"=>{"object"=>"CancelAPI tid:testmid_123456.654321 SUCCESS payRsltCode:0000"}}
|
270
|
+
|
271
|
+
response.raw_info
|
272
|
+
#=> #<OpenStruct tid="testmid_123456.654321", tid_enc="AES256XQIdNnkzFwMQmhF7fuJhS3m0\n", request_url="https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=F">
|
273
|
+
|
274
|
+
response.raw_info.request_url
|
275
|
+
#=> "https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=F"
|
276
|
+
```
|
277
|
+
|
278
|
+
Apart from these it also responds to `message` and `body`.
|
279
|
+
|
280
|
+
#### 3.2. Partial refund
|
281
|
+
|
282
|
+
For partial refunds, you need to pass `amount` as an option to `refund_transaction` method along with other options.
|
283
|
+
|
284
|
+
```ruby
|
285
|
+
response = member.refund_transaction('testmid_123456.654321',
|
286
|
+
amount: 1000,
|
287
|
+
order_id: 'ord10001')
|
288
|
+
```
|
289
|
+
|
290
|
+
### 4. Profile Pay
|
291
|
+
|
292
|
+
You can use the `profile_no` returned from the OpenPayAPI after first payment by a customer to make future payments for him.
|
293
|
+
|
294
|
+
```ruby
|
295
|
+
response = member.profile_pay('profile_1234567890', 'WON', 1000)
|
296
|
+
|
297
|
+
response.transaction_type
|
298
|
+
#=> :profile_pay
|
299
|
+
|
300
|
+
response.http_code
|
301
|
+
#=> "200"
|
302
|
+
|
303
|
+
response.json
|
304
|
+
#=> {"validecode"=>"00", "authcode"=>"12345678", "authdt"=>"20171120165728", "cardname"=>"BC \x00\x00\x00\x00", "cardnumber"=>"411111**********", "cardtype"=>"301310", "cardquota"=>"00", "cardexpiremonth"=>"11", "cardexpireyear"=>"2020", "merchantno"=>"12345678", "m_tid"=>nil, "paymethodname"=>"CARD_BASIC", "ReplyMsg"=>"\xBA\xBA\xBC\xBD\xC1\xC2\xC3\xC4 OK: 12345678", "ReplyCode"=>"0000", "receipttoname"=>"Test name\xC1\xD1\xB1\xB1\xC1\xA1", "receipttoemail"=>"dev@paygate.net", "subtotalprice"=>"1000", "transactionid"=>"testmid_123456.654321", "hashresult"=>"db1fdc6789cc8d088172b79ca680b3af8711e9fb32", "mb_serial_no"=>"\r\n"}
|
305
|
+
```
|
306
|
+
|
307
|
+
### 5. JavaScript helpers
|
308
|
+
|
309
|
+
`paygate-ruby` also provides a JavaScript class `Paygate` with some helper functions that can be used in your JavaScript e.g.
|
310
|
+
|
311
|
+
- _openPayApiForm_ - Returns the payment form
|
312
|
+
- _openPayApiScreen_ - Returns the screen for paygate API response
|
313
|
+
- _findInputByName_ - Find an input field in payment form by name. Pass the _camelCased_ form of field names from section 1.2 above as arguments.
|
314
|
+
- _responseCode_
|
315
|
+
- _responseMessage_
|
316
|
+
- _tid_
|
317
|
+
- _profileNo_
|
318
|
+
- _fillInput_ - Accepts input name (_camelCased_) and a value to set
|
319
|
+
- _submitForm_ - Makes a call to PayGate API with the payment form inputs
|
320
|
+
|
321
|
+
## Contributing
|
322
|
+
|
323
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tablecheck/paygate-ruby.
|
324
|
+
|
325
|
+
## License
|
326
|
+
|
327
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|