slimpay_client 1.1.3 → 1.2.0
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/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +66 -0
- data/CHANGELOG.md +25 -1
- data/README.md +1 -1
- data/lib/slimpay_client/app.rb +25 -17
- data/lib/slimpay_client/base.rb +39 -30
- data/lib/slimpay_client/card.rb +4 -11
- data/lib/slimpay_client/card_alias.rb +4 -11
- data/lib/slimpay_client/configuration.rb +10 -16
- data/lib/slimpay_client/creditor.rb +4 -11
- data/lib/slimpay_client/direct_debit.rb +8 -7
- data/lib/slimpay_client/error.rb +12 -9
- data/lib/slimpay_client/mandate.rb +5 -2
- data/lib/slimpay_client/order.rb +22 -19
- data/lib/slimpay_client/payment.rb +6 -15
- data/lib/slimpay_client/recurrent_card_transaction.rb +5 -12
- data/lib/slimpay_client/recurrent_direct_debit.rb +5 -12
- data/lib/slimpay_client/resource.rb +3 -3
- data/lib/slimpay_client/version.rb +1 -1
- data/lib/slimpay_client.rb +29 -28
- metadata +31 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 117052b9e86d2b4448b243b31a78060ad93c52e7ff8583228b4350f54d6e8637
|
|
4
|
+
data.tar.gz: b68073df5aa04f77df5af0b3acc4d12dd4dcb147bff28bb64883e39ff50c35d0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 132d721d0710779b9c4657bb92076898c1f60170647aac0275f0ac85ed46d2ad6bd0de37620a0600b53bd63a52998d753f3dc786d6724e2ecf909f49e87b6ea0
|
|
7
|
+
data.tar.gz: 0fee4c44b6a9ab4a148a763cfa6114b4bb12d26a4bae403f09695bf8946635ed8a93e167deeecf6b8b945cb99c1001e2ccfe6ee8ce1d09cf0d1aa0bc5ea87342
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config --no-exclude-limit`
|
|
3
|
+
# on 2026-11-20 15:26:35 UTC using RuboCop version 1.92.3.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 6
|
|
10
|
+
# Configuration parameters: EnforcedStyle, AllowedGems.
|
|
11
|
+
# SupportedStyles: Gemfile, gems.rb, gemspec
|
|
12
|
+
Gemspec/DevelopmentDependencies:
|
|
13
|
+
Exclude:
|
|
14
|
+
- 'slimpay_client.gemspec'
|
|
15
|
+
|
|
16
|
+
# Offense count: 2
|
|
17
|
+
# Configuration parameters: AllowedParentClasses.
|
|
18
|
+
Lint/MissingSuper:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'lib/slimpay_client/app.rb'
|
|
21
|
+
- 'lib/slimpay_client/error.rb'
|
|
22
|
+
|
|
23
|
+
# Offense count: 2
|
|
24
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
25
|
+
Metrics/AbcSize:
|
|
26
|
+
Exclude:
|
|
27
|
+
- 'lib/slimpay_client/base.rb'
|
|
28
|
+
|
|
29
|
+
# Offense count: 3
|
|
30
|
+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
31
|
+
# AllowedMethods: refine
|
|
32
|
+
Metrics/BlockLength:
|
|
33
|
+
Exclude:
|
|
34
|
+
- '**/*.gemspec'
|
|
35
|
+
- 'spec/base_spec.rb'
|
|
36
|
+
- 'spec/order_spec.rb'
|
|
37
|
+
- 'spec/slimpay_client_spec.rb'
|
|
38
|
+
|
|
39
|
+
# Offense count: 1
|
|
40
|
+
# Configuration parameters: CountComments, Max, CountAsOne.
|
|
41
|
+
Metrics/ClassLength:
|
|
42
|
+
Exclude:
|
|
43
|
+
- 'lib/slimpay_client/base.rb'
|
|
44
|
+
|
|
45
|
+
# Offense count: 1
|
|
46
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
47
|
+
Metrics/CyclomaticComplexity:
|
|
48
|
+
Exclude:
|
|
49
|
+
- 'lib/slimpay_client/base.rb'
|
|
50
|
+
|
|
51
|
+
# Offense count: 7
|
|
52
|
+
# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
53
|
+
Metrics/MethodLength:
|
|
54
|
+
Exclude:
|
|
55
|
+
- 'lib/slimpay_client/base.rb'
|
|
56
|
+
- 'lib/slimpay_client/direct_debit.rb'
|
|
57
|
+
- 'lib/slimpay_client/error.rb'
|
|
58
|
+
- 'lib/slimpay_client/order.rb'
|
|
59
|
+
|
|
60
|
+
# Offense count: 1
|
|
61
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
|
62
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
|
|
63
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
|
64
|
+
Style/SafeNavigation:
|
|
65
|
+
Exclude:
|
|
66
|
+
- 'lib/slimpay_client/base.rb'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
|
-
## [
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [1.2.0] - 2026-11-20
|
|
4
|
+
|
|
5
|
+
**Requires Ruby >= 3.2.**
|
|
6
|
+
|
|
7
|
+
* fix `SlimpayClient::App`: missing `API_HEADER` constant raised `NameError`
|
|
8
|
+
* fix query string building for generated GET methods (trailing `&`, nil arguments, URL encoding)
|
|
9
|
+
* fix `get_one`: API errors are raised before parsing the response body
|
|
10
|
+
* require `json` and `uri` explicitly
|
|
11
|
+
* remove duplicated `initialize` in resources, fix doc comments
|
|
12
|
+
* rubocop autocorrect
|
|
13
|
+
* gemspec: `required_ruby_version >= 3.2`, `activesupport >= 7.0, < 9`, `httparty >= 0.24.3`, `oauth2 >= 2.0.12`, updated dev dependencies
|
|
14
|
+
* gemspec: `rubygems_mfa_required`
|
|
15
|
+
* GitHub Actions CI (RSpec on Ruby 3.2/3.3/3.4, RuboCop, gem build) and Dependabot
|
|
16
|
+
* GitLab CI on Ruby 3.4
|
|
2
17
|
|
|
3
18
|
## [1.1.3] - 2026-03-31
|
|
19
|
+
|
|
20
|
+
* changelog only, no code changes
|
|
21
|
+
|
|
22
|
+
## [1.1.2] - 2026-03-31
|
|
23
|
+
|
|
4
24
|
* update gem dependency
|
|
5
25
|
** 'httparty', '~> 0.24.2'
|
|
6
26
|
|
|
27
|
+
## [1.1.1] - 2025-07-15
|
|
28
|
+
|
|
29
|
+
* first published release of 1.1.0 changes (1.1.0 was not published on RubyGems)
|
|
30
|
+
|
|
7
31
|
## [1.1.0] - 2025-07-15
|
|
8
32
|
|
|
9
33
|
* release task
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# SlimpayClient
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/baraidrissa/slimpay_client/actions/workflows/ci.yml)
|
|
4
4
|
|
|
5
5
|
SlimpayClient is a Ruby gem designed to provide a comprehensive and up-to-date interface for interacting with the Slimpay API. This gem extends the original \`slimpay\` gem created by gdurelle, addressing the need for maintenance and updates to ensure compatibility with the latest Slimpay API features and best practices.
|
|
6
6
|
|
data/lib/slimpay_client/app.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
4
|
# Used only to get and set callback URLs.
|
|
3
5
|
class App < Resource
|
|
@@ -10,9 +12,9 @@ module SlimpayClient
|
|
|
10
12
|
init_config
|
|
11
13
|
@username = username || SlimpayClient.configuration.username
|
|
12
14
|
@password = password || SlimpayClient.configuration.password
|
|
13
|
-
@basic_auth = {username: "#{@creditor_reference}##{@username}", password: @password}
|
|
15
|
+
@basic_auth = { username: "#{@creditor_reference}##{@username}", password: @password }
|
|
14
16
|
response = HTTParty.post(@token_endpoint, basic_auth: @basic_auth, body: app_options)
|
|
15
|
-
@token = response[
|
|
17
|
+
@token = response["access_token"]
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
# Change the successUrl
|
|
@@ -20,7 +22,8 @@ module SlimpayClient
|
|
|
20
22
|
# app = SlimpayClient::App.new
|
|
21
23
|
# app.success_url = "mywebsite.com/client/123/"
|
|
22
24
|
def success_url(url)
|
|
23
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
25
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
26
|
+
body: { successUrl: url }.to_json, headers: options)
|
|
24
27
|
SlimpayClient.answer(response)
|
|
25
28
|
end
|
|
26
29
|
|
|
@@ -29,7 +32,8 @@ module SlimpayClient
|
|
|
29
32
|
# app = SlimpayClient::App.new
|
|
30
33
|
# app.failure_url = "mywebsite.com/client/123/"
|
|
31
34
|
def failure_url(url)
|
|
32
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
35
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
36
|
+
body: { failureUrl: url }.to_json, headers: options)
|
|
33
37
|
SlimpayClient.answer(response)
|
|
34
38
|
end
|
|
35
39
|
|
|
@@ -38,7 +42,8 @@ module SlimpayClient
|
|
|
38
42
|
# app = SlimpayClient::App.new
|
|
39
43
|
# app.cancel_url = "mywebsite.com/client/123/"
|
|
40
44
|
def cancel_url(url)
|
|
41
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
45
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
46
|
+
body: { cancelUrl: url }.to_json, headers: options)
|
|
42
47
|
SlimpayClient.answer(response)
|
|
43
48
|
end
|
|
44
49
|
|
|
@@ -47,26 +52,29 @@ module SlimpayClient
|
|
|
47
52
|
# app = SlimpayClient::App.new
|
|
48
53
|
# app.return_url = "mywebsite.com/client/123/"
|
|
49
54
|
def return_url(url)
|
|
50
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
55
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
56
|
+
body: { returnUrl: url }.to_json, headers: options)
|
|
51
57
|
SlimpayClient.answer(response)
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
# Change the notifyUrl
|
|
55
61
|
def notify_url(url)
|
|
56
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
62
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
63
|
+
body: { notifyUrl: url }.to_json, headers: options)
|
|
57
64
|
SlimpayClient.answer(response)
|
|
58
65
|
end
|
|
59
66
|
|
|
60
67
|
# Change the notification and return URLs.
|
|
61
68
|
#
|
|
62
69
|
# ===== Arguments:
|
|
63
|
-
# successUrl: (String) URL
|
|
64
|
-
# failureUrl: (String) URL
|
|
65
|
-
# cancelUrl: (String) URL
|
|
66
|
-
# returnUrl: (String) URL
|
|
67
|
-
# notifyUrl: (String) URL
|
|
70
|
+
# successUrl: (String) URL the customer is redirected to when leaving Slimpay platform (success).
|
|
71
|
+
# failureUrl: (String) URL the customer is redirected to when leaving Slimpay platform (failure).
|
|
72
|
+
# cancelUrl: (String) URL the customer is redirected to when leaving Slimpay platform (cancel).
|
|
73
|
+
# returnUrl: (String) URL the customer is redirected to when leaving Slimpay platform.
|
|
74
|
+
# notifyUrl: (String) URL Slimpay sends notifications to (signature, payment, etc.).
|
|
68
75
|
def change_urls(urls_params)
|
|
69
|
-
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
76
|
+
response = HTTParty.patch("#{@endpoint}/creditors/#{@creditor_reference}/apps/#{@client_id}",
|
|
77
|
+
body: urls_params.to_json, headers: options)
|
|
70
78
|
SlimpayClient.answer(response)
|
|
71
79
|
end
|
|
72
80
|
|
|
@@ -74,10 +82,10 @@ module SlimpayClient
|
|
|
74
82
|
|
|
75
83
|
def app_options
|
|
76
84
|
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
"Accept" => API_HEADER,
|
|
86
|
+
"Content-type" => "application/hal+json",
|
|
87
|
+
"grant_type" => "client_credentials",
|
|
88
|
+
"scope" => "api_admin"
|
|
81
89
|
}
|
|
82
90
|
end
|
|
83
91
|
end
|
data/lib/slimpay_client/base.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
4
|
# Defines constants, main variables, requests options.
|
|
3
5
|
#
|
|
4
6
|
# Connect to the API through OAuth2 and generates API's first resources GET methods.
|
|
5
7
|
# ===== Usage:
|
|
6
|
-
# slimpay = SlimpayClient::Base.new
|
|
8
|
+
# slimpay = SlimpayClient::Base.new
|
|
7
9
|
# slimpay.api_methods
|
|
8
10
|
# =>
|
|
9
11
|
# { "post_token"=>"https://api-sandbox.slimpay.net/oauth/token",
|
|
@@ -21,10 +23,7 @@ module SlimpayClient
|
|
|
21
23
|
# "get_card_transaction_issues"=>"https://api-sandbox.slimpay.net/card-transaction-issues{?id}",
|
|
22
24
|
# "profile"=>"https://api-sandbox.slimpay.net/alps/v1"}
|
|
23
25
|
#
|
|
24
|
-
#
|
|
25
|
-
# client_id: (String)
|
|
26
|
-
# client_secret: (String)
|
|
27
|
-
# creditor_reference: (String)
|
|
26
|
+
# Credentials and URLs are read from SlimpayClient.configuration (see SlimpayClient.configure).
|
|
28
27
|
class Base
|
|
29
28
|
def initialize
|
|
30
29
|
init_config
|
|
@@ -38,15 +37,17 @@ module SlimpayClient
|
|
|
38
37
|
# It will also create new methods from future answers.
|
|
39
38
|
def generate_api_methods(response)
|
|
40
39
|
methods = {}
|
|
41
|
-
links = response[
|
|
42
|
-
|
|
40
|
+
links = response["_links"]
|
|
41
|
+
if response["_embedded"] && response["_embedded"]["items"]
|
|
42
|
+
links = links.merge(response["_embedded"]["items"].first["_links"])
|
|
43
|
+
end
|
|
43
44
|
return if links.nil?
|
|
44
45
|
|
|
45
46
|
links.each do |k, v|
|
|
46
|
-
name = k.gsub(
|
|
47
|
-
next if @methods && @methods.keys.include?(name) && !k.eql?(
|
|
47
|
+
name = k.gsub("https://api.slimpay.net/alps#", "").underscore
|
|
48
|
+
next if @methods && @methods.keys.include?(name) && !k.eql?("self")
|
|
48
49
|
|
|
49
|
-
url = v[
|
|
50
|
+
url = v["href"]
|
|
50
51
|
api_args = url.scan(/{\?(.*),?}/).flatten.first
|
|
51
52
|
|
|
52
53
|
methods[name] = generate_method(name, url, api_args)
|
|
@@ -68,19 +69,20 @@ module SlimpayClient
|
|
|
68
69
|
@return_url = SlimpayClient.configuration.return_url
|
|
69
70
|
@notify_url = SlimpayClient.configuration.notify_url
|
|
70
71
|
@endpoint = sandbox? ? SANDBOX_ENDPOINT : PRODUCTION_ENDPOINT
|
|
71
|
-
@token_endpoint = @endpoint
|
|
72
|
+
@token_endpoint = @endpoint
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
# A request call to the endpoint.
|
|
75
76
|
# An empty call will return list of available methods in the API.
|
|
76
|
-
def request_to_api(url =
|
|
77
|
+
def request_to_api(url = "")
|
|
77
78
|
response = HTTParty.get("#{@endpoint}/#{url}", headers: options)
|
|
78
79
|
SlimpayClient.answer response
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
# OAuth2 call to retrieve the token
|
|
82
83
|
def connect_api_with_oauth
|
|
83
|
-
client = OAuth2::Client.new(@client_id, @client_secret, site: @token_endpoint, headers: oauth_options,
|
|
84
|
+
client = OAuth2::Client.new(@client_id, @client_secret, site: @token_endpoint, headers: oauth_options,
|
|
85
|
+
auth_scheme: :basic_auth)
|
|
84
86
|
response = client.client_credentials.get_token
|
|
85
87
|
@token = response.token
|
|
86
88
|
end
|
|
@@ -90,9 +92,9 @@ module SlimpayClient
|
|
|
90
92
|
# url: (String) URL called in the method block
|
|
91
93
|
# api_args: (String) API arguments for this URL.
|
|
92
94
|
def generate_method(name, url, api_args)
|
|
93
|
-
if name.start_with?(
|
|
95
|
+
if name.start_with?("create", "post", "cancel")
|
|
94
96
|
generate_post_method(name, url)
|
|
95
|
-
elsif name.start_with?(
|
|
97
|
+
elsif name.start_with?("patch")
|
|
96
98
|
generate_patch_method(name, url)
|
|
97
99
|
else
|
|
98
100
|
generate_get_method(name, url, api_args)
|
|
@@ -105,7 +107,7 @@ module SlimpayClient
|
|
|
105
107
|
if api_args.nil?
|
|
106
108
|
response = HTTParty.get(url, headers: options)
|
|
107
109
|
else
|
|
108
|
-
clean_url = url.gsub(/{\?.*/,
|
|
110
|
+
clean_url = url.gsub(/{\?.*/, "")
|
|
109
111
|
url_args = format_html_arguments(api_args, method_arguments)
|
|
110
112
|
response = HTTParty.get("#{clean_url}?#{url_args}", headers: options)
|
|
111
113
|
end
|
|
@@ -132,14 +134,13 @@ module SlimpayClient
|
|
|
132
134
|
# api_args: (String) SlimpayClient given argument within URLs. Formated like: ?{arg1, arg2}
|
|
133
135
|
# method_arguments: (String) Arguments called on the currently defined method.
|
|
134
136
|
def format_html_arguments(api_args, method_arguments)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
end
|
|
137
|
+
return "" if method_arguments.blank?
|
|
138
|
+
|
|
139
|
+
params = api_args.split(",").each_with_object({}) do |arg, query|
|
|
140
|
+
value = method_arguments[arg.to_sym]
|
|
141
|
+
query[arg] = value if value.to_s.present?
|
|
141
142
|
end
|
|
142
|
-
|
|
143
|
+
URI.encode_www_form(params)
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
# Create the 'api_methods' instance method to retrieve an array of API methods previously created.
|
|
@@ -150,12 +151,20 @@ module SlimpayClient
|
|
|
150
151
|
# => [apps, creditors, direct_debits, mandates, orders, recurrent_direct_debits, subscribers, ...]
|
|
151
152
|
def list_api_methods(methods)
|
|
152
153
|
@methods ||= methods
|
|
153
|
-
self.class.send(:define_method,
|
|
154
|
+
self.class.send(:define_method, "api_methods") do
|
|
154
155
|
@methods = @methods.merge(methods) if @methods != methods
|
|
155
156
|
@methods
|
|
156
157
|
end
|
|
157
158
|
end
|
|
158
159
|
|
|
160
|
+
# GET a resource by its full URL, raise on API errors and generate methods from the returned links.
|
|
161
|
+
def get_resource(url)
|
|
162
|
+
response = HTTParty.get(url, headers: options)
|
|
163
|
+
answer = SlimpayClient.answer(response)
|
|
164
|
+
generate_api_methods(JSON.parse(answer)) if answer.is_a?(String)
|
|
165
|
+
answer
|
|
166
|
+
end
|
|
167
|
+
|
|
159
168
|
# Catch up potential errors and generate new methods if needed.
|
|
160
169
|
def follow_up_api(response)
|
|
161
170
|
answer = SlimpayClient.answer(response)
|
|
@@ -165,19 +174,19 @@ module SlimpayClient
|
|
|
165
174
|
|
|
166
175
|
def oauth_options
|
|
167
176
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
177
|
+
"Accept" => "application/json",
|
|
178
|
+
"Content-type" => "application/x-www-form-urlencoded",
|
|
179
|
+
"grant_type" => "client_credentials",
|
|
180
|
+
"scope" => "api"
|
|
172
181
|
}
|
|
173
182
|
end
|
|
174
183
|
|
|
175
184
|
def options
|
|
176
|
-
{
|
|
185
|
+
{ "Authorization" => "Bearer #{@token}", "Content-type" => "application/json" }
|
|
177
186
|
end
|
|
178
187
|
|
|
179
188
|
def sandbox?
|
|
180
|
-
@sandbox || @client_id.eql?(
|
|
189
|
+
@sandbox || @client_id.eql?(SANDBOX_CLIENT_ID) ? true : false
|
|
181
190
|
end
|
|
182
191
|
end
|
|
183
192
|
end
|
data/lib/slimpay_client/card.rb
CHANGED
|
@@ -1,18 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API CardAlias non-semantic methods.
|
|
4
|
+
# Defines API Card methods.
|
|
5
5
|
class Card < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(id = 1)
|
|
12
7
|
url = "#{@endpoint}/cards/#{id}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
end
|
|
18
11
|
end
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API CardAlias non-semantic methods.
|
|
4
|
+
# Defines API CardAlias methods.
|
|
5
5
|
class CardAlias < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(id = 1)
|
|
12
7
|
url = "#{@endpoint}/card_aliases/#{id}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
end
|
|
18
11
|
end
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
4
|
+
# Holds credentials, environment and callback URLs. See SlimpayClient.configure.
|
|
2
5
|
class Configuration
|
|
3
|
-
attr_accessor :client_id
|
|
4
|
-
|
|
5
|
-
attr_accessor :creditor_reference
|
|
6
|
-
attr_accessor :sandbox
|
|
7
|
-
attr_accessor :success_url
|
|
8
|
-
attr_accessor :failure_url
|
|
9
|
-
attr_accessor :cancel_url
|
|
10
|
-
attr_accessor :return_url
|
|
11
|
-
attr_accessor :notify_url
|
|
12
|
-
attr_accessor :username
|
|
13
|
-
attr_accessor :password
|
|
6
|
+
attr_accessor :client_id, :client_secret, :creditor_reference, :sandbox, :success_url, :failure_url, :cancel_url,
|
|
7
|
+
:return_url, :notify_url, :username, :password
|
|
14
8
|
|
|
15
9
|
def initialize
|
|
16
10
|
@client_id = SlimpayClient::SANDBOX_CLIENT_ID
|
|
17
11
|
@client_secret = SlimpayClient::SANDBOX_SECRET_ID
|
|
18
12
|
@creditor_reference = SlimpayClient::SANDBOX_CREDITOR
|
|
19
13
|
@sandbox = true
|
|
20
|
-
@success_url =
|
|
21
|
-
@failure_url =
|
|
22
|
-
@cancel_url =
|
|
23
|
-
@return_url =
|
|
24
|
-
@notify_url =
|
|
14
|
+
@success_url = "localhost:5000"
|
|
15
|
+
@failure_url = "localhost:5000"
|
|
16
|
+
@cancel_url = "localhost:5000"
|
|
17
|
+
@return_url = "localhost:5000"
|
|
18
|
+
@notify_url = "localhost:5000"
|
|
25
19
|
end
|
|
26
20
|
end
|
|
27
21
|
end
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API Creditor non-semantic methods.
|
|
4
|
+
# Defines API Creditor methods.
|
|
5
5
|
class Creditor < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(reference = 1)
|
|
12
7
|
url = "#{@endpoint}/creditors/#{reference}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
end
|
|
18
11
|
end
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
4
|
+
# Defines API DirectDebit methods.
|
|
2
5
|
class DirectDebit < Resource
|
|
3
6
|
# Override the Resource#get_one method because the url is not the same for DirectDebits
|
|
4
7
|
#
|
|
5
8
|
def get_one(reference = 1)
|
|
6
9
|
url = "#{@endpoint}/#{@resource_name}/#{reference}"
|
|
7
|
-
|
|
8
|
-
generate_api_methods(JSON.parse(response.body))
|
|
9
|
-
SlimpayClient.answer(response)
|
|
10
|
+
get_resource(url)
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
# Alias method for create_direct_debits
|
|
@@ -16,7 +17,7 @@ module SlimpayClient
|
|
|
16
17
|
# /!\ Amount as to be rounded to maximum 2 numbers after comma.
|
|
17
18
|
# If not you'll receive an error : { "code" : 100, "message" : "Internal error : Rounding necessary" }
|
|
18
19
|
def make_payment(debit_hash = default_debit_hash)
|
|
19
|
-
|
|
20
|
+
create_direct_debits(debit_hash)
|
|
20
21
|
end
|
|
21
22
|
|
|
22
23
|
private
|
|
@@ -27,11 +28,11 @@ module SlimpayClient
|
|
|
27
28
|
reference: @creditor_reference
|
|
28
29
|
},
|
|
29
30
|
mandate: {
|
|
30
|
-
rum:
|
|
31
|
+
rum: "1"
|
|
31
32
|
},
|
|
32
33
|
amount: 100.00,
|
|
33
|
-
label:
|
|
34
|
-
paymentReference:
|
|
34
|
+
label: "The label",
|
|
35
|
+
paymentReference: "Payment 123"
|
|
35
36
|
}
|
|
36
37
|
end
|
|
37
38
|
end
|
data/lib/slimpay_client/error.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
4
|
# To display SlimpayClient error messages with the HTTP code.
|
|
3
5
|
#
|
|
@@ -10,9 +12,10 @@ module SlimpayClient
|
|
|
10
12
|
# * code: 205, message: "Client data are inconsistent : missing query parameters creditorReference and/or rum"
|
|
11
13
|
class Error < StandardError
|
|
12
14
|
attr_reader :message
|
|
15
|
+
|
|
13
16
|
# If the HTTP response is nil or empty returns an actual message.
|
|
14
17
|
def self.empty
|
|
15
|
-
@message = {code: 418, message:
|
|
18
|
+
@message = { code: 418, message: "The answer was empty." }
|
|
16
19
|
end
|
|
17
20
|
|
|
18
21
|
# Returns either formated error with its HTTP code or the raw HTTP response.
|
|
@@ -24,7 +27,7 @@ module SlimpayClient
|
|
|
24
27
|
else
|
|
25
28
|
@message = JSON.parse(http_response.body)
|
|
26
29
|
end
|
|
27
|
-
|
|
30
|
+
raise self, @message.to_s
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
def to_s
|
|
@@ -51,29 +54,29 @@ module SlimpayClient
|
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
def bad_request(http_message)
|
|
54
|
-
{code: 400, message: "HTTP Bad Request. #{slimpay_error(http_message)}"}
|
|
57
|
+
{ code: 400, message: "HTTP Bad Request. #{slimpay_error(http_message)}" }
|
|
55
58
|
end
|
|
56
59
|
|
|
57
60
|
def unauthorized(http_message)
|
|
58
|
-
{code: 401, message: "HTTP Unauthorized. #{slimpay_error(http_message)}"}
|
|
61
|
+
{ code: 401, message: "HTTP Unauthorized. #{slimpay_error(http_message)}" }
|
|
59
62
|
end
|
|
60
63
|
|
|
61
64
|
def forbidden(http_message)
|
|
62
|
-
{code: 403, message: "HTTP Forbidden. #{slimpay_error(http_message)}"}
|
|
65
|
+
{ code: 403, message: "HTTP Forbidden. #{slimpay_error(http_message)}" }
|
|
63
66
|
end
|
|
64
67
|
|
|
65
68
|
def not_found
|
|
66
|
-
{code: 404, message:
|
|
69
|
+
{ code: 404, message: "URI not found." }
|
|
67
70
|
end
|
|
68
71
|
|
|
69
72
|
def not_acceptable(http_message)
|
|
70
|
-
{code: 406, message: "HTTP Not Acceptable. #{slimpay_error(http_message)}"}
|
|
73
|
+
{ code: 406, message: "HTTP Not Acceptable. #{slimpay_error(http_message)}" }
|
|
71
74
|
end
|
|
72
75
|
|
|
73
76
|
def slimpay_error(http_message)
|
|
74
77
|
slimpay_error = http_message.is_a?(Hash) ? http_message : JSON.parse(http_message.body)
|
|
75
|
-
slimpay_code = slimpay_error[
|
|
76
|
-
slimpay_message = slimpay_error[
|
|
78
|
+
slimpay_code = slimpay_error["code"]
|
|
79
|
+
slimpay_message = slimpay_error["message"] || slimpay_error["error_description"]
|
|
77
80
|
"SlimpayClient #{slimpay_code} : #{slimpay_message}"
|
|
78
81
|
end
|
|
79
82
|
end
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
4
|
+
# Defines API Mandate methods.
|
|
2
5
|
class Mandate < Resource
|
|
3
6
|
# POST
|
|
4
|
-
def revoke(id =
|
|
7
|
+
def revoke(id = "mandate01")
|
|
5
8
|
url = "mandates/#{id}/revocation"
|
|
6
9
|
body_options = {}
|
|
7
10
|
response = HTTParty.post("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
|
|
8
11
|
follow_up_api(response)
|
|
9
12
|
end
|
|
10
13
|
|
|
11
|
-
def document(id =
|
|
14
|
+
def document(id = "mandate01")
|
|
12
15
|
url = "mandates/#{id}/document"
|
|
13
16
|
body_options = {}
|
|
14
17
|
response = HTTParty.get("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
|
data/lib/slimpay_client/order.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
# Inherits from
|
|
4
|
+
# Inherits from Resource and thus defines its associated resource's methods.
|
|
3
5
|
#
|
|
4
6
|
# Defines shortcut methods for the create_order method with various arguments.
|
|
5
7
|
class Order < Resource
|
|
@@ -32,8 +34,8 @@ module SlimpayClient
|
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
# POST
|
|
35
|
-
def login(reference =
|
|
36
|
-
url =
|
|
37
|
+
def login(reference = "subscriber01")
|
|
38
|
+
url = "orders"
|
|
37
39
|
body_options = {
|
|
38
40
|
creditor: {
|
|
39
41
|
reference: @creditor_reference
|
|
@@ -43,7 +45,7 @@ module SlimpayClient
|
|
|
43
45
|
},
|
|
44
46
|
items: [
|
|
45
47
|
{
|
|
46
|
-
type:
|
|
48
|
+
type: "subscriberLogin"
|
|
47
49
|
}
|
|
48
50
|
],
|
|
49
51
|
started: true
|
|
@@ -58,12 +60,13 @@ module SlimpayClient
|
|
|
58
60
|
# In case of success, this will generate a method accessible via the _.api_methods_ method.
|
|
59
61
|
# This method let you redirect the customer to the approval page : orders.api_methods['user_approval']
|
|
60
62
|
# ===== Arguments
|
|
61
|
-
# reference: (String) The reference to your User in your application. Use a unique key.
|
|
63
|
+
# reference: (String) The reference to your User in your application. Use a unique key.
|
|
64
|
+
# Slimpay will refer to it for future answers.
|
|
62
65
|
# signatory: (Hash) Your customer informations. See API Order documentation for details.
|
|
63
66
|
# ===== Returns
|
|
64
67
|
# a Hash representing the Mandate.
|
|
65
|
-
def sign_mandate(reference =
|
|
66
|
-
url =
|
|
68
|
+
def sign_mandate(reference = "subscriber01", signatory = default_signatory)
|
|
69
|
+
url = "orders"
|
|
67
70
|
body_options = {
|
|
68
71
|
creditor: {
|
|
69
72
|
reference: @creditor_reference
|
|
@@ -73,9 +76,9 @@ module SlimpayClient
|
|
|
73
76
|
},
|
|
74
77
|
items: [
|
|
75
78
|
{
|
|
76
|
-
type:
|
|
79
|
+
type: "signMandate",
|
|
77
80
|
mandate: {
|
|
78
|
-
standard:
|
|
81
|
+
standard: "SEPA",
|
|
79
82
|
signatory: signatory
|
|
80
83
|
}
|
|
81
84
|
}
|
|
@@ -90,17 +93,17 @@ module SlimpayClient
|
|
|
90
93
|
|
|
91
94
|
def default_signatory
|
|
92
95
|
{
|
|
93
|
-
honorificPrefix:
|
|
94
|
-
familyName:
|
|
95
|
-
givenName:
|
|
96
|
-
telephone:
|
|
97
|
-
email:
|
|
96
|
+
honorificPrefix: "Mr",
|
|
97
|
+
familyName: "Doe",
|
|
98
|
+
givenName: "John",
|
|
99
|
+
telephone: "+33612345678",
|
|
100
|
+
email: "john.doe@gmail.com",
|
|
98
101
|
billingAddress: {
|
|
99
|
-
street1:
|
|
100
|
-
street2:
|
|
101
|
-
postalCode:
|
|
102
|
-
city:
|
|
103
|
-
country:
|
|
102
|
+
street1: "27 rue des fleurs",
|
|
103
|
+
street2: "Bat 2",
|
|
104
|
+
postalCode: "75008",
|
|
105
|
+
city: "Paris",
|
|
106
|
+
country: "FR"
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
end
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API Payment non-semantic methods.
|
|
4
|
+
# Defines API Payment methods.
|
|
5
5
|
class Payment < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(id = 1)
|
|
12
7
|
url = "#{@endpoint}/payments/#{id}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
|
|
18
11
|
def issues(id = 1)
|
|
19
12
|
url = "#{@endpoint}/payments/#{id}/issues"
|
|
20
|
-
|
|
21
|
-
generate_api_methods(JSON.parse(response.body))
|
|
22
|
-
SlimpayClient.answer(response)
|
|
13
|
+
get_resource(url)
|
|
23
14
|
end
|
|
24
15
|
|
|
25
16
|
def refund(id, amount)
|
|
26
17
|
url = "payments/#{id}/refund"
|
|
27
|
-
body_options = {amount: amount}
|
|
18
|
+
body_options = { amount: amount }
|
|
28
19
|
response = HTTParty.post("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
|
|
29
20
|
follow_up_api(response)
|
|
30
21
|
end
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API CardAlias non-semantic methods.
|
|
4
|
+
# Defines API RecurrentCardTransaction methods.
|
|
5
5
|
class RecurrentCardTransaction < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(id = 1)
|
|
12
7
|
url = "#{@endpoint}/recurrent_card_transaction/#{id}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
|
|
18
|
-
def cancel(id =
|
|
11
|
+
def cancel(id = "card-transac-1")
|
|
19
12
|
url = "recurrent-card-transactions/#{id}/cancellation"
|
|
20
13
|
body_options = {}
|
|
21
14
|
response = HTTParty.post("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Defines API CardAlias non-semantic methods.
|
|
4
|
+
# Defines API RecurrentDirectDebit methods.
|
|
5
5
|
class RecurrentDirectDebit < Resource
|
|
6
|
-
def initialize
|
|
7
|
-
@resource_name = self.class.to_s.demodulize.underscore.dasherize.pluralize
|
|
8
|
-
super
|
|
9
|
-
end
|
|
10
|
-
|
|
11
6
|
def get_one(id = 1)
|
|
12
7
|
url = "#{@endpoint}/recurrent-direct-debits/#{id}"
|
|
13
|
-
|
|
14
|
-
generate_api_methods(JSON.parse(response.body))
|
|
15
|
-
SlimpayClient.answer(response)
|
|
8
|
+
get_resource(url)
|
|
16
9
|
end
|
|
17
10
|
|
|
18
|
-
def cancel(id =
|
|
11
|
+
def cancel(id = "rec-direct-debit1")
|
|
19
12
|
url = "recurrent-direct-debits/#{id}/cancellation"
|
|
20
13
|
body_options = {}
|
|
21
14
|
response = HTTParty.post("#{@endpoint}/#{url}", body: body_options.to_json, headers: options)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module SlimpayClient
|
|
2
4
|
# An abstract resource to be inherited from.
|
|
3
5
|
#
|
|
@@ -21,9 +23,7 @@ module SlimpayClient
|
|
|
21
23
|
# reference: (String)
|
|
22
24
|
def get_one(reference = 1)
|
|
23
25
|
url = "#{@endpoint}/creditors/#{@creditor_reference}/#{@resource_name}/#{reference}"
|
|
24
|
-
|
|
25
|
-
generate_api_methods(JSON.parse(response.body))
|
|
26
|
-
SlimpayClient.answer(response)
|
|
26
|
+
get_resource(url)
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
end
|
data/lib/slimpay_client.rb
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "slimpay_client/version"
|
|
4
|
-
require
|
|
5
|
-
require
|
|
4
|
+
require "json"
|
|
5
|
+
require "uri"
|
|
6
|
+
require "oauth2"
|
|
7
|
+
require "httparty"
|
|
6
8
|
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
+
require "active_support/core_ext/string/inflections"
|
|
10
|
+
require "active_support/core_ext/object/blank"
|
|
9
11
|
|
|
12
|
+
require "slimpay_client/configuration"
|
|
13
|
+
require "slimpay_client/error"
|
|
14
|
+
require "slimpay_client/base"
|
|
15
|
+
require "slimpay_client/resource"
|
|
16
|
+
require "slimpay_client/app"
|
|
17
|
+
require "slimpay_client/mandate"
|
|
18
|
+
require "slimpay_client/order"
|
|
19
|
+
require "slimpay_client/direct_debit"
|
|
20
|
+
require "slimpay_client/creditor"
|
|
21
|
+
require "slimpay_client/card_alias"
|
|
22
|
+
require "slimpay_client/card"
|
|
23
|
+
require "slimpay_client/recurrent_card_transaction"
|
|
24
|
+
require "slimpay_client/recurrent_direct_debit"
|
|
25
|
+
require "slimpay_client/payment"
|
|
10
26
|
|
|
11
|
-
require
|
|
12
|
-
require 'slimpay_client/error'
|
|
13
|
-
require 'slimpay_client/base'
|
|
14
|
-
require 'slimpay_client/resource'
|
|
15
|
-
require 'slimpay_client/app'
|
|
16
|
-
require 'slimpay_client/mandate'
|
|
17
|
-
require 'slimpay_client/order'
|
|
18
|
-
require 'slimpay_client/direct_debit'
|
|
19
|
-
require 'slimpay_client/creditor'
|
|
20
|
-
require 'slimpay_client/card_alias'
|
|
21
|
-
require 'slimpay_client/card'
|
|
22
|
-
require 'slimpay_client/recurrent_card_transaction'
|
|
23
|
-
require 'slimpay_client/recurrent_direct_debit'
|
|
24
|
-
require 'slimpay_client/payment'
|
|
25
|
-
|
|
26
|
-
# SlimpayClient module defines Simpay's HAPI constants and require dependencies.
|
|
27
|
+
# SlimpayClient module defines Slimpay's HAPI constants and require dependencies.
|
|
27
28
|
# TODO: If-None-Match support. (next answer ?= 304)
|
|
28
|
-
# TODO: wiki/doc full
|
|
29
|
+
# TODO: wiki/doc full workflow: 1. App to change URLs, 2. Order to sign mandate, 3. DirectDebit to pay with mandate.
|
|
29
30
|
module SlimpayClient
|
|
30
|
-
PRODUCTION_ENDPOINT =
|
|
31
|
-
SANDBOX_ENDPOINT =
|
|
32
|
-
SANDBOX_CLIENT_ID =
|
|
33
|
-
SANDBOX_SECRET_ID =
|
|
34
|
-
SANDBOX_CREDITOR =
|
|
31
|
+
PRODUCTION_ENDPOINT = "https://api.slimpay.net"
|
|
32
|
+
SANDBOX_ENDPOINT = "https://api.preprod.slimpay.com"
|
|
33
|
+
SANDBOX_CLIENT_ID = "democreditor01"
|
|
34
|
+
SANDBOX_SECRET_ID = "demosecret01"
|
|
35
|
+
SANDBOX_CREDITOR = "democreditor"
|
|
36
|
+
API_HEADER = 'application/hal+json; profile="https://api.slimpay.net/alps/v1"'
|
|
35
37
|
|
|
36
38
|
class << self
|
|
37
39
|
attr_accessor :configuration
|
|
@@ -60,8 +62,7 @@ module SlimpayClient
|
|
|
60
62
|
# ===== Arguments:
|
|
61
63
|
# http_response: (HTTParty::Response)
|
|
62
64
|
def self.answer(http_response)
|
|
63
|
-
|
|
64
|
-
return SlimpayClient::Error.empty if ( http_response.blank? || http_response.body.blank? )
|
|
65
|
+
return SlimpayClient::Error.empty if http_response.blank? || http_response.body.blank?
|
|
65
66
|
|
|
66
67
|
if http_response.code >= 400
|
|
67
68
|
SlimpayClient::Error.new(http_response)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slimpay_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Idrissa Bara
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,28 +16,40 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
19
|
+
version: '7.0'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '9'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
27
|
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
29
|
+
version: '7.0'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '9'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: httparty
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
37
|
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.24
|
|
39
|
+
version: '0.24'
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 0.24.3
|
|
34
43
|
type: :runtime
|
|
35
44
|
prerelease: false
|
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
46
|
requirements:
|
|
38
47
|
- - "~>"
|
|
39
48
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.24
|
|
49
|
+
version: '0.24'
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 0.24.3
|
|
41
53
|
- !ruby/object:Gem::Dependency
|
|
42
54
|
name: oauth2
|
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -47,7 +59,7 @@ dependencies:
|
|
|
47
59
|
version: '2.0'
|
|
48
60
|
- - ">="
|
|
49
61
|
- !ruby/object:Gem::Version
|
|
50
|
-
version: 2.0.
|
|
62
|
+
version: 2.0.12
|
|
51
63
|
type: :runtime
|
|
52
64
|
prerelease: false
|
|
53
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -57,7 +69,7 @@ dependencies:
|
|
|
57
69
|
version: '2.0'
|
|
58
70
|
- - ">="
|
|
59
71
|
- !ruby/object:Gem::Version
|
|
60
|
-
version: 2.0.
|
|
72
|
+
version: 2.0.12
|
|
61
73
|
- !ruby/object:Gem::Dependency
|
|
62
74
|
name: bundler
|
|
63
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -78,14 +90,14 @@ dependencies:
|
|
|
78
90
|
requirements:
|
|
79
91
|
- - "~>"
|
|
80
92
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '13.
|
|
93
|
+
version: '13.4'
|
|
82
94
|
type: :development
|
|
83
95
|
prerelease: false
|
|
84
96
|
version_requirements: !ruby/object:Gem::Requirement
|
|
85
97
|
requirements:
|
|
86
98
|
- - "~>"
|
|
87
99
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '13.
|
|
100
|
+
version: '13.4'
|
|
89
101
|
- !ruby/object:Gem::Dependency
|
|
90
102
|
name: rspec
|
|
91
103
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -106,54 +118,42 @@ dependencies:
|
|
|
106
118
|
requirements:
|
|
107
119
|
- - "~>"
|
|
108
120
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: '1.
|
|
110
|
-
- - ">="
|
|
111
|
-
- !ruby/object:Gem::Version
|
|
112
|
-
version: 1.65.1
|
|
121
|
+
version: '1.92'
|
|
113
122
|
type: :development
|
|
114
123
|
prerelease: false
|
|
115
124
|
version_requirements: !ruby/object:Gem::Requirement
|
|
116
125
|
requirements:
|
|
117
126
|
- - "~>"
|
|
118
127
|
- !ruby/object:Gem::Version
|
|
119
|
-
version: '1.
|
|
120
|
-
- - ">="
|
|
121
|
-
- !ruby/object:Gem::Version
|
|
122
|
-
version: 1.65.1
|
|
128
|
+
version: '1.92'
|
|
123
129
|
- !ruby/object:Gem::Dependency
|
|
124
130
|
name: vcr
|
|
125
131
|
requirement: !ruby/object:Gem::Requirement
|
|
126
132
|
requirements:
|
|
127
133
|
- - "~>"
|
|
128
134
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: '6.
|
|
135
|
+
version: '6.4'
|
|
130
136
|
type: :development
|
|
131
137
|
prerelease: false
|
|
132
138
|
version_requirements: !ruby/object:Gem::Requirement
|
|
133
139
|
requirements:
|
|
134
140
|
- - "~>"
|
|
135
141
|
- !ruby/object:Gem::Version
|
|
136
|
-
version: '6.
|
|
142
|
+
version: '6.4'
|
|
137
143
|
- !ruby/object:Gem::Dependency
|
|
138
144
|
name: webmock
|
|
139
145
|
requirement: !ruby/object:Gem::Requirement
|
|
140
146
|
requirements:
|
|
141
147
|
- - "~>"
|
|
142
148
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: '3.
|
|
144
|
-
- - ">="
|
|
145
|
-
- !ruby/object:Gem::Version
|
|
146
|
-
version: 3.23.1
|
|
149
|
+
version: '3.36'
|
|
147
150
|
type: :development
|
|
148
151
|
prerelease: false
|
|
149
152
|
version_requirements: !ruby/object:Gem::Requirement
|
|
150
153
|
requirements:
|
|
151
154
|
- - "~>"
|
|
152
155
|
- !ruby/object:Gem::Version
|
|
153
|
-
version: '3.
|
|
154
|
-
- - ">="
|
|
155
|
-
- !ruby/object:Gem::Version
|
|
156
|
-
version: 3.23.1
|
|
156
|
+
version: '3.36'
|
|
157
157
|
description: Ruby library for Slimpay's API.
|
|
158
158
|
email:
|
|
159
159
|
- bara.idris@gmail.com
|
|
@@ -163,6 +163,7 @@ extra_rdoc_files: []
|
|
|
163
163
|
files:
|
|
164
164
|
- ".rspec"
|
|
165
165
|
- ".rubocop.yml"
|
|
166
|
+
- ".rubocop_todo.yml"
|
|
166
167
|
- CHANGELOG.md
|
|
167
168
|
- CODE_OF_CONDUCT.md
|
|
168
169
|
- Gemfile
|
|
@@ -192,6 +193,7 @@ licenses:
|
|
|
192
193
|
metadata:
|
|
193
194
|
homepage_uri: https://github.com/baraidrissa/slimpay_client
|
|
194
195
|
source_code_uri: https://github.com/baraidrissa/slimpay_client
|
|
196
|
+
rubygems_mfa_required: 'true'
|
|
195
197
|
changelog_uri: https://github.com/baraidrissa/slimpay_client/blob/main/CHANGELOG.md
|
|
196
198
|
post_install_message: Please refer to Slimpay's API https://dev.slimpay.com for more
|
|
197
199
|
informations.
|
|
@@ -202,7 +204,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
202
204
|
requirements:
|
|
203
205
|
- - ">="
|
|
204
206
|
- !ruby/object:Gem::Version
|
|
205
|
-
version: 2.
|
|
207
|
+
version: 3.2.0
|
|
206
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
209
|
requirements:
|
|
208
210
|
- - ">="
|