mangopay 3.4.0 → 3.5.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: f3be9c170462d86c30e551361cb135196086b166a5b4da755002635e6dffa367
4
- data.tar.gz: f6cba5c6f4a1f3eacaa4fed0ffb484dacbf71e3d8b8f6a8cc16deca7387188ec
3
+ metadata.gz: b84828fb11033157bfa54765cb99dc5e9ba1c0a00fe7b9351dd8bf4d747d29f2
4
+ data.tar.gz: 9f83683c46d13b2e6cf18532e4948ccd6daee09bdf4fdf590aee1d9da57e87f8
5
5
  SHA512:
6
- metadata.gz: 50f20f836d5eb42c7122b2e5865d20dc6a566ad1433915eef235d9cc0dfef4d4cde39f949c050de0bfafa9510c8aa263d6091ebf7df126e77a222160db8250b2
7
- data.tar.gz: 11a3cc3fb9ed24f8b791c331f2113bf35e388082f18f78063c3c2ded7c74d1d8cffe53016d0a4f4fc5ccb03f2a296b09fb73246801bf45b6a1011a065a78d2a0
6
+ metadata.gz: e593d8cbe199ef24f65ca3a4388015a5cfca4e8b71012fdc3960389ede99e6eef9ad7a424cd136162d581bdc81fb344becf1cced30a5300f09ad1d4aefc49830
7
+ data.tar.gz: 5d06c7d08de2d7fb8edb1d3ba28bd20643bc3f28c823e535af889b7b270316883134fe95af0fb573811173cbb311fde3ed716249f69269d7927d7350c19ff044
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [3.5.0] - 2021.06.10
2
+ ## Added
3
+
4
+ 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.
5
+
6
+ You can start testing in sandbox, to help you define your workflow. This release provides the first elements of the full feature.
7
+
8
+ - [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
9
+ - [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
10
+ - [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
11
+
12
+ This feature is not yet available in production and you need to contact the Support team to request access.
13
+
14
+ ## Accepted PRs
15
+
16
+ - Add support for refund creation
17
+ - Allow to fetch UBO Declaration without User ID
18
+
19
+
20
+
1
21
  ## [3.4.0] - 2021.05.27
2
22
  ## Added
3
23
 
@@ -126,5 +126,31 @@ 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(*)
134
+ "#{MangoPay.api_path}/recurringpayinregistrations"
135
+ end
136
+ end
137
+
138
+ class CIT < Resource
139
+ include HTTPCalls::Create
140
+
141
+ def self.url(*)
142
+ "#{MangoPay.api_path}/payins/recurring/card/direct"
143
+ end
144
+ end
145
+
146
+ class MIT < Resource
147
+ include HTTPCalls::Create
148
+
149
+ def self.url(*)
150
+ "#{MangoPay.api_path}/payins/recurring/card/direct"
151
+ end
152
+ end
153
+ end
154
+
129
155
  end
130
156
  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+
@@ -14,8 +14,10 @@ module MangoPay
14
14
  MangoPay.request(:post, url(user_id), {}, {}, idempotency_key)
15
15
  end
16
16
 
17
+ # Fetches the Ubo declaration belonging to the given +user_id+ if given, with the given +id+.
17
18
  def fetch(user_id, id, idempotency_key)
18
- MangoPay.request(:get, url(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
23
  def update(user_id, id, params = {}, idempotency_key)
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.4.0'
2
+ VERSION = '3.5.0'
3
3
  end
@@ -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
@@ -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)
@@ -14,6 +14,17 @@ describe MangoPay::UboDeclaration do
14
14
  expect(ubo_declaration_byId).not_to be_nil
15
15
  end
16
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)
23
+
24
+ expect(ubo_declaration).not_to be_nil
25
+ expect(ubo_declaration_byId).not_to be_nil
26
+ end
27
+
17
28
  describe 'UPDATE' do
18
29
  it 'can update a UBO declaration' do
19
30
  legal_user = new_legal_user
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.4.0
4
+ version: 3.5.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-05-27 00:00:00.000000000 Z
12
+ date: 2021-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -134,6 +134,7 @@ files:
134
134
  - spec/mangopay/payin_preauthorized_direct_spec.rb
135
135
  - spec/mangopay/payout_bankwire_spec.rb
136
136
  - spec/mangopay/preauthorization_spec.rb
137
+ - spec/mangopay/recurring_payin_spec.rb
137
138
  - spec/mangopay/refund_spec.rb
138
139
  - spec/mangopay/report_spec.rb
139
140
  - spec/mangopay/report_wallets_spec.rb
@@ -198,6 +199,7 @@ test_files:
198
199
  - spec/mangopay/payin_preauthorized_direct_spec.rb
199
200
  - spec/mangopay/payout_bankwire_spec.rb
200
201
  - spec/mangopay/preauthorization_spec.rb
202
+ - spec/mangopay/recurring_payin_spec.rb
201
203
  - spec/mangopay/refund_spec.rb
202
204
  - spec/mangopay/report_spec.rb
203
205
  - spec/mangopay/report_wallets_spec.rb