paygate-ruby 0.1.1 → 0.1.2
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 +16 -0
- data/README.md +19 -11
- data/lib/paygate/member.rb +2 -2
- data/lib/paygate/response.rb +1 -1
- data/lib/paygate/transaction.rb +6 -4
- data/lib/paygate/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65cf37be0b80974b5bbfea30323cac9a49700b5b019ce61d0c169a0566ca04f0
|
4
|
+
data.tar.gz: 37865beecc0da514d9c104197af2dcebf6fc85d14b76eed79a68cfb583f1b6ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ba8427bdd1e06a0c411ce0cb21d9cd40086402a356a3e488f0c9c2ce34e1476d956fd7ab47807f4a25cc41a1705f71114f9ad762a18268ffd9314ff9438cbf
|
7
|
+
data.tar.gz: c32240809e74a7c6e5ff98c7b897f8366101ce9a82699451d8bbe5f669366d1d5659dde478bf956c66d29c2b2199152fcc35a1c435e589986d523070c717e1da
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.1.2 - 2018-03-16
|
4
|
+
|
5
|
+
- Fix Bug - Pass correct value of _amount_ for full refund of a transaction.
|
6
|
+
|
7
|
+
## 0.1.1 - 2018-03-09
|
8
|
+
|
9
|
+
- Add raw info to the response of refund transaction.
|
10
|
+
|
11
|
+
## 0.1.0 - 2017-11-29
|
12
|
+
|
13
|
+
- Add view helper for rendering OpenPayAPI payment form with default values.
|
14
|
+
- Add Javascript helpers for accessing OpenPayAPI payment form and payment screen.
|
15
|
+
- Support full refund of a transaction using CancelAPI.
|
16
|
+
- Support future payments (Profile Pay) for existing customers.
|
data/README.md
CHANGED
@@ -28,7 +28,7 @@ NOTE: Unless otherwise stated, all the following documentation is for making pay
|
|
28
28
|
|
29
29
|
Contents:
|
30
30
|
- [1 Purchase](#1-purchase)
|
31
|
-
- [2
|
31
|
+
- [2 Refund](#2-refund)
|
32
32
|
- [3 Profile Pay](#3-profile-pay)
|
33
33
|
|
34
34
|
### 1 Purchase
|
@@ -127,7 +127,7 @@ Passing `nil` above would return default currency i.e. "WON".
|
|
127
127
|
|
128
128
|
You need to contact PayGate to know the correct amount for making a successful transaction in test mode.
|
129
129
|
|
130
|
-
Remember, in test mode too, PayGate makes real transactions and you need to
|
130
|
+
Remember, in test mode too, PayGate makes real transactions and you need to `refund` them.
|
131
131
|
|
132
132
|
**tid**
|
133
133
|
|
@@ -194,7 +194,7 @@ $('form[name="PGIOForm"]').on('submit', function(event){
|
|
194
194
|
|
195
195
|
And, your payment form is all set to make payments.
|
196
196
|
|
197
|
-
### 2
|
197
|
+
### 2 Refund
|
198
198
|
|
199
199
|
Initialize a `Paygate::Member` instance using the Member ID and Secret you have.
|
200
200
|
|
@@ -213,21 +213,21 @@ member.secret
|
|
213
213
|
=> "secret"
|
214
214
|
```
|
215
215
|
|
216
|
-
|
216
|
+
#### 2.1 Full refund
|
217
217
|
|
218
218
|
```ruby
|
219
|
-
response = member.
|
220
|
-
=> #<Paygate::Response:0x007fbf3d111940 @transaction_type=:
|
221
|
-
#<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=
|
219
|
+
response = member.refund_transaction('testmid_123456.654321')
|
220
|
+
=> #<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=
|
221
|
+
#<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">>
|
222
222
|
```
|
223
223
|
|
224
|
-
Here, _testmid_123456.654321_ is `tid` of the transaction you want to
|
224
|
+
Here, _testmid_123456.654321_ is `tid` of the transaction you want to refund.
|
225
225
|
|
226
226
|
`response` provides some helpful accessor methods too.
|
227
227
|
|
228
228
|
```ruby
|
229
229
|
response.transaction_type
|
230
|
-
=> :
|
230
|
+
=> :refund
|
231
231
|
|
232
232
|
response.http_code
|
233
233
|
=> "200"
|
@@ -236,14 +236,22 @@ response.json
|
|
236
236
|
=> {"replyCode"=>"0000", "replyMessage"=>"Response has been completed", "content"=>{"object"=>"CancelAPI tid:testmid_123456.654321 SUCCESS payRsltCode:0000"}}
|
237
237
|
|
238
238
|
response.raw_info
|
239
|
-
=> #<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=
|
239
|
+
=> #<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">
|
240
240
|
|
241
241
|
response.raw_info.request_url
|
242
|
-
=> "https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=
|
242
|
+
=> "https://service.paygate.net/service/cancelAPI.json?callback=callback&mid=testmid&tid=AES256XQIdNnkzFwMQmhF7fuJhS3m0%0A&amount=F"
|
243
243
|
```
|
244
244
|
|
245
245
|
Apart from these it also responds to `message` and `body`.
|
246
246
|
|
247
|
+
#### 2.2 Partial refund
|
248
|
+
|
249
|
+
For partial refunds, pass `amount` as an option to `refund_transaction` method:
|
250
|
+
|
251
|
+
```ruby
|
252
|
+
response = member.refund_transaction('testmid_123456.654321', amount: 1000)
|
253
|
+
```
|
254
|
+
|
247
255
|
### 3 Profile Pay
|
248
256
|
|
249
257
|
You can use the `profile_no` returned from the OpenPayAPI after first payment by a customer to make future payments for him.
|
data/lib/paygate/member.rb
CHANGED
@@ -6,10 +6,10 @@ module Paygate
|
|
6
6
|
@mid, @secret = mid, secret
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
9
|
+
def refund_transaction(txn_id, options = {})
|
10
10
|
txn = Transaction.new(txn_id)
|
11
11
|
txn.member = self
|
12
|
-
txn.
|
12
|
+
txn.refund(options)
|
13
13
|
end
|
14
14
|
|
15
15
|
def profile_pay(profile_no, currency, amount)
|
data/lib/paygate/response.rb
CHANGED
data/lib/paygate/transaction.rb
CHANGED
@@ -4,7 +4,8 @@ require 'net/http'
|
|
4
4
|
|
5
5
|
module Paygate
|
6
6
|
class Transaction
|
7
|
-
|
7
|
+
REFUND_API_URL = 'https://service.paygate.net/service/cancelAPI.json'.freeze
|
8
|
+
FULL_AMOUNT_IDENTIFIER = 'F'.freeze
|
8
9
|
|
9
10
|
attr_reader :tid
|
10
11
|
attr_accessor :member
|
@@ -13,7 +14,7 @@ module Paygate
|
|
13
14
|
@tid = tid
|
14
15
|
end
|
15
16
|
|
16
|
-
def
|
17
|
+
def refund(options = {})
|
17
18
|
# Encrypt data
|
18
19
|
api_key_256 = ::Digest::SHA256.hexdigest(member.secret)
|
19
20
|
aes_ctr = AesCtr.encrypt(tid, api_key_256, 256)
|
@@ -22,14 +23,15 @@ module Paygate
|
|
22
23
|
# Prepare params
|
23
24
|
params = { callback: 'callback', mid: member.mid, tid: tid_enc }
|
24
25
|
params.merge!(options.slice(:amount))
|
26
|
+
params[:amount] ||= FULL_AMOUNT_IDENTIFIER
|
25
27
|
params.delete_if { |_, v| v.blank? }
|
26
28
|
|
27
29
|
# Make request
|
28
|
-
uri = URI(
|
30
|
+
uri = URI(REFUND_API_URL)
|
29
31
|
uri.query = ::URI.encode_www_form(params)
|
30
32
|
response = ::Net::HTTP.get_response(uri)
|
31
33
|
|
32
|
-
r = Response.build_from_net_http_response(:
|
34
|
+
r = Response.build_from_net_http_response(:refund, response)
|
33
35
|
r.raw_info = OpenStruct.new(tid: tid, tid_enc: tid_enc, request_url: uri.to_s)
|
34
36
|
r
|
35
37
|
end
|
data/lib/paygate/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jagdeepsingh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- CHANGELOG.md
|
49
50
|
- CODE_OF_CONDUCT.md
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|