securionpay 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/console +2 -0
- data/lib/securionpay/blacklist.rb +24 -0
- data/lib/securionpay/cards.rb +9 -27
- data/lib/securionpay/charges.rb +31 -0
- data/lib/securionpay/communicator.rb +33 -25
- data/lib/securionpay/configuration.rb +22 -2
- data/lib/securionpay/credits.rb +23 -0
- data/lib/securionpay/cross_sale_offers.rb +27 -0
- data/lib/securionpay/customers.rb +27 -0
- data/lib/securionpay/disputes.rb +23 -0
- data/lib/securionpay/events.rb +15 -0
- data/lib/securionpay/file_uploads.rb +20 -0
- data/lib/securionpay/fraud_warnings.rb +15 -0
- data/lib/securionpay/plans.rb +27 -0
- data/lib/securionpay/securion_pay_exception.rb +16 -0
- data/lib/securionpay/subscriptions.rb +27 -0
- data/lib/securionpay/tokens.rb +15 -0
- data/lib/securionpay/transaction_base.rb +13 -0
- data/lib/securionpay/version.rb +3 -1
- data/lib/securionpay.rb +19 -1
- metadata +106 -33
- data/.codeclimate.yml +0 -25
- data/.gitignore +0 -10
- data/.rubocop.yml +0 -1156
- data/.ruby-version +0 -1
- data/.travis.yml +0 -9
- data/Gemfile +0 -4
- data/README.md +0 -113
- data/Rakefile +0 -7
- data/bin/setup +0 -8
- data/lib/securionpay/builders/path_builder.rb +0 -13
- data/securionpay-ruby.gemspec +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9b95512e478342f2458ccf71e6bde4439f90d1d5930831d261ab239cd30c9c43
|
4
|
+
data.tar.gz: dc91f41e4c309ef05e2823f777981a1f6eef085ff5ad595cb91fe0bd94159874
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e23dd58edb84394e0d00a6bbf2001167a6aee5a7b2020c43adf2059f0184a57164cec75b67005d27498b8a2c5f08e23c9edbf9896a94f5b616616751de58b819
|
7
|
+
data.tar.gz: 89aff8b416b289c5711eec238de4acb5553afb6cf82a3ae365597f6892d7098065800c1fdac0232e7fe5ee77f74e8c4e567863fd2136bbd37e5a75b0ef8f27dc
|
data/bin/console
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
# Blacklist can be used to block unwanted charges.
|
5
|
+
class Blacklist
|
6
|
+
extend TransactionBase
|
7
|
+
|
8
|
+
def self.create(params)
|
9
|
+
communicator.post("#{Configuration.api_url}/blacklist", json: params)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.retrieve(blacklist_rule_id)
|
13
|
+
communicator.get("#{Configuration.api_url}/blacklist/#{blacklist_rule_id}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.delete(blacklist_rule_id)
|
17
|
+
communicator.delete("#{Configuration.api_url}/blacklist/#{blacklist_rule_id}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.list(params = nil)
|
21
|
+
communicator.get("#{Configuration.api_url}/blacklist", query: params)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/securionpay/cards.rb
CHANGED
@@ -1,45 +1,27 @@
|
|
1
|
-
|
2
|
-
require 'securionpay/builders/path_builder'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
3
|
module SecurionPay
|
5
4
|
class Cards
|
6
|
-
|
7
|
-
attr_accessor :communicator, :path_builder
|
8
|
-
end
|
9
|
-
|
10
|
-
@communicator = Communicator
|
11
|
-
@path_builder = Builders::PathBuilder
|
5
|
+
extend TransactionBase
|
12
6
|
|
13
7
|
def self.create(customer_id, params)
|
14
|
-
communicator.post(
|
15
|
-
path_builder.build_card_path(customer_id),
|
16
|
-
params
|
17
|
-
)
|
8
|
+
communicator.post("#{Configuration.api_url}/customers/#{customer_id}/cards", json: params)
|
18
9
|
end
|
19
10
|
|
20
11
|
def self.retrieve(customer_id, card_id)
|
21
|
-
communicator.get(
|
22
|
-
path_builder.build_card_path(customer_id, card_id)
|
23
|
-
)
|
12
|
+
communicator.get("#{Configuration.api_url}/customers/#{customer_id}/cards/#{card_id}")
|
24
13
|
end
|
25
14
|
|
26
15
|
def self.update(customer_id, card_id, params)
|
27
|
-
communicator.post(
|
28
|
-
path_builder.build_card_path(customer_id, card_id),
|
29
|
-
params
|
30
|
-
)
|
16
|
+
communicator.post("#{Configuration.api_url}/customers/#{customer_id}/cards/#{card_id}", json: params)
|
31
17
|
end
|
32
|
-
|
18
|
+
|
33
19
|
def self.delete(customer_id, card_id)
|
34
|
-
communicator.delete(
|
35
|
-
path_builder.build_card_path(customer_id, card_id)
|
36
|
-
)
|
20
|
+
communicator.delete("#{Configuration.api_url}/customers/#{customer_id}/cards/#{card_id}")
|
37
21
|
end
|
38
22
|
|
39
|
-
def self.list(customer_id)
|
40
|
-
communicator.get(
|
41
|
-
path_builder.build_card_path(customer_id)
|
42
|
-
)
|
23
|
+
def self.list(customer_id, params = nil)
|
24
|
+
communicator.get("#{Configuration.api_url}/customers/#{customer_id}/cards", query: params)
|
43
25
|
end
|
44
26
|
end
|
45
27
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Charges
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/charges", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(charge_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/charges/#{charge_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(charge_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/charges/#{charge_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.list(params = nil)
|
20
|
+
communicator.get("#{Configuration.api_url}/charges", query: params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.capture(charge_id)
|
24
|
+
communicator.post("#{Configuration.api_url}/charges/#{charge_id}/capture")
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.refund(charge_id, params = nil)
|
28
|
+
communicator.post("#{Configuration.api_url}/charges/#{charge_id}/refund", json: params)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'httparty'
|
2
4
|
|
3
5
|
module SecurionPay
|
@@ -8,44 +10,50 @@ module SecurionPay
|
|
8
10
|
|
9
11
|
@web_consumer = HTTParty
|
10
12
|
|
11
|
-
def self.get(
|
12
|
-
web_consumer.get(
|
13
|
-
|
14
|
-
|
15
|
-
)
|
13
|
+
def self.get(url, query: nil)
|
14
|
+
response = web_consumer.get(url, request(query: query))
|
15
|
+
handle_response(response)
|
16
|
+
response
|
16
17
|
end
|
17
18
|
|
18
|
-
def self.post(
|
19
|
-
web_consumer.post(
|
20
|
-
|
21
|
-
|
22
|
-
)
|
19
|
+
def self.post(url, json: nil, body: nil)
|
20
|
+
response = web_consumer.post(url, request(json: json, body: body))
|
21
|
+
handle_response(response)
|
22
|
+
response
|
23
23
|
end
|
24
24
|
|
25
|
-
def self.delete(
|
26
|
-
web_consumer.delete(
|
27
|
-
|
28
|
-
|
29
|
-
)
|
25
|
+
def self.delete(url)
|
26
|
+
response = web_consumer.delete(url, request)
|
27
|
+
handle_response(response)
|
28
|
+
response
|
30
29
|
end
|
31
30
|
|
32
|
-
def self.
|
33
|
-
|
34
|
-
|
31
|
+
def self.request(json: nil, query: nil, body: nil)
|
32
|
+
headers = {
|
33
|
+
"User-Agent" => "SecurionPay-Ruby/#{SecurionPay::VERSION} (Ruby/#{RUBY_VERSION})",
|
34
|
+
"Accept" => "application/json",
|
35
|
+
}
|
36
|
+
if json
|
37
|
+
raise ArgumentError("Cannot specify both body and json") if body
|
38
|
+
|
39
|
+
body = json.to_json
|
40
|
+
headers["Content-Type"] = "application/json"
|
41
|
+
end
|
35
42
|
|
36
|
-
def self.request_body(body = nil)
|
37
43
|
{
|
38
44
|
body: body,
|
39
|
-
|
45
|
+
query: query,
|
46
|
+
headers: headers,
|
47
|
+
basic_auth: {
|
48
|
+
username: Configuration.secret_key
|
49
|
+
}
|
40
50
|
}
|
41
51
|
end
|
42
52
|
|
43
|
-
def self.
|
44
|
-
|
45
|
-
username: Configuration.private_key
|
46
|
-
}
|
53
|
+
def self.handle_response(response)
|
54
|
+
raise SecurionPayException, response if (400..599).cover?(response.code)
|
47
55
|
end
|
48
56
|
|
49
|
-
private_class_method :
|
57
|
+
private_class_method :request, :handle_response
|
50
58
|
end
|
51
59
|
end
|
@@ -1,9 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module SecurionPay
|
2
4
|
class Configuration
|
3
5
|
class << self
|
4
|
-
attr_accessor :
|
6
|
+
attr_accessor :secret_key
|
7
|
+
attr_reader :api_url, :uploads_url
|
5
8
|
end
|
6
9
|
|
7
|
-
@
|
10
|
+
@api_url = 'https://api.securionpay.com'
|
11
|
+
@uploads_url = 'https://uploads.securionpay.com'
|
12
|
+
|
13
|
+
def self.api_url=(api_url)
|
14
|
+
@api_url = if api_url.nil?
|
15
|
+
'https://api.securionpay.com'
|
16
|
+
else
|
17
|
+
api_url.gsub(%r{/$}, "")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.uploads_url=(uploads_url)
|
22
|
+
@uploads_url = if uploads_url.nil?
|
23
|
+
'https://uploads.securionpay.com'
|
24
|
+
else
|
25
|
+
uploads_url.gsub(%r{/$}, "")
|
26
|
+
end
|
27
|
+
end
|
8
28
|
end
|
9
29
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Credits
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/credits", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(credit_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/credits/#{credit_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(credit_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/credits/#{credit_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.list(params = nil)
|
20
|
+
communicator.get("#{Configuration.api_url}/credits", query: params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class CrossSaleOffers
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/cross-sale-offers", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(cross_sale_offer_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/cross-sale-offers/#{cross_sale_offer_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(cross_sale_offer_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/cross-sale-offers/#{cross_sale_offer_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.delete(cross_sale_offer_id)
|
20
|
+
communicator.delete("#{Configuration.api_url}/cross-sale-offers/#{cross_sale_offer_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params = nil)
|
24
|
+
communicator.get("#{Configuration.api_url}/cross-sale-offers", query: params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Customers
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/customers", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(customer_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/customers/#{customer_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(customer_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/customers/#{customer_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.delete(customer_id)
|
20
|
+
communicator.delete("#{Configuration.api_url}/customers/#{customer_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params = nil)
|
24
|
+
communicator.get("#{Configuration.api_url}/customers", query: params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Disputes
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.retrieve(dispute_id)
|
8
|
+
communicator.get("#{Configuration.api_url}/disputes/#{dispute_id}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.update(dispute_id, params)
|
12
|
+
communicator.post("#{Configuration.api_url}/disputes/#{dispute_id}", json: params)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.close(dispute_id)
|
16
|
+
communicator.post("#{Configuration.api_url}/disputes/#{dispute_id}/close")
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.list(params = nil)
|
20
|
+
communicator.get("#{Configuration.api_url}/disputes", query: params)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Events
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.retrieve(event_id)
|
8
|
+
communicator.get("#{Configuration.api_url}/events/#{event_id}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.list(params = nil)
|
12
|
+
communicator.get("#{Configuration.api_url}/events", query: params)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class FileUploads
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.upload(file, params)
|
8
|
+
body = { file: file }.merge(params)
|
9
|
+
communicator.post("#{Configuration.uploads_url}/files", body: body)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.list(params = nil)
|
13
|
+
communicator.get("#{Configuration.uploads_url}/files", query: params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.retrieve(file_upload_id)
|
17
|
+
communicator.get("#{Configuration.uploads_url}/files/#{file_upload_id}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class FraudWarnings
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.retrieve(fraud_warning_id)
|
8
|
+
communicator.get("#{Configuration.api_url}/fraud-warnings/#{fraud_warning_id}")
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.list(params = nil)
|
12
|
+
communicator.get("#{Configuration.api_url}/fraud-warnings", query: params)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Plans
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/plans", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(plan_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/plans/#{plan_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(plan_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/plans/#{plan_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.delete(plan_id)
|
20
|
+
communicator.delete("#{Configuration.api_url}/plans/#{plan_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params = nil)
|
24
|
+
communicator.get("#{Configuration.api_url}/plans", query: params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class SecurionPayException < StandardError
|
5
|
+
attr_reader :response
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
super(response)
|
9
|
+
@response = response
|
10
|
+
end
|
11
|
+
|
12
|
+
def [](key)
|
13
|
+
response[key]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Subscriptions
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/subscriptions", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(subscription_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/subscriptions/#{subscription_id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update(subscription_id, params)
|
16
|
+
communicator.post("#{Configuration.api_url}/subscriptions/#{subscription_id}", json: params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.cancel(subscription_id)
|
20
|
+
communicator.delete("#{Configuration.api_url}/subscriptions/#{subscription_id}")
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params = nil)
|
24
|
+
communicator.get("#{Configuration.api_url}/subscriptions", query: params)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SecurionPay
|
4
|
+
class Tokens
|
5
|
+
extend TransactionBase
|
6
|
+
|
7
|
+
def self.create(params)
|
8
|
+
communicator.post("#{Configuration.api_url}/tokens", json: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.retrieve(token_id)
|
12
|
+
communicator.get("#{Configuration.api_url}/tokens/#{token_id}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/securionpay/version.rb
CHANGED
data/lib/securionpay.rb
CHANGED
@@ -1,7 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securionpay/transaction_base'
|
4
|
+
require 'securionpay/version'
|
5
|
+
require 'securionpay/securion_pay_exception'
|
6
|
+
|
7
|
+
require 'securionpay/blacklist'
|
1
8
|
require 'securionpay/cards'
|
9
|
+
require 'securionpay/charges'
|
2
10
|
require 'securionpay/communicator'
|
3
11
|
require 'securionpay/configuration'
|
4
|
-
require 'securionpay/
|
12
|
+
require 'securionpay/credits'
|
13
|
+
require 'securionpay/cross_sale_offers'
|
14
|
+
require 'securionpay/customers'
|
15
|
+
require 'securionpay/disputes'
|
16
|
+
require 'securionpay/events'
|
17
|
+
require 'securionpay/file_uploads'
|
18
|
+
require 'securionpay/fraud_warnings'
|
19
|
+
require 'securionpay/plans'
|
20
|
+
require 'securionpay/subscriptions'
|
21
|
+
require 'securionpay/tokens'
|
22
|
+
|
5
23
|
#
|
6
24
|
# SecurionPay start point
|
7
25
|
module SecurionPay
|