paymentrails 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paymentrails.rb +2 -0
- data/lib/paymentrails/Client.rb +1 -6
- data/lib/paymentrails/Configuration.rb +14 -4
- data/lib/paymentrails/Gateway.rb +4 -0
- data/lib/paymentrails/OfflinePayment.rb +6 -0
- data/lib/paymentrails/Payment.rb +45 -2
- data/lib/paymentrails/gateways/OfflinePaymentGateway.rb +63 -0
- data/lib/paymentrails/gateways/RecipientAccountGateway.rb +1 -1
- data/paymentrails.gemspec +4 -3
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c675152b7b6253f43974fe54ef75f61040576e37b8eb8d18a31e0bdcd3648b31
|
4
|
+
data.tar.gz: ffed38b9237d86b3d902950fd27f520d1ebdb7854fc605844e5167933082618c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7946d78778cd54ff5952d939adf9ab8b37b0d1449801a34c45ee09c7f121ff72b0ca1db3cf2b0429aca93ad57dfc34391289f768b4dc3b8732aedb6ed7283a4e
|
7
|
+
data.tar.gz: 85347efba19d8342f71d71fe3dce890c64505b965c640aed7b4207ae112d578324291c52674bfea845475d150d7a448283e22bba8bd666b3472654be6976f2ef
|
data/lib/paymentrails.rb
CHANGED
@@ -6,6 +6,7 @@ require 'paymentrails/gateways/BatchGateway'
|
|
6
6
|
require 'paymentrails/gateways/PaymentGateway'
|
7
7
|
require 'paymentrails/gateways/RecipientGateway'
|
8
8
|
require 'paymentrails/gateways/RecipientAccountGateway'
|
9
|
+
require 'paymentrails/gateways/OfflinePaymentGateway'
|
9
10
|
|
10
11
|
require 'paymentrails/Balance'
|
11
12
|
require 'paymentrails/Batch'
|
@@ -14,6 +15,7 @@ require 'paymentrails/Exceptions'
|
|
14
15
|
require 'paymentrails/Payment'
|
15
16
|
require 'paymentrails/Recipient'
|
16
17
|
require 'paymentrails/RecipientAccount'
|
18
|
+
require 'paymentrails/OfflinePayment'
|
17
19
|
|
18
20
|
module PaymentRails
|
19
21
|
def self.client(key, secret, environment = 'production')
|
data/lib/paymentrails/Client.rb
CHANGED
@@ -35,12 +35,7 @@ module PaymentRails
|
|
35
35
|
def send_request(endPoint, method, body = '')
|
36
36
|
uri = URI.parse(@config.apiBase + endPoint)
|
37
37
|
http = Net::HTTP.new(uri.host, uri.port)
|
38
|
-
|
39
|
-
# for ssl use
|
40
|
-
if (@config.apiBase["https"])
|
41
|
-
http.use_ssl = true
|
42
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
43
|
-
end
|
38
|
+
http.use_ssl = @config.useSsl?
|
44
39
|
|
45
40
|
time = Time.now.to_i
|
46
41
|
headers = {'X-PR-Timestamp': time.to_s,
|
@@ -2,13 +2,19 @@ module PaymentRails
|
|
2
2
|
class Configuration
|
3
3
|
|
4
4
|
def initialize(publicKey, privateKey, environment = 'production')
|
5
|
+
# if publicKey&.empty? || privateKey&.empty?
|
6
|
+
# raise ArgumentError, 'Both key/secret must be a nonempty string'
|
7
|
+
# end
|
8
|
+
|
9
|
+
raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey&.empty? || privateKey&.empty?
|
10
|
+
|
5
11
|
@publicKey = publicKey
|
6
12
|
@privateKey = privateKey
|
7
|
-
@
|
13
|
+
@environment = environment
|
8
14
|
end
|
9
15
|
|
10
|
-
def
|
11
|
-
case
|
16
|
+
def apiBase
|
17
|
+
case environment
|
12
18
|
when 'production'
|
13
19
|
'https://api.paymentrails.com'
|
14
20
|
when 'development'
|
@@ -20,6 +26,10 @@ module PaymentRails
|
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
29
|
+
def useSsl?
|
30
|
+
apiBase.start_with? 'https'
|
31
|
+
end
|
32
|
+
|
23
33
|
attr_reader :publicKey
|
24
34
|
|
25
35
|
attr_writer :publicKey
|
@@ -28,6 +38,6 @@ module PaymentRails
|
|
28
38
|
|
29
39
|
attr_writer :privateKey
|
30
40
|
|
31
|
-
attr_reader :
|
41
|
+
attr_reader :environment
|
32
42
|
end
|
33
43
|
end
|
data/lib/paymentrails/Gateway.rb
CHANGED
@@ -21,6 +21,9 @@ module PaymentRails
|
|
21
21
|
attr_reader :balance
|
22
22
|
attr_writer :balance
|
23
23
|
|
24
|
+
attr_reader :offline_payment
|
25
|
+
attr_writer :offline_payment
|
26
|
+
|
24
27
|
def initialize(config)
|
25
28
|
@config = config
|
26
29
|
@client = Client.new(config)
|
@@ -29,6 +32,7 @@ module PaymentRails
|
|
29
32
|
@batch = BatchGateway.new(client)
|
30
33
|
@payment = PaymentGateway.new(client)
|
31
34
|
@balance = BalanceGateway.new(client)
|
35
|
+
@offline_payment = OfflinePaymentGateway.new(client)
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
module PaymentRails
|
2
|
+
class OfflinePayment
|
3
|
+
attr_accessor :id, :recipientId, :externalId, :memo, :tags, :taxReportable, :category, :amount, :currency, :withholdingAmount, :withholdingCurrency, :processedAt, :equivalentWithholdingAmount, :equivalentWithholdingCurrency, :updatedAt, :createdAt, :deletedAt
|
4
|
+
attr_writer :id, :externalId, :memo, :tags, :taxReportable, :category, :amount, :currency, :withholdingAmount, :withholdingCurrency, :processedAt
|
5
|
+
end
|
6
|
+
end
|
data/lib/paymentrails/Payment.rb
CHANGED
@@ -1,6 +1,49 @@
|
|
1
1
|
module PaymentRails
|
2
2
|
class Payment
|
3
|
-
|
4
|
-
|
3
|
+
attr_accessor(
|
4
|
+
:id,
|
5
|
+
:status,
|
6
|
+
:isSupplyPayment,
|
7
|
+
:returnedAmount,
|
8
|
+
:sourceAmount,
|
9
|
+
:sourceCurrency,
|
10
|
+
:targetAmount,
|
11
|
+
:targetCurrency,
|
12
|
+
:exchangeRate,
|
13
|
+
:fees,
|
14
|
+
:recipientFees,
|
15
|
+
:fxRate,
|
16
|
+
:memo,
|
17
|
+
:externalId,
|
18
|
+
:processedAt,
|
19
|
+
:createdAt,
|
20
|
+
:updatedAt,
|
21
|
+
:merchantFees,
|
22
|
+
:compliance,
|
23
|
+
:payoutMethod,
|
24
|
+
:recipient,
|
25
|
+
:withholdingAmount,
|
26
|
+
:withholdingCurrency,
|
27
|
+
:equivalentWithholdingAmount,
|
28
|
+
:equivalentWithholdingCurrency,
|
29
|
+
:methodDisplay,
|
30
|
+
:batch,
|
31
|
+
:coverFees,
|
32
|
+
:category,
|
33
|
+
:amount,
|
34
|
+
:currency,
|
35
|
+
:taxReportable,
|
36
|
+
:taxBasisAmount,
|
37
|
+
:taxBasisCurrency,
|
38
|
+
:tags,
|
39
|
+
:account,
|
40
|
+
:initiatedAt,
|
41
|
+
:settledAt,
|
42
|
+
:returnedAt,
|
43
|
+
:returnedNote,
|
44
|
+
:returnedReason,
|
45
|
+
:failureMessage,
|
46
|
+
:merchantId
|
47
|
+
)
|
5
48
|
end
|
6
49
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative '../Client.rb'
|
2
|
+
|
3
|
+
module PaymentRails
|
4
|
+
class OfflinePaymentGateway
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(recipient_id, body)
|
10
|
+
response = @client.post('/v1/recipients/' + recipient_id + '/offlinePayments', body)
|
11
|
+
offline_payment_builder(response)
|
12
|
+
end
|
13
|
+
|
14
|
+
def update(recipient_id, offline_payment_id, body)
|
15
|
+
@client.patch('/v1/recipients/' + recipient_id + '/offlinePayments/' + offline_payment_id, body)
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
def delete(recipient_id, offline_payment_id)
|
20
|
+
@client.delete('/v1/recipients/' + recipient_id + '/offlinePayments/' + offline_payment_id)
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def search(recipient_id = '', page = 1, page_size = 10, term = '')
|
25
|
+
if recipient_id === ''
|
26
|
+
response = @client.get('/v1/offline-payments?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term)
|
27
|
+
else
|
28
|
+
response = @client.get('/v1/recipients/' + recipient_id + '/offlinePayments?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term)
|
29
|
+
end
|
30
|
+
|
31
|
+
offline_payments_list_builder(response)
|
32
|
+
end
|
33
|
+
|
34
|
+
def offline_payment_builder(response)
|
35
|
+
offline_payment = OfflinePayment.new
|
36
|
+
data = JSON.parse(response)
|
37
|
+
data.each do |key, value|
|
38
|
+
next unless key === 'offlinePayment'
|
39
|
+
value.each do |opKey, opValue|
|
40
|
+
offline_payment.send("#{opKey}=", opValue)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
offline_payment
|
44
|
+
end
|
45
|
+
|
46
|
+
def offline_payments_list_builder(response)
|
47
|
+
offline_payments = []
|
48
|
+
data = JSON.parse(response)
|
49
|
+
|
50
|
+
data.each do |key, value|
|
51
|
+
next unless key === 'offlinePayments'
|
52
|
+
value.each do |newKey, _newValue|
|
53
|
+
offline_payment = OfflinePayment.new
|
54
|
+
newKey.each do |key1, value1|
|
55
|
+
offline_payment.send("#{key1}=", value1)
|
56
|
+
end
|
57
|
+
offline_payments.push(offline_payment)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
offline_payments
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -22,7 +22,7 @@ module PaymentRails
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def update(recipient_id, recipient_account_id, body)
|
25
|
-
response = @client.patch('/v1/recipients/' + recipient_id
|
25
|
+
response = @client.patch('/v1/recipients/' + recipient_id + '/accounts/' + recipient_account_id, body)
|
26
26
|
recipient_account_builder(response)
|
27
27
|
end
|
28
28
|
|
data/paymentrails.gemspec
CHANGED
@@ -4,12 +4,13 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.name = "paymentrails"
|
5
5
|
s.summary = "PaymentRails Ruby SDK"
|
6
6
|
s.description = "Ruby SDK for interacting with the PaymentRails API"
|
7
|
-
s.version = '0.2.
|
7
|
+
s.version = '0.2.2'
|
8
8
|
s.homepage = 'https://www.paymentrails.com/'
|
9
|
-
s.email = ['
|
9
|
+
s.email = ['joshua@paymentrails.com']
|
10
10
|
s.license = "MIT"
|
11
11
|
s.author = "PaymentRails"
|
12
|
-
s.has_rdoc = false
|
13
12
|
s.files = Dir.glob ["README.rdoc", "LICENSE", "lib/**/*.{rb,crt}", "spec/**/*", "*.gemspec"]
|
13
|
+
s.required_ruby_version = '>= 2.4'
|
14
14
|
s.add_dependency "rest-client", ">= 2.0.0"
|
15
|
+
s.add_development_dependency "rubocop", '~> 0.77'
|
15
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paymentrails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PaymentRails
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -24,9 +24,22 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 2.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.77'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.77'
|
27
41
|
description: Ruby SDK for interacting with the PaymentRails API
|
28
42
|
email:
|
29
|
-
- jesse.silber@paymentrails.com
|
30
43
|
- joshua@paymentrails.com
|
31
44
|
executables: []
|
32
45
|
extensions: []
|
@@ -41,11 +54,13 @@ files:
|
|
41
54
|
- lib/paymentrails/Configuration.rb
|
42
55
|
- lib/paymentrails/Exceptions.rb
|
43
56
|
- lib/paymentrails/Gateway.rb
|
57
|
+
- lib/paymentrails/OfflinePayment.rb
|
44
58
|
- lib/paymentrails/Payment.rb
|
45
59
|
- lib/paymentrails/Recipient.rb
|
46
60
|
- lib/paymentrails/RecipientAccount.rb
|
47
61
|
- lib/paymentrails/gateways/BalanceGateway.rb
|
48
62
|
- lib/paymentrails/gateways/BatchGateway.rb
|
63
|
+
- lib/paymentrails/gateways/OfflinePaymentGateway.rb
|
49
64
|
- lib/paymentrails/gateways/PaymentGateway.rb
|
50
65
|
- lib/paymentrails/gateways/RecipientAccountGateway.rb
|
51
66
|
- lib/paymentrails/gateways/RecipientGateway.rb
|
@@ -64,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
79
|
requirements:
|
65
80
|
- - ">="
|
66
81
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
82
|
+
version: '2.4'
|
68
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
84
|
requirements:
|
70
85
|
- - ">="
|