paygate-ruby 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -6
- data/README.md +16 -2
- data/lib/paygate-ruby.rb +13 -0
- data/lib/paygate/configuration.rb +16 -0
- data/lib/paygate/helpers/form_helper.rb +3 -1
- data/lib/paygate/transaction.rb +10 -2
- 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: 53e3be330ee7a0ab9a06e1e1286d594093eb5b06c7d8f9231e4b8c7d1ac0295f
|
4
|
+
data.tar.gz: d6200b5886faa14d0248505f9e0b769d4fd5ce92eb43fd253f24a2850f266c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b142a69391e643ef31a1217a4cb154325d2da83c2fd971aefbd94623d76b09af99e771e047f88f22e51b5b3e69c69d233a724eb3d722c04b1208c1b3dec4638f
|
7
|
+
data.tar.gz: 4535297d8c9bfac45e4b04f097a430dabdad7a7672063a5adf554dc242050dbf45fea6da905dbf63ce33cdef409fd81e27352f3aa77e3d54245589488dcf76bc
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.1.4 - 2018-04-20
|
4
|
+
|
5
|
+
- [PR#3](https://github.com/jagdeepsingh/paygate-ruby/pull/3) Make `Paygate` configurable with the help of a block. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
6
|
+
|
3
7
|
## 0.1.2 - 2018-03-16
|
4
8
|
|
5
|
-
- Fix Bug - Pass correct value of _amount_ for full refund of a transaction.
|
9
|
+
- Fix Bug - Pass correct value of _amount_ for full refund of a transaction. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
6
10
|
|
7
11
|
## 0.1.1 - 2018-03-09
|
8
12
|
|
9
|
-
- Add raw info to the response of refund transaction.
|
13
|
+
- [PR#1](https://github.com/jagdeepsingh/paygate-ruby/pull/1) Add raw info to the response of refund transaction. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
10
14
|
|
11
15
|
## 0.1.0 - 2017-11-29
|
12
16
|
|
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.
|
17
|
+
- Add view helper for rendering OpenPayAPI payment form with default values. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
18
|
+
- Add Javascript helpers for accessing OpenPayAPI payment form and payment screen. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
19
|
+
- Support full refund of a transaction using CancelAPI. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
20
|
+
- Support future payments (Profile Pay) for existing customers. ([jagdeepsingh](https://github.com/jagdeepsingh))
|
data/README.md
CHANGED
@@ -18,6 +18,18 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install paygate-ruby
|
20
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
|
+
|
21
33
|
## Usage
|
22
34
|
|
23
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).
|
@@ -246,10 +258,12 @@ Apart from these it also responds to `message` and `body`.
|
|
246
258
|
|
247
259
|
#### 2.2 Partial refund
|
248
260
|
|
249
|
-
For partial refunds, pass `amount` as an option to `refund_transaction` method
|
261
|
+
For partial refunds, you need to pass `amount` as an option to `refund_transaction` method along with other options.
|
250
262
|
|
251
263
|
```ruby
|
252
|
-
response = member.refund_transaction('testmid_123456.654321',
|
264
|
+
response = member.refund_transaction('testmid_123456.654321',
|
265
|
+
amount: 1000,
|
266
|
+
order_id: 'ord10001')
|
253
267
|
```
|
254
268
|
|
255
269
|
### 3 Profile Pay
|
data/lib/paygate-ruby.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "paygate/version"
|
2
2
|
|
3
|
+
require 'paygate/configuration'
|
3
4
|
require 'paygate/aes'
|
4
5
|
require 'paygate/aes_ctr'
|
5
6
|
|
@@ -32,4 +33,16 @@ module Paygate
|
|
32
33
|
locale.present? ? LOCALES_MAP[locale.to_s] : DEFAULT_LOCALE
|
33
34
|
end
|
34
35
|
module_function :mapped_locale
|
36
|
+
|
37
|
+
class << self
|
38
|
+
attr_writer :configuration
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.configuration
|
42
|
+
@configuration ||= Configuration.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.configure
|
46
|
+
yield configuration
|
47
|
+
end
|
35
48
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Paygate
|
2
|
+
class Configuration
|
3
|
+
MODES = %i(live sandbox).freeze
|
4
|
+
|
5
|
+
attr_reader :mode
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@mode = :live
|
9
|
+
end
|
10
|
+
|
11
|
+
def mode=(value)
|
12
|
+
fail 'Invalid mode. Value must be one of the following: :live, :sandbox' unless value && MODES.include?(value.to_sym)
|
13
|
+
@mode = value.to_sym
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
module Paygate
|
2
2
|
module FormHelper
|
3
3
|
def paygate_open_pay_api_js_url
|
4
|
-
|
4
|
+
(Paygate.configuration.mode == :live) ?
|
5
|
+
'https://api.paygate.net/ajax/common/OpenPayAPI.js'.freeze :
|
6
|
+
'https://stgapi.paygate.net/ajax/common/OpenPayAPI.js'.freeze
|
5
7
|
end
|
6
8
|
|
7
9
|
def paygate_open_pay_api_form(options = {})
|
data/lib/paygate/transaction.rb
CHANGED
@@ -4,7 +4,6 @@ require 'net/http'
|
|
4
4
|
|
5
5
|
module Paygate
|
6
6
|
class Transaction
|
7
|
-
REFUND_API_URL = 'https://service.paygate.net/service/cancelAPI.json'.freeze
|
8
7
|
FULL_AMOUNT_IDENTIFIER = 'F'.freeze
|
9
8
|
|
10
9
|
attr_reader :tid
|
@@ -24,10 +23,11 @@ module Paygate
|
|
24
23
|
params = { callback: 'callback', mid: member.mid, tid: tid_enc }
|
25
24
|
params.merge!(options.slice(:amount))
|
26
25
|
params[:amount] ||= FULL_AMOUNT_IDENTIFIER
|
26
|
+
params[:mb_serial_no] = options[:order_id]
|
27
27
|
params.delete_if { |_, v| v.blank? }
|
28
28
|
|
29
29
|
# Make request
|
30
|
-
uri = URI(
|
30
|
+
uri = URI(self.class.refund_api_url)
|
31
31
|
uri.query = ::URI.encode_www_form(params)
|
32
32
|
response = ::Net::HTTP.get_response(uri)
|
33
33
|
|
@@ -35,5 +35,13 @@ module Paygate
|
|
35
35
|
r.raw_info = OpenStruct.new(tid: tid, tid_enc: tid_enc, request_url: uri.to_s)
|
36
36
|
r
|
37
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def self.refund_api_url
|
42
|
+
(Paygate.configuration.mode == :live) ?
|
43
|
+
'https://service.paygate.net/service/cancelAPI.json' :
|
44
|
+
'https://stgsvc.paygate.net/service/cancelAPI.json'
|
45
|
+
end
|
38
46
|
end
|
39
47
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jagdeepsingh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/paygate-ruby.rb
|
59
59
|
- lib/paygate/aes.rb
|
60
60
|
- lib/paygate/aes_ctr.rb
|
61
|
+
- lib/paygate/configuration.rb
|
61
62
|
- lib/paygate/helpers/form_helper.rb
|
62
63
|
- lib/paygate/member.rb
|
63
64
|
- lib/paygate/profile.rb
|