paygate-ruby 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 142282ed7e106d032ccd9921f5261c9723d95181412b7cacdb958f779143bfb1
4
- data.tar.gz: 6ed8ea42004d28b3b95f3c19ad016660066cfefefe3b40dd832f19ee241ff543
3
+ metadata.gz: 21f6f2a0afbfa035e89f89c04e8f062b54483e3df2867f7b8e2aa29ec8c435f5
4
+ data.tar.gz: 875791a118652b891ff33f31ed0c8756c87857aecc468d000d69c956ccbe71f2
5
5
  SHA512:
6
- metadata.gz: 79a67919970e5bf06fb6e2ed38fbcc8c6a4bf5f76b54e8c12e2fa1e6b7d5f009ce3aacaceab0889044a586bdb7c60b2a129d12ad79aa746c29462fc210c25abe
7
- data.tar.gz: 79117c3dfa0279ba50f129842520a2971731e2d667cde24882517e45dfc9eb58d00620cd467f91b257d7afb8249b780113311ca13d52fa228593362de6e0210e
6
+ metadata.gz: 45186cfc205d6649c9ed40dee2796d1a9e0c8c42be3a6174d3ad3bc865133029cf988ef24aa038debef2aae00550620c4d5a363b0f236fe1007b3f4d1183de59
7
+ data.tar.gz: f19f08405e3b1f003e1057fd4b8b36c30458aa6abee8cf84bc009ef225cf4a0706e9b5558b28aad13871efc3603ab96716a69e8b0890cdb2d5388d814f315ee6
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Next
4
4
 
