mangopay 3.2.0 → 3.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efb0b3e0cf693443b3c9e18d1553a029762cf2263d6ca10d72cd1e19a075de21
4
- data.tar.gz: f3a81ab3ed039247efec2bc76f48fe2c28dafb097d6211fbae1d6394b49f8a4d
3
+ metadata.gz: bdb36f26dc6032401dfe30606b77d8368da58389fdae346d1a787971d0963357
4
+ data.tar.gz: 4d6ad1805512bfd56f6289bb2e482653b1b3167006d7d99d95cf7bb030724eb0
5
5
  SHA512:
6
- metadata.gz: c3132d0152e7c24690c347d761d3d41dfe1e264ae9a7918590cf792223ee7ba071919ef7339a29bfe21fc33a63297c147c5c5cf9d5a84274119acc052de37ad0
7
- data.tar.gz: 1634c646e41c4948dae6abb69fa93319c28b1e7e1cd3ce4383aa966b2b058808fb94e5f4a8f1b448b746475e42c7a09aa4a5c1a4a84d0568bcccb77ed2f61d87
6
+ metadata.gz: 1344508c23d8b559c672ff2ff6e3e8739d53b7e9d6690f3a5cfdde733b0af8803e4a4adadeb3fe300e373ab0fc2d638707c4d68a48dfb355301db074cea1732e
7
+ data.tar.gz: 4dab1cab255b3eb58def8ac300c64551541f7ba3f96b3eda1e7bf690439e7ffe6f46167fd7ae80b715bcdc9d4f04bcb969c8c1a290c0f97ed66c3da8dd3cb8b9
@@ -0,0 +1,34 @@
1
+ name: mangopay2-net-ruby-cd
2
+
3
+ on:
4
+ push:
5
+ # Sequence of patterns matched against refs/tags
6
+ tags:
7
+ # It pushes any tags that contain a v. ex: v1.16.1
8
+ - '*'
9
+
10
+ jobs:
11
+ build:
12
+ name: Build + Publish
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby 2.6
21
+ uses: actions/setup-ruby@v1
22
+ with:
23
+ ruby-version: 2.6.x
24
+
25
+ - name: Publish to RubyGems
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: "${{secrets.GEM_HOST_API_KEY}}"
@@ -0,0 +1,34 @@
1
+ name: mangopay2-net-ruby-ci
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ # push on master branch
7
+ - master
8
+ # push on a feature branch
9
+ - feature/*
10
+ # push on a bugfix branch
11
+ - bugfix/*
12
+ pull_request:
13
+ branches: [ master ]
14
+
15
+ jobs:
16
+ build:
17
+ name: Build
18
+ runs-on: ubuntu-latest
19
+ permissions:
20
+ contents: read
21
+ packages: write
22
+
23
+ steps:
24
+ - uses: actions/checkout@v2
25
+ - name: Set up Ruby 2.6
26
+ uses: actions/setup-ruby@v1
27
+ with:
28
+ ruby-version: 2.6.x
29
+ - name: Install Rspec
30
+ run: |
31
+ gem install bundler
32
+ bundler install
33
+ - name: Test
34
+ run: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,80 @@
1
+ ## [3.6.0] - 2021.08.10
2
+ ## Added
3
+
4
+ - You can now update and view a Recurring PayIn Registration object. To know more about this feature, please consult the documentation [here](https://docs.mangopay.com/guide/recurring-payments-introduction).
5
+ - To improve recurring payments, we have added new parameters for CIT : DebitedFunds & Fees. To know more about this feature, please consult the documentation [here](https://docs.mangopay.com/endpoints/v2.01/payins#e1053_create-a-recurring-payin-cit)
6
+
7
+ ## [3.5.0] - 2021.06.10
8
+ ## Added
9
+
10
+ We have added a new feature **[recurring payments](https://docs.mangopay.com/guide/recurring-payments)** dedicated to clients needing to charge a card repeatedly, such as subscriptions or payments installments.
11
+
12
+ You can start testing in sandbox, to help you define your workflow. This release provides the first elements of the full feature.
13
+
14
+ - [Create a Recurring PayIn Registration object](https://docs.mangopay.com/endpoints/v2.01/payins#e1051_create-a-recurring-payin-registration), containing all the information to define the recurring payment
15
+ - [Initiate your recurring payment flow](https://docs.mangopay.com/endpoints/v2.01/payins#e1053_create-a-recurring-payin-cit) with an authenticated transaction (CIT) using the Card Recurring PayIn endpoint
16
+ - [Continue your recurring payment flow](https://docs.mangopay.com/endpoints/v2.01/payins#e1054_create-a-recurring-payin-mit) with an non-authenticated transaction (MIT) using the Card Recurring PayIn endpoint
17
+
18
+ This feature is not yet available in production and you need to contact the Support team to request access.
19
+
20
+ ## Accepted PRs
21
+
22
+ - Add support for refund creation
23
+ - Allow to fetch UBO Declaration without User ID
24
+
25
+
26
+
27
+ ## [3.4.0] - 2021.05.27
28
+ ## Added
29
+
30
+ ### Instant payment
31
+
32
+ Mangopay introduces the instant payment mode. It allows payouts (transfer from wallet to user bank account) to be processed within 25 seconds, rather than the 48 hours for a standard payout.
33
+
34
+ You can now use this new type of payout with the Ruby SDK.
35
+
36
+ Example :
37
+
38
+ ```ruby
39
+ bankwire = MangoPay::PayOut::BankWire.get_bankwire(payout['Id'])
40
+ # where payout['Id'] is the id of an existing payout
41
+ ```
42
+
43
+ Please note that this feature must be authorized and activated by MANGOPAY. More information [here](https://docs.mangopay.com/guide/instant-payment-payout).
44
+
45
+ ### Accepted PRs
46
+
47
+ - Add support to create refunds for PayIn, Transfer and PayOut transactions.
48
+ - ResponseError object improvement
49
+
50
+ ## [3.3.0]
51
+ ## Fixed
52
+
53
+ ### IBAN for testing purposes
54
+
55
+ ⚠️ **IBAN provided for testing purpose should never be used outside of a testing environement!**
56
+
57
+ More information about how to test payments, click [here](https://docs.mangopay.com/guide/testing-payments).
58
+
59
+ ### Others
60
+
61
+ - Adding missing json require in log requests filter spec. Thank you @Vin0uz
62
+ - Extend fetch_wallet and create_payout API. Thank you @peterb
63
+
64
+ ## Added
65
+
66
+ Some of you use a lot the [PreAuthorization](https://docs.mangopay.com/endpoints/v2.01/preauthorizations#e183_the-preauthorization-object) feature of our API. To make your life easier, we have added three new events :
67
+
68
+ - PREAUTHORIZATION_CREATED
69
+ - PREAUTHORIZATION_SUCCEEDED
70
+ - PREAUTHORIZATION_FAILED
71
+
72
+ The goal is to help you monitor a PreAuthorization with a [webhook](https://docs.mangopay.com/endpoints/v2.01/hooks#e246_the-hook-object).
73
+
74
+ *Example: If a PreAuthorization is desynchronized, when the status is updated, you will be able to know it.*
75
+
76
+
77
+
1
78
  ## [3.2.0]
2
79
  ## Added
3
80
 
@@ -33,7 +110,7 @@ The parameter `Applied3DSVersion` shows you the version of the 3DS protocol used
33
110
 
34
111
  ## [3.1.0]
35
112
  - 3DS2 integration with Shipping and Billing objects, including FirstName and LastName fields
36
- The objects Billing and Shipping may be included on all calls to the following endpoints:
113
+ The objects Billing and Shipping may be included on all calls to the following endpoints:
37
114
  - /preauthorizations/card/direct
38
115
  - /payins/card/direct
39
116
  - /payins/card/web
@@ -54,7 +131,7 @@ The objects Billing and Shipping may be included on all calls to the following e
54
131
  ## [3.0.35] - 2020-08-24
55
132
  - Improvement to Net::ReadTimeout handling
56
133
  - "User-agent" format in the headers changed, aligned to other assets 👤
57
-
134
+
58
135
  ## [3.0.34] - 2020-06-25
59
136
  ### Added
60
137
  - This SDK is now GooglePay-ready ! Feel free to ask our lovely support for more infos about its activation.
@@ -72,7 +149,7 @@ The objects Billing and Shipping may be included on all calls to the following e
72
149
 
73
150
  ## [3.0.33] - 2019-09-23
74
151
  ### Added
75
- - ApplePay `Payin` functions are now available. More info about activation to come in the following weeks...
152
+ - ApplePay `Payin` functions are now available. More info about activation to come in the following weeks...
76
153
  ### Changed
77
154
  - GET EMoney method now supports year and month parameters. More info on our [docs](https://docs.mangopay.com/endpoints/v2.01/user-emoney#e895_view-a-users-emoney)
78
155
 
@@ -86,4 +163,4 @@ The objects Billing and Shipping may be included on all calls to the following e
86
163
  - `APIKey` is now replacing `passphrase` property for credentials. You must update it by updating to 3.0.32 SDK version and upper ones.
87
164
 
88
165
 
89
-
166
+
@@ -3,9 +3,9 @@ module MangoPay
3
3
  # See parent class MangoPay::BankingAliases
4
4
  class BankingAliasesIBAN < BankingAliases
5
5
 
6
- def self.create(params, wallet_id)
6
+ def self.create(params, wallet_id, headers_or_idempotency_key = nil)
7
7
  url = "#{MangoPay.api_path}/wallets/#{wallet_id}/bankingaliases/iban"
8
- MangoPay.request(:post, url, params, {})
8
+ MangoPay.request(:post, url, params, {}, headers_or_idempotency_key)
9
9
  end
10
10
 
11
11
  def self.url(id = nil)
@@ -47,7 +47,10 @@ module MangoPay
47
47
  # +currency_iso_code+ is currncy ISO code
48
48
  # see https://docs.mangopay.com/api-references/client-wallets/
49
49
  def fetch_wallet(funds_type, currency_iso_code)
50
- MangoPay.request(:get, url() + "/wallets/#{funds_type}/#{currency_iso_code}")
50
+ method = :get
51
+ path = url() + "/wallets/#{funds_type}/#{currency_iso_code}"
52
+ yield method, path if block_given?
53
+ MangoPay.request(method, path)
51
54
  end
52
55
 
53
56
  # Fetch transactions for all your client wallets.
@@ -79,7 +82,10 @@ module MangoPay
79
82
  end
80
83
 
81
84
  def create_payout(params)
82
- MangoPay.request(:post, url() + "/payouts", params)
85
+ method = :post
86
+ path = url() + "/payouts"
87
+ yield method, path, params if block_given?
88
+ MangoPay.request(method, path, params)
83
89
  end
84
90
 
85
91
  end
@@ -8,9 +8,9 @@ module MangoPay
8
8
  include HTTPCalls::Update
9
9
  class << self
10
10
 
11
- def close(dispute_id)
11
+ def close(dispute_id, idempotency_key = nil)
12
12
  url = url(dispute_id) + "/close/"
13
- MangoPay.request(:put, url)
13
+ MangoPay.request(:put, url, {}, {}, idempotency_key)
14
14
  end
15
15
 
16
16
  # +contested_funds+: Money hash
@@ -44,15 +44,15 @@ module MangoPay
44
44
  url = "#{MangoPay.api_path}/disputes/pendingsettlement"
45
45
  MangoPay.request(:get, url, {}, filters)
46
46
  end
47
-
47
+
48
48
  #####################################################
49
49
  # repudiations / settlement transfers
50
50
  #####################################################
51
51
 
52
52
  # see https://docs.mangopay.com/api-references/disputes/repudiations/
53
- def fetch_repudiation(repudiation_id)
53
+ def fetch_repudiation(repudiation_id, idempotency_key = nil)
54
54
  url = "#{MangoPay.api_path}/repudiations/#{repudiation_id}"
55
- MangoPay.request(:get, url)
55
+ MangoPay.request(:get, url, {}, {}, idempotency_key)
56
56
  end
57
57
 
58
58
  # +params+: hash; see https://docs.mangopay.com/api-references/disputes/settlement-transfers/
@@ -66,7 +66,7 @@ module MangoPay
66
66
  url = "#{MangoPay.api_path}/settlements/#{transfer_id}"
67
67
  MangoPay.request(:get, url)
68
68
  end
69
-
69
+
70
70
  #####################################################
71
71
  # documents
72
72
  #####################################################
@@ -91,13 +91,13 @@ module MangoPay
91
91
  # Fetches list of dispute documents:
92
92
  # - for the particular dispute if +dispute_id+ is provided (not nil)
93
93
  # - or for all disputes otherwise.
94
- #
94
+ #
95
95
  # Optional +filters+ is a hash accepting following keys:
96
96
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
97
97
  # - filters such as +Type+ (e.g. 'REFUND_PROOF') and +Status+ (e.g. 'VALIDATED')
98
98
  # - +BeforeDate+ (timestamp): filters documents with CreationDate _before_ this date
99
99
  # - +AfterDate+ (timestamp): filters documents with CreationDate _after_ this date
100
- #
100
+ #
101
101
  # See https://docs.mangopay.com/api-references/disputes/dispute-documents/
102
102
  #
103
103
  def fetch_documents(dispute_id = nil, filters = {})
@@ -106,12 +106,12 @@ module MangoPay
106
106
  end
107
107
 
108
108
  # Adds the file page (attachment) to the given document.
109
- #
109
+ #
110
110
  # See https://docs.mangopay.com/api-references/disputes/dispute-document-pages/ :
111
111
  # - Document have to be in 'CREATED' Status
112
112
  # - You can create as many pages as needed
113
113
  # - Change Status to 'VALIDATION_ASKED' to submit dispute documents
114
- #
114
+ #
115
115
  # The file_content_base64 param may be:
116
116
  # - Base64 encoded file content
117
117
  # - or nil: in this case pass the file path in the next param
@@ -49,12 +49,17 @@ module MangoPay
49
49
  end
50
50
 
51
51
  def type; @details['Type']; end
52
- def errors; @details['errors']; end
52
+ def error; @details['error']; end
53
+ def errors; @details['errors'] || error; end
53
54
 
54
55
  def message;
55
- msg = @details['Message']
56
- msg += errors.sort.map {|k,v| " #{k}: #{v}"}.join if (errors && errors.is_a?(Hash))
57
- msg
56
+ if error
57
+ msg = error
58
+ else
59
+ msg = @details['Message']
60
+ msg += errors.sort.map {|k,v| " #{k}: #{v}"}.join if (errors && errors.is_a?(Hash))
61
+ msg
62
+ end
58
63
  end
59
64
 
60
65
  end
@@ -39,12 +39,17 @@ module MangoPay
39
39
  @@res_confidential_params ||= [
40
40
  'access_token', 'AccessKey', 'IBAN', 'CardRegistrationURL',
41
41
  'PreregistrationData', 'RedirectURL', 'RegistrationData',
42
- 'SecureModeRedirectUrl', 'OwnerName', 'OwnerAddress', 'BIC'
42
+ 'SecureModeRedirectUrl', 'OwnerName', 'OwnerAddress', 'BIC',
43
+ 'FirstName', 'LastName', 'Email', 'AddressLine1',
44
+ 'AddressLine2',
43
45
  ].freeze
44
46
  end
45
47
 
46
48
  def self.req_confidential_params
47
- @@req_confidential_params ||= ['File', 'IBAN', 'OwnerName', 'OwnerAddress', 'BIC'].freeze
49
+ @@req_confidential_params ||= [
50
+ 'File', 'IBAN', 'OwnerName', 'OwnerAddress', 'BIC', 'FirstName',
51
+ 'LastName', 'Email', 'AddressLine1', 'AddressLine2',
52
+ ].freeze
48
53
  end
49
54
 
50
55
  end
@@ -52,9 +52,9 @@ module MangoPay
52
52
  # MangoPay::User.fetch(filter = {'page' => 2, 'per_page' => 3})
53
53
  # filter # => {"page"=>2, "per_page"=>3, "total_pages"=>1969, "total_items"=>5905}
54
54
  #
55
- def fetch(id_or_filters = nil)
55
+ def fetch(id_or_filters = nil, idempotency_key = nil)
56
56
  id, filters = HTTPCalls::Fetch.parse_id_or_filters(id_or_filters)
57
- response = MangoPay.request(:get, url(id), {}, filters)
57
+ response = MangoPay.request(:get, url(id), {}, filters, idempotency_key)
58
58
  end
59
59
  end
60
60
 
@@ -9,20 +9,20 @@ module MangoPay
9
9
  MangoPay.request(:post, url(user_id), params, {}, idempotency_key)
10
10
  end
11
11
 
12
- def update(user_id, document_id, params = {})
13
- MangoPay.request(:put, url(user_id, document_id), params)
12
+ def update(user_id, document_id, params = {}, idempotency_key = nil)
13
+ MangoPay.request(:put, url(user_id, document_id), params, {}, idempotency_key)
14
14
  end
15
15
 
16
16
  # Fetches the KYC document belonging to the given +user_id+, with the given +document_id+.
17
- def fetch(user_id, document_id)
17
+ def fetch(user_id, document_id, idempotency_key = nil)
18
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)
19
+ MangoPay.request(:get, url, {}, {}, idempotency_key)
20
20
  end
21
21
 
22
22
  # Fetches list of KYC documents:
23
23
  # - for the particular user if +user_id+ is provided (not nil)
24
24
  # - or for all users otherwise.
25
- #
25
+ #
26
26
  # Optional +filters+ is a hash accepting following keys:
27
27
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
28
28
  # - filters such as +Type+ (e.g. 'IDENTITY_PROOF') and +Status+ (e.g. 'VALIDATED')
@@ -35,12 +35,12 @@ module MangoPay
35
35
  end
36
36
 
37
37
  # Adds the file page (attachment) to the given document.
38
- #
38
+ #
39
39
  # See http://docs.mangopay.com/api-references/kyc/pages/ :
40
40
  # - Document have to be in 'CREATED' Status
41
41
  # - You can create as many pages as needed
42
42
  # - Change Status to 'VALIDATION_ASKED' to submit KYC documents
43
- #
43
+ #
44
44
  # The file_content_base64 param may be:
45
45
  # - Base64 encoded file content
46
46
  # - or nil: in this case pass the file path in the next param
@@ -126,5 +126,35 @@ module MangoPay
126
126
  end
127
127
  end
128
128
 
129
+ module RecurringPayments
130
+ class Recurring < Resource
131
+ include HTTPCalls::Create
132
+
133
+ def self.url(*args)
134
+ if args.any?
135
+ "#{MangoPay.api_path}/recurringpayinregistrations/#{args.first}"
136
+ else
137
+ "#{MangoPay.api_path}/recurringpayinregistrations"
138
+ end
139
+ end
140
+ end
141
+
142
+ class CIT < Resource
143
+ include HTTPCalls::Create
144
+
145
+ def self.url(*)
146
+ "#{MangoPay.api_path}/payins/recurring/card/direct"
147
+ end
148
+ end
149
+
150
+ class MIT < Resource
151
+ include HTTPCalls::Create
152
+
153
+ def self.url(*)
154
+ "#{MangoPay.api_path}/payins/recurring/card/direct"
155
+ end
156
+ end
157
+ end
158
+
129
159
  end
130
160
  end
@@ -8,9 +8,9 @@ module MangoPay
8
8
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
9
  # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
10
10
  # - +ResultCode+: string representing the transaction result
11
- def self.refunds(pay_out_id, filters = {})
11
+ def self.refunds(pay_out_id, filters = {}, idempotency_key = nil)
12
12
  url = url(pay_out_id) + '/refunds'
13
- MangoPay.request(:get, url, {}, filters)
13
+ MangoPay.request(:get, url, {}, filters, idempotency_key)
14
14
  end
15
15
 
16
16
  # See http://docs.mangopay.com/api-references/pay-out-bank-wire/
@@ -20,6 +20,11 @@ module MangoPay
20
20
  def self.url(*)
21
21
  "#{MangoPay.api_path}/payouts/bankwire"
22
22
  end
23
+
24
+ def self.get_bankwire(pay_out_id)
25
+ url = self.url() + "/" + pay_out_id
26
+ MangoPay.request(:get, url);
27
+ end
23
28
  end
24
29
  end
25
30
  end
@@ -2,6 +2,7 @@ module MangoPay
2
2
 
3
3
  # See http://docs.mangopay.com/api-references/refund/
4
4
  class Refund < Resource
5
+ include HTTPCalls::Create
5
6
  include HTTPCalls::Fetch
6
7
 
7
8
  # Fetches list of refunds belonging to given +repudiation_id+
@@ -3,7 +3,7 @@ module MangoPay
3
3
  class << self
4
4
  # Fetches list of transactions belonging to the given +wallet_id+.
5
5
  # See also transactions for user: MangoPay::User#transactions
6
- #
6
+ #
7
7
  # Optional +filters+ is a hash accepting following keys:
8
8
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
9
9
  # - +Status+: TransactionStatus {CREATED, SUCCEEDED, FAILED}
@@ -12,8 +12,8 @@ module MangoPay
12
12
  # - +BeforeDate+ (timestamp): filters transactions with CreationDate _before_ this date
13
13
  # - +AfterDate+ (timestamp): filters transactions with CreationDate _after_ this date
14
14
  # See https://docs.mangopay.com/api-references/sort-lists/
15
- def fetch(wallet_id, filters={})
16
- MangoPay.request(:get, url(wallet_id), {}, filters)
15
+ def fetch(wallet_id, filters={}, headers = nil)
16
+ MangoPay.request(:get, url(wallet_id), {}, filters, headers)
17
17
  end
18
18
 
19
19
  def url(wallet_id)
data/lib/mangopay/ubo.rb CHANGED
@@ -10,16 +10,16 @@ module MangoPay
10
10
  end
11
11
  end
12
12
 
13
- def create(user_id, ubo_declaration_id, params)
14
- MangoPay.request(:post, url(user_id, ubo_declaration_id), params)
13
+ def create(user_id, ubo_declaration_id, params, idempotency_key = nil)
14
+ MangoPay.request(:post, url(user_id, ubo_declaration_id), params, {}, idempotency_key)
15
15
  end
16
16
 
17
17
  def fetch(user_id, ubo_declaration_id, ubo_id)
18
18
  MangoPay.request(:get, url(user_id, ubo_declaration_id, ubo_id))
19
19
  end
20
20
 
21
- def update(user_id, ubo_declaration_id, ubo_id, params)
22
- MangoPay.request(:put, url(user_id, ubo_declaration_id, ubo_id), params)
21
+ def update(user_id, ubo_declaration_id, ubo_id, params, idempotency_key = nil)
22
+ MangoPay.request(:put, url(user_id, ubo_declaration_id, ubo_id), params, {}, idempotency_key)
23
23
  end
24
24
  end
25
25
  end
@@ -10,20 +10,22 @@ module MangoPay
10
10
  end
11
11
  end
12
12
 
13
- def create(user_id)
14
- MangoPay.request(:post, url(user_id))
13
+ def create(user_id, idempotency_key)
14
+ MangoPay.request(:post, url(user_id), {}, {}, idempotency_key)
15
15
  end
16
16
 
17
- def fetch(user_id, id)
18
- MangoPay.request(:get, url(user_id, id))
17
+ # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +id+.
18
+ def fetch(user_id, id, idempotency_key)
19
+ url = (user_id) ? url(user_id, id) : "#{MangoPay.api_path}/kyc/ubodeclarations/#{CGI.escape(id.to_s)}"
20
+ MangoPay.request(:get, url, {}, {}, idempotency_key)
19
21
  end
20
22
 
21
- def update(user_id, id, params = {})
23
+ def update(user_id, id, params = {}, idempotency_key)
22
24
  request_params = {
23
25
  Status: params['Status'],
24
26
  Ubos: params['Ubos']
25
27
  }
26
- MangoPay.request(:put, url(user_id, id), request_params)
28
+ MangoPay.request(:put, url(user_id, id), request_params, {}, idempotency_key)
27
29
  end
28
30
  end
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.2.0'
2
+ VERSION = '3.6.0'
3
3
  end
@@ -10,8 +10,8 @@ module MangoPay
10
10
  # Optional +filters+ is a hash accepting following keys:
11
11
  # - +page+, +per_page+, +sort+: pagination and sorting params (see MangoPay::HTTPCalls::Fetch::ClassMethods#fetch)
12
12
  # - other keys specific for transactions filtering (see MangoPay::Transaction.fetch)
13
- def self.transactions(wallet_id, filters = {})
14
- Transaction.fetch(wallet_id, filters)
13
+ def self.transactions(wallet_id, filters = {}, headers = nil)
14
+ Transaction.fetch(wallet_id, filters, headers)
15
15
  end
16
16
  end
17
17
  end
Binary file
@@ -151,8 +151,8 @@ describe MangoPay::Client do
151
151
  PostalCode: '75001',
152
152
  Country: 'FR'
153
153
  },
154
- IBAN: 'FR7618829754160173622224154',
155
- BIC: 'CMBRFR2BCME',
154
+ IBAN: 'FR7630004000031234567890143',
155
+ BIC: 'BNPAFRPP',
156
156
  Tag: 'Test bank account')
157
157
  expect(bank_account).not_to be_nil
158
158
  expect(bank_account['Id']).not_to be_nil
@@ -172,8 +172,8 @@ describe MangoPay::Client do
172
172
  PostalCode: '75001',
173
173
  Country: 'FR'
174
174
  },
175
- IBAN: 'FR7618829754160173622224154',
176
- BIC: 'CMBRFR2BCME',
175
+ IBAN: 'FR7630004000031234567890143',
176
+ BIC: 'BNPAFRPP',
177
177
  Tag: 'Test bank account')
178
178
  pay_out = MangoPay::Client.create_payout(BankAccountId: bank_account['Id'],
179
179
 
@@ -6,7 +6,11 @@ describe MangoPay::Configuration do
6
6
  c.client_id = 'test_asd'
7
7
  c.client_apiKey = '00000'
8
8
  MangoPay::User.fetch()
9
- }.to raise_error(MangoPay::ResponseError)
9
+ }.to raise_error { |err|
10
+ expect(err).to be_a MangoPay::ResponseError
11
+ expect(err.code).to eq '401'
12
+ expect(err.message).to eq 'invalid_client'
13
+ }
10
14
  end
11
15
 
12
16
  it 'goes ok when calling with correct client credentials' do
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  describe MangoPay do
2
2
  include_context 'users'
3
3
  include_context 'payins'
4
+ require 'json'
4
5
 
5
6
  describe 'requests log file' do
6
7
 
@@ -40,6 +40,15 @@ describe MangoPay::PayOut::BankWire, type: :feature do
40
40
  end
41
41
  end
42
42
 
43
+ describe 'Get Bankwire' do
44
+ it 'gets a bankwire' do
45
+ created = new_payout_bankwire
46
+ fetched = MangoPay::PayOut::BankWire.get_bankwire(created['Id'])
47
+ expect(fetched['Id']).to eq(created['Id'])
48
+ expect(fetched['CreationDate']).to eq(created['CreationDate'])
49
+ end
50
+ end
51
+
43
52
  describe 'FETCH' do
44
53
  it 'fetches a payout' do
45
54
  created = new_payout_bankwire
@@ -0,0 +1,66 @@
1
+ describe MangoPay::PayIn::RecurringPayments, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'users'
4
+ include_context 'payins'
5
+
6
+ describe 'CREATE' do
7
+ it 'creates a recurring payment' do
8
+ cardreg = new_card_registration_3dsecure_completed
9
+ wallet = new_wallet
10
+ recurring = MangoPay::PayIn::RecurringPayments::Recurring.create(
11
+ AuthorId: new_natural_user['Id'],
12
+ CardId: cardreg['CardId'],
13
+ CreditedUserId: wallet['Owners'][0],
14
+ CreditedWalletId: wallet['Id'],
15
+ FirstTransactionDebitedFunds: {Currency: 'EUR', Amount: 10},
16
+ FirstTransactionFees: {Currency: 'EUR', Amount: 1},
17
+ Billing: {
18
+ Address: {
19
+ AddressLine1: 'AddressLine1',
20
+ AddressLine2: 'AddressLine2',
21
+ City: 'City',
22
+ Region: 'Region',
23
+ PostalCode: 'PostalCode',
24
+ Country: 'FR'
25
+ },
26
+ FirstName: 'Joe',
27
+ LastName: 'Blogs'
28
+ },
29
+ Shipping: {
30
+ Address: {
31
+ AddressLine1: 'AddressLine1',
32
+ AddressLine2: 'AddressLine2',
33
+ City: 'City',
34
+ Region: 'Region',
35
+ PostalCode: 'PostalCode',
36
+ Country: 'FR'
37
+ },
38
+ FirstName: 'Joe',
39
+ LastName: 'Blogs'
40
+ }
41
+ )
42
+ expect(recurring).not_to be_nil
43
+
44
+ cit = MangoPay::PayIn::RecurringPayments::CIT.create(
45
+ RecurringPayinRegistrationId: recurring['Id'],
46
+ IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C",
47
+ SecureModeReturnURL: "http://www.my-site.com/returnurl",
48
+ StatementDescriptor: "lorem",
49
+ Tag: "custom meta",
50
+ BrowserInfo: {
51
+ AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8",
52
+ JavaEnabled: true,
53
+ Language: "FR-FR",
54
+ ColorDepth: 4,
55
+ ScreenHeight: 1800,
56
+ ScreenWidth: 400,
57
+ JavascriptEnabled: true,
58
+ TimeZoneOffset: "+60",
59
+ UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
60
+ }
61
+ )
62
+
63
+ expect(cit).not_to be_nil
64
+ end
65
+ end
66
+ end
@@ -136,8 +136,8 @@ shared_context 'bank_accounts' do
136
136
  PostalCode: '75001',
137
137
  Country: 'FR'
138
138
  },
139
- IBAN: 'FR7618829754160173622224154',
140
- BIC: 'CMBRFR2BCME',
139
+ IBAN: 'FR7630004000031234567890143',
140
+ BIC: 'BNPAFRPP',
141
141
  Tag: 'Test bank account')
142
142
  end
143
143
  end
@@ -355,6 +355,28 @@ shared_context 'payins' do
355
355
  RegistrationData: cardreg['RegistrationData'])
356
356
  end
357
357
 
358
+ let(:new_card_registration_3dsecure_completed) do
359
+ # 1st step: create
360
+ cardreg = new_card_registration
361
+
362
+ # 2nd step: tokenize by payline (fills-in RegistrationData)
363
+ data = {
364
+ data: cardreg['PreregistrationData'],
365
+ accessKeyRef: cardreg['AccessKey'],
366
+ cardNumber: 4970105191923460,
367
+ cardExpirationDate: 1224,
368
+ cardCvx: 123}
369
+
370
+ res = Net::HTTP.post_form(URI(cardreg['CardRegistrationURL']), data)
371
+ raise Exception, [res, res.body] unless res.is_a?(Net::HTTPOK) && res.body.start_with?('data=')
372
+
373
+ cardreg['RegistrationData'] = res.body
374
+
375
+ # 3rd step: update (fills-in CardId) and return it
376
+ MangoPay::CardRegistration.update(cardreg['Id'],
377
+ RegistrationData: cardreg['RegistrationData'])
378
+ end
379
+
358
380
  let(:new_payin_card_direct) { create_new_payin_card_direct(new_wallet) }
359
381
 
360
382
  def create_new_payin_card_direct(to_wallet, amnt = 1000)
@@ -439,7 +461,8 @@ shared_context 'payouts' do
439
461
  Fees: {Currency: 'EUR', Amount: 0},
440
462
  BankAccountId: new_bank_account['Id'],
441
463
  Communication: 'This is a test',
442
- Tag: 'Test PayOut/Bank/Wire'
464
+ Tag: 'Test PayOut/Bank/Wire',
465
+ PayoutModeRequested: 'Standard'
443
466
  )
444
467
  end
445
468
  end
@@ -6,9 +6,20 @@ describe MangoPay::UboDeclaration do
6
6
  it 'can fetch a UBO declaration' do
7
7
  legal_user = new_legal_user
8
8
 
9
- ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
9
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
10
10
 
11
- ubo_declaration_byId = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'])
11
+ ubo_declaration_byId = MangoPay::UboDeclaration.fetch(legal_user['Id'], ubo_declaration['Id'], nil)
12
+
13
+ expect(ubo_declaration).not_to be_nil
14
+ expect(ubo_declaration_byId).not_to be_nil
15
+ end
16
+
17
+ it 'fetches ubo declaration just by id' do
18
+ legal_user = new_legal_user
19
+
20
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
21
+
22
+ ubo_declaration_byId = MangoPay::UboDeclaration.fetch(nil, ubo_declaration['Id'], nil)
12
23
 
13
24
  expect(ubo_declaration).not_to be_nil
14
25
  expect(ubo_declaration_byId).not_to be_nil
@@ -17,13 +28,13 @@ describe MangoPay::UboDeclaration do
17
28
  describe 'UPDATE' do
18
29
  it 'can update a UBO declaration' do
19
30
  legal_user = new_legal_user
20
- ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
31
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
21
32
  ubo_declaration['Status'] = 'VALIDATION_ASKED'
22
33
 
23
34
  ubo = new_ubo(legal_user, ubo_declaration)
24
35
 
25
36
  ubo_declaration['Ubos'] = [ubo]
26
- ubo_declaration = MangoPay::UboDeclaration.update(legal_user['Id'], ubo_declaration['Id'], ubo_declaration)
37
+ ubo_declaration = MangoPay::UboDeclaration.update(legal_user['Id'], ubo_declaration['Id'], ubo_declaration, nil)
27
38
 
28
39
  expect(ubo_declaration).not_to be_nil
29
40
  expect(ubo_declaration['Status']).to eq 'VALIDATION_ASKED'
@@ -5,7 +5,7 @@ describe MangoPay::Ubo do
5
5
  describe 'FETCH' do
6
6
  it 'can fetch a Ubo' do
7
7
  legal_user = new_legal_user
8
- ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
8
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
9
9
  ubo = new_ubo(legal_user, ubo_declaration)
10
10
  result = MangoPay::Ubo.fetch(legal_user['Id'], ubo_declaration['Id'], ubo['Id'])
11
11
  expect(result).not_to be_nil
@@ -16,7 +16,7 @@ describe MangoPay::Ubo do
16
16
  describe 'CREATE' do
17
17
  it 'can create a new Ubo' do
18
18
  legal_user = new_legal_user
19
- ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
19
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
20
20
  result = new_ubo(legal_user, ubo_declaration)
21
21
  expect(result).not_to be_nil
22
22
  end
@@ -25,7 +25,7 @@ describe MangoPay::Ubo do
25
25
  describe 'UPDATE' do
26
26
  it 'can update a Ubo' do
27
27
  legal_user = new_legal_user
28
- ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'])
28
+ ubo_declaration = MangoPay::UboDeclaration.create(legal_user['Id'], nil)
29
29
  ubo = new_ubo(legal_user, ubo_declaration)
30
30
  ubo['FirstName'] = 'Santa'
31
31
  ubo['LastName'] = 'Clause'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mangopay
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geoffroy Lorieux
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-25 00:00:00.000000000 Z
12
+ date: 2021-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -63,9 +63,10 @@ executables:
63
63
  extensions: []
64
64
  extra_rdoc_files: []
65
65
  files:
66
+ - ".github/workflows/ruby_cd.yml"
67
+ - ".github/workflows/ruby_ci.yml"
66
68
  - ".gitignore"
67
69
  - ".rspec"
68
- - ".travis.yml"
69
70
  - CHANGELOG.md
70
71
  - Gemfile
71
72
  - LICENSE
@@ -134,6 +135,7 @@ files:
134
135
  - spec/mangopay/payin_preauthorized_direct_spec.rb
135
136
  - spec/mangopay/payout_bankwire_spec.rb
136
137
  - spec/mangopay/preauthorization_spec.rb
138
+ - spec/mangopay/recurring_payin_spec.rb
137
139
  - spec/mangopay/refund_spec.rb
138
140
  - spec/mangopay/report_spec.rb
139
141
  - spec/mangopay/report_wallets_spec.rb
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
167
  - !ruby/object:Gem::Version
166
168
  version: '0'
167
169
  requirements: []
168
- rubygems_version: 3.0.8
170
+ rubygems_version: 3.0.3.1
169
171
  signing_key:
170
172
  specification_version: 4
171
173
  summary: Ruby bindings for the version 2 of the MANGOPAY API
@@ -198,6 +200,7 @@ test_files:
198
200
  - spec/mangopay/payin_preauthorized_direct_spec.rb
199
201
  - spec/mangopay/payout_bankwire_spec.rb
200
202
  - spec/mangopay/preauthorization_spec.rb
203
+ - spec/mangopay/recurring_payin_spec.rb
201
204
  - spec/mangopay/refund_spec.rb
202
205
  - spec/mangopay/report_spec.rb
203
206
  - spec/mangopay/report_wallets_spec.rb
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- rvm:
3
- # - 2.0.0
4
- # - 2.1
5
- # - 2.2
6
- # - 2.3
7
- # - 2.4
8
- - 2.5
9
- script:
10
- - if [ $TRAVIS_BRANCH != "release" ]; then bundle exec rspec; fi
11
- deploy:
12
- provider: rubygems
13
- api_key:
14
- secure: gvlnYEh9cyL+mYeudKzlD+2Po+LgIzCjHzggJH+WDcbtgxlGAFpxbVJOOm/KY8VKhMgIudNV7FJl4Gl4rrG8JjNxbb+qM57ypU3yyDcUesQ+uj0DnN+xszv7M+XtcRQMlhkStawoj/E0QMYBPkAAr1lBpPIFQdC17GDkdn5XvaQ=
15
- gem: mangopay
16
- on:
17
- tags: false
18
- repo: Mangopay/mangopay2-ruby-sdk
19
- branch: release