paygate-ruby 0.1.6 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,316 +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
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install paygate-ruby
20
-
21
- ## Configuration
22
-
23
- You can pass a block to the `configure` method to make changes to the `Paygate` configuration.
24
-
25
- ```ruby
26
- Paygate.configure do |config|
27
- config.mode = :sandbox
28
- end
29
- ```
30
-
31
- Default value for `mode` is `:live`. It uses different API urls in different modes for making payments.
32
-
33
- ## Usage
34
-
35
- To start making the transactions on PayGate, you will need a Member ID and a Secret, for which you can register [here](https://admin.paygate.net/front/regist/registMember.jsp?lang=us).
36
-
37
- After a successful registration, you will have access to the [dashboard](https://admin.paygate.net/front/board/welcome.jsp).
38
-
39
- NOTE: Unless otherwise stated, all the following documentation is for making payments with Korean local credit cards in currency 'WON'.
40
-
41
- Contents:
42
- - [1 Purchase](#1-purchase)
43
- - [2 Refund](#2-refund)
44
- - [3 Profile Pay](#3-profile-pay)
45
-
46
- ### 1 Purchase
47
-
48
- #### 1.1 Include javascript
49
-
50
- Include the _OpenPayAPI.js_ in `<head>` of your payment page.
51
-
52
- ```slim
53
- = javascript_include_tag paygate_open_pay_api_js_url
54
- ```
55
-
56
- #### 1.2 Payment form
57
-
58
- Render the PayGate payment form in your view file.
59
-
60
- ```slim
61
- = paygate_open_pay_api_form
62
- ```
63
-
64
- 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:
65
-
66
- ```slim
67
- / payment.html.slim
68
- = paygate_open_pay_api_form(\
69
- mid: { value: 'testmid', placeholder: 'Merchant ID' },
70
- currency: { value: 'USD' },
71
- amount: { value: 2000 }\
72
- )
73
- ```
74
-
75
- Here is a list of all the form fields which you can set:
76
- - mid
77
- - locale (default: 'US')
78
- - charset (default: 'UTF-8')
79
- - title
80
- - currency (default: 'WON')
81
- - amount
82
- - pay_method (default: 'card')
83
- - customer_name
84
- - customer_email
85
- - card_number
86
- - expiry_year
87
- - expiry_month
88
- - cvv
89
-
90
- The form also contains some fields which will are filled after the response is returned by the API. They are:
91
- - card_auth_code
92
- - response_code
93
- - response_message
94
- - tid
95
- - profile_no
96
- - hash_result
97
-
98
- Lets explore some of these fields more.
99
-
100
- **mid**
101
-
102
- You need to set your Member ID in this field.
103
-
104
- 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`.
105
-
106
- **pay_method**
107
-
108
- Value of `pay_method` for Korean cards should be set to "card" and for international cards, it should be "104".
109
-
110
- **locale**
111
-
112
- Use `Paygate.mapped_locale` to get the locale in correct format for the form input.
113
-
114
- ```ruby
115
- Paygate.mapped_locale(:en)
116
- => 'US'
117
-
118
- Paygate.mapped_locale('ko')
119
- => 'KR'
120
- ```
121
-
122
- 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".
123
-
124
- **currency**
125
-
126
- Use `Paygate.mapped_currency` to get the currency in the correct format.
127
-
128
- ```ruby
129
- Paygate.mapped_currency('USD')
130
- => 'USD'
131
-
132
- Paygate.mapped_currency('KRW')
133
- => 'WON'
134
- ```
135
-
136
- Passing `nil` above would return default currency i.e. "WON".
137
-
138
- **amount**
139
-
140
- You need to contact PayGate to know the correct amount for making a successful transaction in test mode.
141
-
142
- Remember, in test mode too, PayGate makes real transactions and you need to `refund` them.
143
-
144
- **tid**
145
-
146
- For every transaction a `tid` is created by PayGate JS before making a request to the API.
147
-
148
- **response_code**
149
-
150
- This is filled automatically by PayGate JS when response is returned. A `response_code` of "0000" means successful transaction.
151
-
152
- **response_message**
153
-
154
- In case of failure, you can see the error message returned by the API here.
155
-
156
- **profile_no**
157
-
158
- 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.
159
-
160
- #### 1.3 Response screen
161
-
162
- 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.
163
-
164
- ```slim
165
- = paygate_open_pay_api_screen
166
- ```
167
-
168
- #### 1.4 Callbacks
169
-
170
- You also need to implement a few callbacks to handle the API response. Add these to your Javascript.
171
-
172
- ```js
173
- // This is called when a response is returned from PayGate API
174
- function getPGIOresult() {
175
- displayStatus(getPGIOElement('ResultScreen'));
176
- verifyReceived(getPGIOElement('tid'), 'callbacksuccess', 'callbackfail');
177
- }
178
-
179
- // This is called when a response (success/failure) is returned from the API
180
- function callbacksuccess() {
181
- var replycode = getPGIOElement('replycode');
182
-
183
- if (replycode == '0000') {
184
- alert('Payment was successful');
185
- } else {
186
- alert('Payment failed with code: ' + replycode);
187
- }
188
- }
189
-
190
- // This is called when there is a system error
191
- function callbackfail() {
192
- alert('System error. Please try again.');
193
- }
194
- ```
195
-
196
- #### 1.5 Submit the form
197
-
198
- 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:
199
-
200
- ```js
201
- $('form[name="PGIOForm"]').on('submit', function(event){
202
- event.preventDefault();
203
- doTransaction(document.PGIOForm);
204
- })
205
- ```
206
-
207
- And, your payment form is all set to make payments.
208
-
209
- ### 2 Refund
210
-
211
- Initialize a `Paygate::Member` instance using the Member ID and Secret you have.
212
-
213
- ```ruby
214
- member = Paygate::Member.new('testmid', 'secret')
215
- => #<Paygate::Member:0x007f96bdb70f38 @mid="testmid", @secret="secret">
216
- ```
217
-
218
- `member` responds to methods `mid`, and `secret`.
219
-
220
- ```ruby
221
- member.mid
222
- => "testmid"
223
-
224
- member.secret
225
- => "secret"
226
- ```
227
-
228
- #### 2.1 Full refund
229
-
230
- ```ruby
231
- response = member.refund_transaction('testmid_123456.654321')
232
- => #<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=
233
- #<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">>
234
- ```
235
-
236
- Here, _testmid_123456.654321_ is `tid` of the transaction you want to refund.
237
-
238
- `response` provides some helpful accessor methods too.
239
-
240
- ```ruby
241
- response.transaction_type
242
- => :refund
243
-
244
- response.http_code
245
- => "200"
246
-
247
- response.json
248
- => {"replyCode"=>"0000", "replyMessage"=>"Response has been completed", "content"=>{"object"=>"CancelAPI tid:testmid_123456.654321 SUCCESS payRsltCode:0000"}}
249
-
250
- response.raw_info
251
- => #<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">
252
-
253
- response.raw_info.request_url
254
- => "https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=F"
255
- ```
256
-
257
- Apart from these it also responds to `message` and `body`.
258
-
259
- #### 2.2 Partial refund
260
-
261
- For partial refunds, you need to pass `amount` as an option to `refund_transaction` method along with other options.
262
-
263
- ```ruby
264
- response = member.refund_transaction('testmid_123456.654321',
265
- amount: 1000,
266
- order_id: 'ord10001')
267
- ```
268
-
269
- ### 3 Profile Pay
270
-
271
- You can use the `profile_no` returned from the OpenPayAPI after first payment by a customer to make future payments for him.
272
-
273
- ```ruby
274
- response = member.profile_pay('profile_1234567890', 'WON', 1000)
275
-
276
- response.transaction_type
277
- => :profile_pay
278
-
279
- response.http_code
280
- => "200"
281
-
282
- response.json
283
- => {"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"}
284
- ```
285
-
286
- ### 4 Javascript helpers
287
-
288
- `paygate-ruby` also provides a Javascript class `Paygate` with some helper functions that can be used in your Javascript e.g.
289
-
290
- - _openPayApiForm_ - Returns the payment form
291
- - _openPayApiScreen_ - Returns the screen for paygate API response
292
- - _findInputByName_ - Find an input field in payment form by name. Pass the _camelCased_ form of field names from section 1.2 above as arguments.
293
- - _responseCode_
294
- - _responseMessage_
295
- - _tid_
296
- - _profileNo_
297
- - _fillInput_ - Accepts input name (_camelCased_) and a value to set
298
- - _submitForm_ - Makes a call to PayGate API with the payment form inputs
299
-
300
- ## Development
301
-
302
- 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.
303
-
304
- 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).
305
-
306
- ## Contributing
307
-
308
- 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.
309
-
310
- ## License
311
-
312
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
313
-
314
- ## Code of Conduct
315
-
316
- 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).