5
+ ## 0.1.8 - 2020-02-11
6
+
7
+ - [PR#5](https://github.com/jagdeepsingh/paygate-ruby/pull/5) Add `verify` method to Transaction class and more meta fields to the payment form. ([jagdeepsingh](https://github.com/jagdeepsingh))
8
+
5
9
  ## 0.1.7 - 2019-11-01
6
10
 
7
11
  - [PR#4](https://github.com/jagdeepsingh/paygate-ruby/pull/4) Update BIN numbers for Korean domestic cards (Oct 2019). ([jagdeepsingh](https://github.com/jagdeepsingh))
data/README.md CHANGED
@@ -40,12 +40,14 @@ NOTE: Unless otherwise stated, all the following documentation is for making pay
40
40
 
41
41
  Contents:
42
42
  - [1 Purchase](#1-purchase)
43
- - [2 Refund](#2-refund)
44
- - [3 Profile Pay](#3-profile-pay)
43
+ - [2 Verify](#2-verify)
44
+ - [3 Refund](#3-refund)
45
+ - [4 Profile Pay](#4-profile-pay)
46
+ - [5 JavaScript helpers](#5-javascript-helpers)
45
47
 
46
48
  ### 1 Purchase
47
49
 
48
- #### 1.1 Include javascript
50
+ #### 1.1 Include JavaScript
49
51
 
50
52
  Include the _OpenPayAPI.js_ in `<head>` of your payment page.
51
53
 
@@ -79,6 +81,7 @@ Here is a list of all the form fields which you can set:
79
81
  - title
80
82
  - currency (default: 'WON')
81
83
  - amount
84
+ - meta1, meta2, meta3, meta4, meta5
82
85
  - pay_method (default: 'card')
83
86
  - customer_name
84
87
  - customer_email
@@ -87,7 +90,7 @@ Here is a list of all the form fields which you can set:
87
90
  - expiry_month
88
91
  - cvv
89
92
 
90
- The form also contains some fields which will are filled after the response is returned by the API. They are:
93
+ The form also contains some fields which are filled after the response is returned by the API. They are:
91
94
  - card_auth_code
92
95
  - response_code
93
96
  - response_message
@@ -141,6 +144,10 @@ You need to contact PayGate to know the correct amount for making a successful t
141
144
 
142
145
  Remember, in test mode too, PayGate makes real transactions and you need to `refund` them.
143
146
 
147
+ **meta1, meta2, meta3, meta4, meta5**
148
+
149
+ 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.
150
+
144
151
  **tid**
145
152
 
146
153
  For every transaction a `tid` is created by PayGate JS before making a request to the API.
@@ -165,9 +172,9 @@ You also need to add a screen at the same HTML level as above form. OpenPayAPI p
165
172
  = paygate_open_pay_api_screen
166
173
  ```
167
174
 
168
- #### 1.4 Callbacks
175
+ #### 1.4 JavaScript callback
169
176
 
170
- You also need to implement a few callbacks to handle the API response. Add these to your Javascript.
177
+ You also need to implement a few callbacks to handle the API response. Add these to your JavaScript.
171
178
 
172
179
  ```js
173
180
  // This is called when a response is returned from PayGate API
@@ -206,7 +213,29 @@ $('form[name="PGIOForm"]').on('submit', function(event){
206
213
 
207
214
  And, your payment form is all set to make payments.
208
215
 
209
- ### 2 Refund
216
+ ### 2 Verify
217
+
218
+ 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.
219
+
220
+ This feature can be helpful if your JavaScript failed to receive the message from PayGate after a successful payment due to network issues.
221
+
222
+ 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:
223
+
224
+ ```ruby
225
+ txn = Paygate::Transaction.new('testmid_123456.654321')
226
+ response = txn.verify
227
+ => #<Paygate::Response:0x007fd4898f14b0 ... >
228
+
229
+ response.transaction_type
230
+ => :verify
231
+
232
+ response.http_code
233
+ => "200"
234
+ ```
235
+
236
+ Here, _testmid_123456.654321_ is `tid` of the transaction you want to verify.
237
+
238
+ ### 3 Refund
210
239
 
211
240
  Initialize a `Paygate::Member` instance using the Member ID and Secret you have.
212
241
 
@@ -225,7 +254,7 @@ member.secret
225
254
  => "secret"
226
255
  ```
227
256
 
228
- #### 2.1 Full refund
257
+ #### 3.1 Full refund
229
258
 
230
259
  ```ruby
231
260
  response = member.refund_transaction('testmid_123456.654321')
@@ -233,8 +262,6 @@ response = member.refund_transaction('testmid_123456.654321')
233
262
  #<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
263
  ```
235
264
 
236
- Here, _testmid_123456.654321_ is `tid` of the transaction you want to refund.
237
-
238
265
  `response` provides some helpful accessor methods too.
239
266
 
240
267
  ```ruby
@@ -256,7 +283,7 @@ response.raw_info.request_url
256
283
 
257
284
  Apart from these it also responds to `message` and `body`.
258
285
 
259
- #### 2.2 Partial refund
286
+ #### 3.2 Partial refund
260
287
 
261
288
  For partial refunds, you need to pass `amount` as an option to `refund_transaction` method along with other options.
262
289
 
@@ -266,7 +293,7 @@ response = member.refund_transaction('testmid_123456.654321',
266
293
  order_id: 'ord10001')
267
294
  ```
268
295
 
269
- ### 3 Profile Pay
296
+ ### 4 Profile Pay
270
297
 
271
298
  You can use the `profile_no` returned from the OpenPayAPI after first payment by a customer to make future payments for him.
272
299
 
@@ -283,9 +310,9 @@ response.json
283
310
  => {"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
311
  ```
285
312
 
286
- ### 4 Javascript helpers
313
+ ### 5 JavaScript helpers
287
314
 
288
- `paygate-ruby` also provides a Javascript class `Paygate` with some helper functions that can be used in your Javascript e.g.
315
+ `paygate-ruby` also provides a JavaScript class `Paygate` with some helper functions that can be used in your JavaScript e.g.
289
316
 
290
317
  - _openPayApiForm_ - Returns the payment form
291
318
  - _openPayApiScreen_ - Returns the screen for paygate API response
@@ -1,5 +1,127 @@
1
1
  module Paygate
2
2
  module FormHelper
3
+ FORM_TEXT_FIELDS = {
4
+ mid: {
5
+ placeholder: 'Member ID'
6
+ },
7
+
8
+ locale: {
9
+ name: 'langcode',
10
+ default: 'KR',
11
+ placeholder: 'Language'
12
+ },
13
+
14
+ charset: {
15
+ default: 'UTF-8',
16
+ placeholder: 'Charset'
17
+ },
18
+
19
+ title: {
20
+ name: 'goodname',
21
+ placeholder: 'Title'
22
+ },
23
+
24
+ currency: {
25
+ name: 'goodcurrency',
26
+ default: 'WON',
27
+ placeholder: 'Currency'
28
+ },
29
+
30
+ amount: {
31
+ name: 'unitprice',
32
+ placeholder: 'Amount'
33
+ },
34
+
35
+ meta1: {
36
+ name: 'goodoption1',
37
+ placeholder: 'Good Option 1'
38
+ },
39
+
40
+ meta2: {
41
+ name: 'goodoption2',
42
+ placeholder: 'Good Option 2'
43
+ },
44
+
45
+ meta3: {
46
+ name: 'goodoption3',
47
+ placeholder: 'Good Option 3'
48
+ },
49
+
50
+ meta4: {
51
+ name: 'goodoption4',
52
+ placeholder: 'Good Option 4'
53
+ },
54
+
55
+ meta5: {
56
+ name: 'goodoption5',
57
+ placeholder: 'Good Option 5'
58
+ },
59
+
60
+ pay_method: {
61
+ name: 'paymethod',
62
+ default: 'card',
63
+ placeholder: 'Pay Method'
64
+ },
65
+
66
+ customer_name: {
67
+ name: 'receipttoname',
68
+ placeholder: 'Customer Name'
69
+ },
70
+
71
+ customer_email: {
72
+ name: 'receipttoemail',
73
+ placeholder: 'Customer Email'
74
+ },
75
+
76
+ card_number: {
77
+ name: 'cardnumber',
78
+ placeholder: 'Card Number'
79
+ },
80
+
81
+ expiry_year: {
82
+ name: 'cardexpireyear',
83
+ placeholder: 'Expiry Year'
84
+ },
85
+
86
+ expiry_month: {
87
+ name: 'cardexpiremonth',
88
+ placeholder: 'Expiry Month'
89
+ },
90
+
91
+ cvv: {
92
+ name: 'cardsecretnumber',
93
+ placeholder: 'CVV'
94
+ },
95
+
96
+ card_auth_code: {
97
+ name: 'cardauthcode',
98
+ placeholder: 'Card Auth Code'
99
+ },
100
+
101
+ response_code: {
102
+ name: 'replycode',
103
+ placeholder: 'Response Code'
104
+ },
105
+
106
+ response_message: {
107
+ name: 'replyMsg',
108
+ placeholder: 'Response Message'
109
+ },
110
+
111
+ tid: {
112
+ placeholder: 'TID'
113
+ },
114
+
115
+ profile_no: {
116
+ placeholder: 'Profile No'
117
+ },
118
+
119
+ hash_result: {
120
+ name: 'hashresult',
121
+ placeholder: 'Hash Result'
122
+ }
123
+ }
124
+
3
125
  def paygate_open_pay_api_js_url
4
126
  (Paygate.configuration.mode == :live) ?
5
127
  'https://api.paygate.net/ajax/common/OpenPayAPI.js'.freeze :
@@ -10,62 +132,15 @@ module Paygate
10
132
  form_tag({}, name: 'PGIOForm') do
11
133
  fields = []
12
134
 
13
- fields << text_field_tag(:mid, options[:mid].try(:[], :value),
14
- placeholder: options[:mid].try(:[], :placeholder) || 'Member ID').html_safe
15
-
16
- fields << text_field_tag(:locale, options[:locale].try(:[], :value) || 'KR',
17
- name: 'langcode', placeholder: options[:locale].try(:[], :placeholder) || 'Language').html_safe
18
-
19
- fields << text_field_tag(:charset, options[:charset].try(:[], :value) || 'UTF-8',
20
- placeholder: options[:charset].try(:[], :placeholder) || 'Charset').html_safe
21
-
22
- fields << text_field_tag(:title, options[:title].try(:[], :value),
23
- name: 'goodname', placeholder: options[:title].try(:[], :placeholder) || 'Title').html_safe
24
-
25
- fields << text_field_tag(:currency, options[:currency].try(:[], :value) || 'WON',
26
- name: 'goodcurrency', placeholder: options[:currency].try(:[], :placeholder) || 'Currency').html_safe
27
-
28
- fields << text_field_tag(:amount, options[:amount].try(:[], :value),
29
- name: 'unitprice', placeholder: options[:amount].try(:[], :placeholder) || 'Amount').html_safe
30
-
31
- fields << text_field_tag(:pay_method, options[:pay_method].try(:[], :value) || 'card',
32
- name: 'paymethod', placeholder: options[:pay_method].try(:[], :placeholder) || 'Pay Method').html_safe
33
-
34
- fields << text_field_tag(:customer_name, options[:customer_name].try(:[], :value),
35
- name: 'receipttoname', placeholder: options[:customer_name].try(:[], :placeholder) || 'Customer Name').html_safe
36
-
37
- fields << text_field_tag(:customer_email, options[:customer_email].try(:[], :value),
38
- name: 'receipttoemail', placeholder: options[:customer_email].try(:[], :placeholder) || 'Customer Email').html_safe
39
-
40
- fields << text_field_tag(:card_number, options[:card_number].try(:[], :value),
41
- name: 'cardnumber', placeholder: options[:card_number].try(:[], :placeholder) || 'Card Number').html_safe
42
-
43
- fields << text_field_tag(:expiry_year, options[:expiry_year].try(:[], :value),
44
- name: 'cardexpireyear', placeholder: options[:expiry_year].try(:[], :placeholder) || 'Expiry Year').html_safe
45
-
46
- fields << text_field_tag(:expiry_month, options[:expiry_month].try(:[], :value),
47
- name: 'cardexpiremonth', placeholder: options[:expiry_month].try(:[], :placeholder) || 'Expiry Month').html_safe
48
-
49
- fields << text_field_tag(:cvv, options[:cvv].try(:[], :value),
50
- name: 'cardsecretnumber', placeholder: options[:cvv].try(:[], :placeholder) || 'CVV').html_safe
51
-
52
- fields << text_field_tag(:card_auth_code, nil,
53
- name: 'cardauthcode', placeholder: options[:card_auth_code].try(:[], :placeholder) || 'Card Auth Code').html_safe
54
-
55
- fields << text_field_tag(:response_code, nil,
56
- name: 'replycode', placeholder: options[:response_code].try(:[], :placeholder) || 'Response Code').html_safe
57
-
58
- fields << text_field_tag(:response_message, nil,
59
- name: 'replyMsg', placeholder: options[:response_message].try(:[], :placeholder) || 'Response Message').html_safe
60
-
61
- fields << text_field_tag(:tid, nil,
62
- placeholder: options[:tid].try(:[], :placeholder) || 'TID').html_safe
63
-
64
- fields << text_field_tag(:profile_no, nil,
65
- placeholder: options[:profile_no].try(:[], :placeholder) || 'Profile No').html_safe
66
-
67
- fields << text_field_tag(:hash_result, nil,
68
- name: 'hashresult', placeholder: options[:hash_result].try(:[], :placeholder) || 'Hash Result').html_safe
135
+ FORM_TEXT_FIELDS.each do |key, opts|
136
+ arg_opts = options[key] || {}
137
+ fields << text_field_tag(
138
+ key,
139
+ arg_opts[:value] || opts[:default],
140
+ name: opts[:name] || key.to_s,
141
+ placeholder: arg_opts[:placeholder] || opts[:placeholder]
142
+ ).html_safe
143
+ end
69
144
 
70
145
  fields.join.html_safe
71
146
  end.html_safe
@@ -36,6 +36,17 @@ module Paygate
36
36
  r
37
37
  end
38
38
 
39
+ # Doc: https://km.paygate.net/pages/viewpage.action?pageId=9207875
40
+ def verify
41
+ params = { tid: tid, verifyNum: 100 }
42
+
43
+ uri = URI('https://service.paygate.net/djemals/settle/verifyReceived.jsp')
44
+ uri.query = ::URI.encode_www_form(params)
45
+ response = ::Net::HTTP.get_response(uri)
46
+
47
+ Response.build_from_net_http_response(:verify, response)
48
+ end
49
+
39
50
  private
40
51
 
41
52
  def self.refund_api_url
@@ -1,3 +1,3 @@
1
1
  module Paygate
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -8,6 +8,11 @@ window.Paygate = (function() {
8
8
  title: 'goodname',
9
9
  currency: 'goodcurrency',
10
10
  amount: 'unitprice',
11
+ meta1: 'goodoption1',
12
+ meta2: 'goodoption2',
13
+ meta3: 'goodoption3',
14
+ meta4: 'goodoption4',
15
+ meta5: 'goodoption5',
11
16
  payMethod: 'paymethod',
12
17
  customerName: 'receipttoname',
13
18
  customerEmail: 'receipttoemail',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paygate-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - jagdeepsingh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-01 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler