paygate-ruby 0.1.1 → 0.1.2

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: 5c14a70c282c1f4f93ac7e45f2de15fe88f9af2bd4f4e0dab3d5274ecb1b6499
4
- data.tar.gz: 24158c084acd02c3d26967e5ca8f9c5e9483649e1a0d26cb26883b5d5cd3bb93
3
+ metadata.gz: 65cf37be0b80974b5bbfea30323cac9a49700b5b019ce61d0c169a0566ca04f0
4
+ data.tar.gz: 37865beecc0da514d9c104197af2dcebf6fc85d14b76eed79a68cfb583f1b6ca
5
5
  SHA512:
6
- metadata.gz: d041fa6ccf284ab752f62429da877f31b672b85f1b2846c64dd2d1932a4c49b1b8205eca6563fddaa908114ce67a8c35497c3ce3ec0d05db7e439d8702692578
7
- data.tar.gz: 30da4f2cbd4dae440e78b93b3b927486f7a4e5c8040841e71bb57d47bb3a7f215e6ffe26bd5dbdb6ae4ca1acaf96fb3bc3c2041540e734ce3b15064f6a6c3ae5
6
+ metadata.gz: b3ba8427bdd1e06a0c411ce0cb21d9cd40086402a356a3e488f0c9c2ce34e1476d956fd7ab47807f4a25cc41a1705f71114f9ad762a18268ffd9314ff9438cbf
7
+ data.tar.gz: c32240809e74a7c6e5ff98c7b897f8366101ce9a82699451d8bbe5f669366d1d5659dde478bf956c66d29c2b2199152fcc35a1c435e589986d523070c717e1da
@@ -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 Cancel](#2-cancel)
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 cancel them for the refunds.
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 Cancel
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
- Cancel the transaction.
216
+ #### 2.1 Full refund
217
217
 
218
218
  ```ruby
219
- response = member.cancel_transaction('testmid_123456.654321', amount: 1000)
220
- => #<Paygate::Response:0x007fbf3d111940 @transaction_type=:cancel, @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=1000">>
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 cancel.
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
- => :cancel
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=1000">
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=1000"
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.
@@ -6,10 +6,10 @@ module Paygate
6
6
  @mid, @secret = mid, secret
7
7
  end
8
8
 
9
- def cancel_transaction(txn_id, options = {})
9
+ def refund_transaction(txn_id, options = {})
10
10
  txn = Transaction.new(txn_id)
11
11
  txn.member = self
12
- txn.cancel(options)
12
+ txn.refund(options)
13
13
  end
14
14
 
15
15
  def profile_pay(profile_no, currency, amount)
@@ -10,7 +10,7 @@ module Paygate
10
10
  r.body = response.body
11
11
 
12
12
  case txn_type
13
- when :cancel
13
+ when :refund
14
14
  r.json = JSON.parse response.body.gsub(/^callback\((.*)\)$/, '\1') if response.code.to_i == 200
15
15
  when :profile_pay
16
16
  r.json = {}
@@ -4,7 +4,8 @@ require 'net/http'
4
4
 
5
5
  module Paygate
6
6
  class Transaction
7
- CANCEL_API_URL = 'https://service.paygate.net/service/cancelAPI.json'.freeze
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 cancel(options = {})
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(CANCEL_API_URL)
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(:cancel, 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
@@ -1,3 +1,3 @@
1
1
  module Paygate
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-09 00:00:00.000000000 Z
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