mangopay 3.0.25 → 3.0.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +30 -28
- data/.rspec +2 -2
- data/.travis.yml +13 -4
- data/Gemfile +2 -2
- data/LICENSE +20 -20
- data/README.md +126 -126
- data/bin/mangopay +9 -9
- data/lib/generators/mangopay/install_generator.rb +60 -60
- data/lib/generators/templates/mangopay.rb.erb +5 -5
- data/lib/mangopay.rb +228 -225
- data/lib/mangopay/authorization_token.rb +88 -88
- data/lib/mangopay/bank_account.rb +38 -38
- data/lib/mangopay/bankingaliases.rb +29 -0
- data/lib/mangopay/bankingaliases_iban.rb +16 -0
- data/lib/mangopay/card.rb +8 -8
- data/lib/mangopay/card_registration.rb +9 -9
- data/lib/mangopay/client.rb +74 -74
- data/lib/mangopay/dispute.rb +130 -130
- data/lib/mangopay/errors.rb +61 -61
- data/lib/mangopay/event.rb +18 -18
- data/lib/mangopay/filter_parameters.rb +46 -46
- data/lib/mangopay/hook.rb +9 -9
- data/lib/mangopay/http_calls.rb +85 -85
- data/lib/mangopay/json.rb +14 -14
- data/lib/mangopay/kyc_document.rb +70 -70
- data/lib/mangopay/legal_user.rb +15 -15
- data/lib/mangopay/mandate.rb +32 -32
- data/lib/mangopay/natural_user.rb +14 -14
- data/lib/mangopay/pay_in.rb +96 -85
- data/lib/mangopay/pay_out.rb +14 -14
- data/lib/mangopay/pre_authorization.rb +13 -13
- data/lib/mangopay/refund.rb +7 -7
- data/lib/mangopay/report.rb +17 -17
- data/lib/mangopay/resource.rb +21 -21
- data/lib/mangopay/transaction.rb +24 -24
- data/lib/mangopay/transfer.rb +9 -9
- data/lib/mangopay/user.rb +43 -43
- data/lib/mangopay/version.rb +3 -3
- data/lib/mangopay/wallet.rb +17 -17
- data/mangopay.gemspec +30 -30
- data/spec/mangopay/authorization_token_spec.rb +70 -70
- data/spec/mangopay/bank_account_spec.rb +97 -97
- data/spec/mangopay/bankingaliases_spec.rb +29 -0
- data/spec/mangopay/card_registration_spec.rb +73 -73
- data/spec/mangopay/client_spec.rb +110 -110
- data/spec/mangopay/configuration_spec.rb +95 -95
- data/spec/mangopay/dispute_spec.rb +262 -262
- data/spec/mangopay/event_spec.rb +31 -31
- data/spec/mangopay/fetch_filters_spec.rb +63 -63
- data/spec/mangopay/hook_spec.rb +37 -37
- data/spec/mangopay/idempotency_spec.rb +41 -41
- data/spec/mangopay/kyc_document_spec.rb +103 -103
- data/spec/mangopay/log_requests_filter_spec.rb +25 -25
- data/spec/mangopay/mandate_spec.rb +92 -92
- data/spec/mangopay/payin_bankwire_direct_spec.rb +74 -74
- data/spec/mangopay/payin_card_direct_spec.rb +68 -68
- data/spec/mangopay/payin_card_web_spec.rb +47 -38
- data/spec/mangopay/payin_directdebit_direct_spec.rb +37 -37
- data/spec/mangopay/payin_directdebit_web_spec.rb +38 -38
- data/spec/mangopay/payin_paypal_web_spec.rb +38 -38
- data/spec/mangopay/payin_preauthorized_direct_spec.rb +68 -68
- data/spec/mangopay/payout_bankwire_spec.rb +54 -54
- data/spec/mangopay/preauthorization_spec.rb +42 -42
- data/spec/mangopay/refund_spec.rb +21 -21
- data/spec/mangopay/report_spec.rb +39 -39
- data/spec/mangopay/shared_resources.rb +397 -381
- data/spec/mangopay/transaction_spec.rb +54 -54
- data/spec/mangopay/transfer_spec.rb +69 -69
- data/spec/mangopay/user_spec.rb +137 -137
- data/spec/mangopay/wallet_spec.rb +80 -80
- data/spec/spec_helper.rb +31 -31
- metadata +7 -6
- data/lib/mangopay/temp.rb +0 -74
- data/spec/mangopay/temp_paymentcard_spec.rb +0 -31
data/lib/mangopay/hook.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See http://docs.mangopay.com/api-references/notifications/
|
4
|
-
class Hook < Resource
|
5
|
-
include HTTPCalls::Create
|
6
|
-
include HTTPCalls::Update
|
7
|
-
include HTTPCalls::Fetch
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See http://docs.mangopay.com/api-references/notifications/
|
4
|
+
class Hook < Resource
|
5
|
+
include HTTPCalls::Create
|
6
|
+
include HTTPCalls::Update
|
7
|
+
include HTTPCalls::Fetch
|
8
|
+
end
|
9
|
+
end
|
data/lib/mangopay/http_calls.rb
CHANGED
@@ -1,85 +1,85 @@
|
|
1
|
-
module MangoPay
|
2
|
-
module HTTPCalls
|
3
|
-
module Create
|
4
|
-
module ClassMethods
|
5
|
-
|
6
|
-
def create(params, id = nil, idempotency_key = nil)
|
7
|
-
# LEGACY SUPPORT FOR OLD SIGNATURE: def create(*id, params)
|
8
|
-
if !params.is_a?(Hash) && id.is_a?(Hash)
|
9
|
-
temp = params
|
10
|
-
params = id
|
11
|
-
id = temp
|
12
|
-
end
|
13
|
-
MangoPay.request(:post, url(id), params, {}, idempotency_key)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.included(base)
|
18
|
-
base.extend(ClassMethods)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
module Update
|
23
|
-
module ClassMethods
|
24
|
-
def update(id = nil, params = {})
|
25
|
-
MangoPay.request(:put, url(id), params)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.included(base)
|
30
|
-
base.extend(ClassMethods)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module Fetch
|
35
|
-
module ClassMethods
|
36
|
-
|
37
|
-
# - Fetching _single_entity_ by +id+:
|
38
|
-
#
|
39
|
-
# MangoPay::User.fetch("user-id") # => {"FirstName"=>"Mango", "LastName"=>"Pay", ...}
|
40
|
-
#
|
41
|
-
# - or fetching _multiple_entities_ with _optional_ +filters+ hash,
|
42
|
-
# including _pagination_ and _sorting_ params
|
43
|
-
# +page+, +per_page+, +sort+ (see http://docs.mangopay.com/api-references/pagination/):
|
44
|
-
#
|
45
|
-
# MangoPay::User.fetch() # => [{...}, ...]: list of user data hashes (10 per page by default)
|
46
|
-
# MangoPay::User.fetch({'page' => 2, 'per_page' => 3}) # => list of 3 hashes from 2nd page
|
47
|
-
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc'}) # => bank accounts by user, sorting by date descending (with default pagination)
|
48
|
-
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc', 'page' => 2, 'per_page' => 3}) # both sorting and pagination params provided
|
49
|
-
#
|
50
|
-
# - For paginated queries the +filters+ param will be supplemented by +total_pages+ and +total_items+ info:
|
51
|
-
#
|
52
|
-
# MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3})
|
53
|
-
# filter # => {"page"=>2, "per_page"=>3, "total_pages"=>1969, "total_items"=>5905}
|
54
|
-
#
|
55
|
-
def fetch(id_or_filters = nil)
|
56
|
-
id, filters = HTTPCalls::Fetch.parse_id_or_filters(id_or_filters)
|
57
|
-
response = MangoPay.request(:get, url(id), {}, filters)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.included(base)
|
62
|
-
base.extend(ClassMethods)
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.parse_id_or_filters(id_or_filters = nil)
|
66
|
-
id_or_filters.is_a?(Hash) ? [nil, id_or_filters] : [id_or_filters, {}]
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
module Refund
|
71
|
-
module ClassMethods
|
72
|
-
|
73
|
-
# See http://docs.mangopay.com/api-references/refund/%E2%80%A2-refund-a-pay-in/
|
74
|
-
# See http://docs.mangopay.com/api-references/refund/%E2%80%A2-refund-a-transfer/
|
75
|
-
def refund(id = nil, params = {}, idempotency_key = nil)
|
76
|
-
MangoPay.request(:post, url(id) + '/refunds', params, {}, idempotency_key)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.included(base)
|
81
|
-
base.extend(ClassMethods)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
module HTTPCalls
|
3
|
+
module Create
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
def create(params, id = nil, idempotency_key = nil)
|
7
|
+
# LEGACY SUPPORT FOR OLD SIGNATURE: def create(*id, params)
|
8
|
+
if !params.is_a?(Hash) && id.is_a?(Hash)
|
9
|
+
temp = params
|
10
|
+
params = id
|
11
|
+
id = temp
|
12
|
+
end
|
13
|
+
MangoPay.request(:post, url(id), params, {}, idempotency_key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
base.extend(ClassMethods)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Update
|
23
|
+
module ClassMethods
|
24
|
+
def update(id = nil, params = {})
|
25
|
+
MangoPay.request(:put, url(id), params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.included(base)
|
30
|
+
base.extend(ClassMethods)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Fetch
|
35
|
+
module ClassMethods
|
36
|
+
|
37
|
+
# - Fetching _single_entity_ by +id+:
|
38
|
+
#
|
39
|
+
# MangoPay::User.fetch("user-id") # => {"FirstName"=>"Mango", "LastName"=>"Pay", ...}
|
40
|
+
#
|
41
|
+
# - or fetching _multiple_entities_ with _optional_ +filters+ hash,
|
42
|
+
# including _pagination_ and _sorting_ params
|
43
|
+
# +page+, +per_page+, +sort+ (see http://docs.mangopay.com/api-references/pagination/):
|
44
|
+
#
|
45
|
+
# MangoPay::User.fetch() # => [{...}, ...]: list of user data hashes (10 per page by default)
|
46
|
+
# MangoPay::User.fetch({'page' => 2, 'per_page' => 3}) # => list of 3 hashes from 2nd page
|
47
|
+
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc'}) # => bank accounts by user, sorting by date descending (with default pagination)
|
48
|
+
# MangoPay::BankAccount.fetch(user_id, {'sort' => 'CreationDate:desc', 'page' => 2, 'per_page' => 3}) # both sorting and pagination params provided
|
49
|
+
#
|
50
|
+
# - For paginated queries the +filters+ param will be supplemented by +total_pages+ and +total_items+ info:
|
51
|
+
#
|
52
|
+
# MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3})
|
53
|
+
# filter # => {"page"=>2, "per_page"=>3, "total_pages"=>1969, "total_items"=>5905}
|
54
|
+
#
|
55
|
+
def fetch(id_or_filters = nil)
|
56
|
+
id, filters = HTTPCalls::Fetch.parse_id_or_filters(id_or_filters)
|
57
|
+
response = MangoPay.request(:get, url(id), {}, filters)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.included(base)
|
62
|
+
base.extend(ClassMethods)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.parse_id_or_filters(id_or_filters = nil)
|
66
|
+
id_or_filters.is_a?(Hash) ? [nil, id_or_filters] : [id_or_filters, {}]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
module Refund
|
71
|
+
module ClassMethods
|
72
|
+
|
73
|
+
# See http://docs.mangopay.com/api-references/refund/%E2%80%A2-refund-a-pay-in/
|
74
|
+
# See http://docs.mangopay.com/api-references/refund/%E2%80%A2-refund-a-transfer/
|
75
|
+
def refund(id = nil, params = {}, idempotency_key = nil)
|
76
|
+
MangoPay.request(:post, url(id) + '/refunds', params, {}, idempotency_key)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.included(base)
|
81
|
+
base.extend(ClassMethods)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/mangopay/json.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# We can use MultiJson directly , why do we even have this module ?
|
2
|
-
module MangoPay
|
3
|
-
module JSON
|
4
|
-
class << self
|
5
|
-
def dump(*args)
|
6
|
-
MultiJson.dump(*args)
|
7
|
-
end
|
8
|
-
|
9
|
-
def load(*args)
|
10
|
-
MultiJson.load(*args)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# We can use MultiJson directly , why do we even have this module ?
|
2
|
+
module MangoPay
|
3
|
+
module JSON
|
4
|
+
class << self
|
5
|
+
def dump(*args)
|
6
|
+
MultiJson.dump(*args)
|
7
|
+
end
|
8
|
+
|
9
|
+
def load(*args)
|
10
|
+
MultiJson.load(*args)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,70 +1,70 @@
|
|
1
|
-
require 'base64'
|
2
|
-
|
3
|
-
module MangoPay
|
4
|
-
|
5
|
-
# See http://docs.mangopay.com/api-references/kyc/documents/
|
6
|
-
class KycDocument < Resource
|
7
|
-
class << self
|
8
|
-
def create(user_id, params, idempotency_key = nil)
|
9
|
-
MangoPay.request(:post, url(user_id), params, {}, idempotency_key)
|
10
|
-
end
|
11
|
-
|
12
|
-
def update(user_id, document_id, params = {})
|
13
|
-
MangoPay.request(:put, url(user_id, document_id), params)
|
14
|
-
end
|
15
|
-
|
16
|
-
# Fetches the KYC document belonging to the given +user_id+, with the given +document_id+.
|
17
|
-
def fetch(user_id, document_id)
|
18
|
-
url = (user_id) ? url(user_id, document_id) : "#{MangoPay.api_path}/KYC/documents/#{CGI.escape(document_id.to_s)}"
|
19
|
-
MangoPay.request(:get, url)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Fetches list of KYC documents:
|
23
|
-
# - for the particular user if +user_id+ is provided (not nil)
|
24
|
-
# - or for all users otherwise.
|
25
|
-
#
|
26
|
-
# Optional +filters+ is a hash accepting following keys:
|
27
|
-
# - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
28
|
-
# - filters such as +Type+ (e.g. 'IDENTITY_PROOF') and +Status+ (e.g. 'VALIDATED')
|
29
|
-
# - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
|
30
|
-
# - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
|
31
|
-
#
|
32
|
-
def fetch_all(user_id = nil, filters = {})
|
33
|
-
url = (user_id) ? url(user_id) : "#{MangoPay.api_path}/KYC/documents"
|
34
|
-
MangoPay.request(:get, url, {}, filters)
|
35
|
-
end
|
36
|
-
|
37
|
-
# Adds the file page (attachment) to the given document.
|
38
|
-
#
|
39
|
-
# See http://docs.mangopay.com/api-references/kyc/pages/ :
|
40
|
-
# - Document have to be in 'CREATED' Status
|
41
|
-
# - You can create as many pages as needed
|
42
|
-
# - Change Status to 'VALIDATION_ASKED' to submit KYC documents
|
43
|
-
#
|
44
|
-
# The file_content_base64 param may be:
|
45
|
-
# - Base64 encoded file content
|
46
|
-
# - or nil: in this case pass the file path in the next param
|
47
|
-
#
|
48
|
-
def create_page(user_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
|
49
|
-
if file_content_base64.nil? && !file_path.nil?
|
50
|
-
bts = File.open(file_path, 'rb') { |f| f.read }
|
51
|
-
file_content_base64 = Base64.encode64(bts)
|
52
|
-
end
|
53
|
-
# normally it returns 204 HTTP code on success
|
54
|
-
begin
|
55
|
-
MangoPay.request(:post, url(user_id, document_id) + '/pages', {'File' => file_content_base64}, {}, idempotency_key)
|
56
|
-
rescue ResponseError => ex
|
57
|
-
raise ex unless ex.code == '204'
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def url(user_id, document_id = nil)
|
62
|
-
if document_id
|
63
|
-
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents/#{CGI.escape(document_id.to_s)}"
|
64
|
-
else
|
65
|
-
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents"
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module MangoPay
|
4
|
+
|
5
|
+
# See http://docs.mangopay.com/api-references/kyc/documents/
|
6
|
+
class KycDocument < Resource
|
7
|
+
class << self
|
8
|
+
def create(user_id, params, idempotency_key = nil)
|
9
|
+
MangoPay.request(:post, url(user_id), params, {}, idempotency_key)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(user_id, document_id, params = {})
|
13
|
+
MangoPay.request(:put, url(user_id, document_id), params)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Fetches the KYC document belonging to the given +user_id+, with the given +document_id+.
|
17
|
+
def fetch(user_id, document_id)
|
18
|
+
url = (user_id) ? url(user_id, document_id) : "#{MangoPay.api_path}/KYC/documents/#{CGI.escape(document_id.to_s)}"
|
19
|
+
MangoPay.request(:get, url)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Fetches list of KYC documents:
|
23
|
+
# - for the particular user if +user_id+ is provided (not nil)
|
24
|
+
# - or for all users otherwise.
|
25
|
+
#
|
26
|
+
# Optional +filters+ is a hash accepting following keys:
|
27
|
+
# - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
|
28
|
+
# - filters such as +Type+ (e.g. 'IDENTITY_PROOF') and +Status+ (e.g. 'VALIDATED')
|
29
|
+
# - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
|
30
|
+
# - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
|
31
|
+
#
|
32
|
+
def fetch_all(user_id = nil, filters = {})
|
33
|
+
url = (user_id) ? url(user_id) : "#{MangoPay.api_path}/KYC/documents"
|
34
|
+
MangoPay.request(:get, url, {}, filters)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Adds the file page (attachment) to the given document.
|
38
|
+
#
|
39
|
+
# See http://docs.mangopay.com/api-references/kyc/pages/ :
|
40
|
+
# - Document have to be in 'CREATED' Status
|
41
|
+
# - You can create as many pages as needed
|
42
|
+
# - Change Status to 'VALIDATION_ASKED' to submit KYC documents
|
43
|
+
#
|
44
|
+
# The file_content_base64 param may be:
|
45
|
+
# - Base64 encoded file content
|
46
|
+
# - or nil: in this case pass the file path in the next param
|
47
|
+
#
|
48
|
+
def create_page(user_id, document_id, file_content_base64, file_path = nil, idempotency_key = nil)
|
49
|
+
if file_content_base64.nil? && !file_path.nil?
|
50
|
+
bts = File.open(file_path, 'rb') { |f| f.read }
|
51
|
+
file_content_base64 = Base64.encode64(bts)
|
52
|
+
end
|
53
|
+
# normally it returns 204 HTTP code on success
|
54
|
+
begin
|
55
|
+
MangoPay.request(:post, url(user_id, document_id) + '/pages', {'File' => file_content_base64}, {}, idempotency_key)
|
56
|
+
rescue ResponseError => ex
|
57
|
+
raise ex unless ex.code == '204'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def url(user_id, document_id = nil)
|
62
|
+
if document_id
|
63
|
+
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents/#{CGI.escape(document_id.to_s)}"
|
64
|
+
else
|
65
|
+
"#{MangoPay.api_path}/users/#{CGI.escape(user_id.to_s)}/KYC/documents"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/lib/mangopay/legal_user.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See http://docs.mangopay.com/api-references/users/legal-users/
|
4
|
-
# See also parent class MangoPay::User
|
5
|
-
class LegalUser < User
|
6
|
-
|
7
|
-
def self.url(id = nil)
|
8
|
-
if id
|
9
|
-
"#{MangoPay.api_path}/users/legal/#{CGI.escape(id.to_s)}"
|
10
|
-
else
|
11
|
-
"#{MangoPay.api_path}/users/legal"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See http://docs.mangopay.com/api-references/users/legal-users/
|
4
|
+
# See also parent class MangoPay::User
|
5
|
+
class LegalUser < User
|
6
|
+
|
7
|
+
def self.url(id = nil)
|
8
|
+
if id
|
9
|
+
"#{MangoPay.api_path}/users/legal/#{CGI.escape(id.to_s)}"
|
10
|
+
else
|
11
|
+
"#{MangoPay.api_path}/users/legal"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/mangopay/mandate.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
module MangoPay
|
2
|
-
|
3
|
-
# See https://docs.mangopay.com/api-references/mandates/
|
4
|
-
class Mandate < Resource
|
5
|
-
include HTTPCalls::Fetch
|
6
|
-
|
7
|
-
class << self
|
8
|
-
|
9
|
-
# +params+: hash; see https://docs.mangopay.com/api-references/mandates/
|
10
|
-
def create(params, idempotency_key = nil)
|
11
|
-
url = "#{MangoPay.api_path}/mandates/directdebit/web"
|
12
|
-
MangoPay.request(:post, url, params, {}, idempotency_key)
|
13
|
-
end
|
14
|
-
|
15
|
-
def cancel(id)
|
16
|
-
url = "#{MangoPay.api_path}/mandates/#{id}/cancel"
|
17
|
-
MangoPay.request(:put, url)
|
18
|
-
end
|
19
|
-
|
20
|
-
def fetch_for_user(user_id, filters = {})
|
21
|
-
url = "#{MangoPay.api_path}/users/#{user_id}/mandates"
|
22
|
-
MangoPay.request(:get, url, {}, filters)
|
23
|
-
end
|
24
|
-
|
25
|
-
def fetch_for_user_bank_account(user_id, bank_account_id, filters = {})
|
26
|
-
url = "#{MangoPay.api_path}/users/#{user_id}/bankaccounts/#{bank_account_id}/mandates"
|
27
|
-
MangoPay.request(:get, url, {}, filters)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module MangoPay
|
2
|
+
|
3
|
+
# See https://docs.mangopay.com/api-references/mandates/
|
4
|
+
class Mandate < Resource
|
5
|
+
include HTTPCalls::Fetch
|
6
|
+
|
7
|
+
class << self
|
8
|
+
|
9
|
+
# +params+: hash; see https://docs.mangopay.com/api-references/mandates/
|
10
|
+
def create(params, idempotency_key = nil)
|
11
|
+
url = "#{MangoPay.api_path}/mandates/directdebit/web"
|
12
|
+
MangoPay.request(:post, url, params, {}, idempotency_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
def cancel(id)
|
16
|
+
url = "#{MangoPay.api_path}/mandates/#{id}/cancel"
|
17
|
+
MangoPay.request(:put, url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def fetch_for_user(user_id, filters = {})
|
21
|
+
url = "#{MangoPay.api_path}/users/#{user_id}/mandates"
|
22
|
+
MangoPay.request(:get, url, {}, filters)
|
23
|
+
end
|
24
|
+
|
25
|
+
def fetch_for_user_bank_account(user_id, bank_account_id, filters = {})
|
26
|
+
url = "#{MangoPay.api_path}/users/#{user_id}/bankaccounts/#{bank_account_id}/mandates"
|
27
|
+
MangoPay.request(:get, url, {}, filters)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|