mangopay 3.16.0 → 3.17.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: ee564c11b6f6937ee8e1736000f571f999effa0e65946cbbdf73a7fd2671c4ef
4
- data.tar.gz: 004c55f7857d52c18dedff47a44777d1f311739f6e039cd8953fa2ac49340cbc
3
+ metadata.gz: afb1569667ffe29e931e6ffd8e29b965c6dd84e094741c8bfb307ff44f7e71d3
4
+ data.tar.gz: e77127572650d95af53a9564d9c7d845785d161c9043212e27baa4f36b171740
5
5
  SHA512:
6
- metadata.gz: d3bbdd4eb6cef6ca0093da5f10a84e9250272118725ffa9f99cc45959807ba38b441ec0799904d33787ef0a9769df9a08099a452748a4aba36e85dded23ab663
7
- data.tar.gz: 8bbb4cbca2206df01fc7a02687bbed28b531a1fa469e74b763318d36a95a40ebed000667bd7e1873626245c96483cffa4577be231e5275570b323828443d6998
6
+ metadata.gz: 7c78c113e106af277a4e0ec63bc1e8602fa2ff120bc2016041c018031275beb8b9c225d93f27f53566ba9560032aaed4936a6d0f087f5593665ba87ba11d8fe8
7
+ data.tar.gz: 841cab6e5d7d41a4db88075121f597737c10d2dd113556e812d887547b86c65d79af296b2ec29f455d4011e400e420840b4a2908dc446fa4d31511bcbb753196
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [3.17.0] - 2023-09-20
2
+ ### Added
3
+
4
+ - A new parameter for Paypal : ShippingPreference
5
+ - Klarna is now available as a payment method with Mangopay. This payment method is in private beta. Please contact support if you have any questions.
6
+ - #225 It's now possible to configure ssl_options. It's now possible to set to false in preproduction environment. Thanks to @mantaskujalis
7
+
1
8
  ## [3.16.0] - 2023-09-04
2
9
  ### Added
3
10
 
@@ -187,6 +187,16 @@ module MangoPay
187
187
  end
188
188
  end
189
189
 
190
+ module Klarna
191
+ class Web < Resource
192
+ include HTTPCalls::Create
193
+
194
+ def self.url(*)
195
+ "#{MangoPay.api_path}/payins/payment-methods/klarna"
196
+ end
197
+ end
198
+ end
199
+
190
200
  module RecurringPayments
191
201
  class Recurring < Resource
192
202
  include HTTPCalls::Create
@@ -1,3 +1,3 @@
1
1
  module MangoPay
2
- VERSION = '3.16.0'
2
+ VERSION = '3.17.0'
3
3
  end
data/lib/mangopay.rb CHANGED
@@ -53,7 +53,7 @@ module MangoPay
53
53
  :client_id, :client_apiKey,
54
54
  :temp_dir, :log_file, :http_timeout,
55
55
  :http_max_retries, :http_open_timeout,
56
- :logger
56
+ :logger, :use_ssl
57
57
 
58
58
  def preproduction
59
59
  @preproduction || false
@@ -74,6 +74,14 @@ module MangoPay
74
74
  def http_open_timeout
75
75
  @http_open_timeout || 30
76
76
  end
77
+
78
+ def use_ssl?
79
+ return true unless preproduction == true
80
+ return true unless defined?(@use_ssl)
81
+ return false if @use_ssl == false
82
+
83
+ true
84
+ end
77
85
  end
78
86
 
79
87
  class << self
@@ -150,7 +158,7 @@ module MangoPay
150
158
  headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
151
159
  end
152
160
 
153
- res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout,
161
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => configuration.use_ssl?, :read_timeout => configuration.http_timeout,
154
162
  :max_retries => configuration.http_max_retries,
155
163
  :open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
156
164
  req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
@@ -19,6 +19,36 @@ describe MangoPay::Configuration do
19
19
  expect(users).to be_kind_of(Array)
20
20
  end
21
21
 
22
+ describe '.use_ssl?' do
23
+ let(:configuration) { MangoPay::Configuration.new }
24
+
25
+ it 'defaults to true' do
26
+ expect(configuration.use_ssl?).to eq(true)
27
+ end
28
+
29
+ context 'when assigned to false in production' do
30
+ before do
31
+ configuration.use_ssl = false
32
+ configuration.preproduction = false
33
+ end
34
+
35
+ it 'uses true as value' do
36
+ expect(configuration.use_ssl?).to eq(true)
37
+ end
38
+ end
39
+
40
+ context 'when assigned to false in preproduction' do
41
+ before do
42
+ configuration.use_ssl = false
43
+ configuration.preproduction = true
44
+ end
45
+
46
+ it 'uses assigned as value' do
47
+ expect(configuration.use_ssl?).to eq(false)
48
+ end
49
+ end
50
+ end
51
+
22
52
  describe 'logger' do
23
53
  around(:each) do |example|
24
54
  c = MangoPay.configuration
@@ -0,0 +1,32 @@
1
+ describe MangoPay::PayIn::Klarna::Web, type: :feature do
2
+ include_context 'wallets'
3
+ include_context 'payins'
4
+
5
+ def check_type_and_status(payin)
6
+ expect(payin['Type']).to eq('PAYIN')
7
+ expect(payin['Nature']).to eq('REGULAR')
8
+ expect(payin['PaymentType']).to eq('KLARNA')
9
+ expect(payin['ExecutionType']).to eq('WEB')
10
+ expect(payin['Status']).to eq('CREATED')
11
+ end
12
+
13
+ describe 'CREATE' do
14
+ it 'creates a klarna web payin' do
15
+ created = new_payin_klarna_web
16
+ expect(created['Id']).not_to be_nil
17
+ expect(created['ReturnURL']).not_to be_nil
18
+ check_type_and_status(created)
19
+ end
20
+ end
21
+
22
+ describe 'FETCH' do
23
+ it 'fetches a payin' do
24
+ created = new_payin_klarna_web
25
+ fetched = MangoPay::PayIn.fetch(created['Id'])
26
+ expect(fetched['Id']).to eq(created['Id'])
27
+ check_type_and_status(created)
28
+ check_type_and_status(fetched)
29
+ end
30
+ end
31
+ end
32
+
@@ -28,5 +28,4 @@ describe MangoPay::PayIn::Multibanco::Web, type: :feature do
28
28
  check_type_and_status(fetched)
29
29
  end
30
30
  end
31
-
32
31
  end
@@ -509,7 +509,67 @@ shared_context 'payins' do
509
509
  end
510
510
 
511
511
  ###############################################
512
- # PAYPAL/direct
512
+ # KLARNA/web
513
+ ###############################################
514
+ let(:new_payin_klarna_web) do
515
+ MangoPay::PayIn::Klarna::Web.create(
516
+ AuthorId: new_natural_user['Id'],
517
+ CreditedWalletId: new_wallet['Id'],
518
+ DebitedFunds: {Currency: 'EUR', Amount: 400},
519
+ Fees: {Currency: 'EUR', Amount: 10},
520
+ ReturnURL: 'http://www.my-site.com/returnURL',
521
+ LineItems: [
522
+ {
523
+ Name: "running shoes",
524
+ Quantity: 1,
525
+ UnitAmount: 200,
526
+ TaxAmount: 0,
527
+ Description: "seller1 ID"
528
+ },
529
+ {
530
+ Name: "running shoes",
531
+ Quantity: 1,
532
+ UnitAmount: 200,
533
+ TaxAmount: 0,
534
+ Description: "seller2 ID"
535
+ }
536
+ ],
537
+ Country: 'FR',
538
+ Culture: 'FR',
539
+ Phone: '33#607080900',
540
+ Email: 'mango@mangopay.com',
541
+ AdditionalData: '{}',
542
+ Billing: {
543
+ Address: {
544
+ AddressLine1: 'AddressLine1',
545
+ AddressLine2: 'AddressLine2',
546
+ City: 'City',
547
+ Region: 'Region',
548
+ PostalCode: 'PostalCode',
549
+ Country: 'FR'
550
+ },
551
+ FirstName: 'Joe',
552
+ LastName: 'Blogs'
553
+ },
554
+ Shipping: {
555
+ Address: {
556
+ AddressLine1: 'AddressLine1',
557
+ AddressLine2: 'AddressLine2',
558
+ City: 'City',
559
+ Region: 'Region',
560
+ PostalCode: 'PostalCode',
561
+ Country: 'FR'
562
+ },
563
+ FirstName: 'Joe',
564
+ LastName: 'Blogs'
565
+ },
566
+ MerchantOrderId: 'afd48-879d-48fg',
567
+ Tag: 'Test PayIn/Klarna/Web'
568
+ )
569
+ end
570
+
571
+ ###############################################
572
+ # PAYPAL/web V2
513
573
  ###############################################
514
574
  let(:new_payin_paypal_web_v2) do
515
575
  MangoPay::PayIn::PayPal::Web.create_v2(
@@ -546,6 +606,7 @@ shared_context 'payins' do
546
606
  FirstName: 'Joe',
547
607
  LastName: 'Blogs'
548
608
  },
609
+ ShippingPreference: "GET_FROM_FILE",
549
610
  StatementDescriptor: "ruby",
550
611
  Tag: 'Test',
551
612
  # Culture: 'FR'
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.16.0
4
+ version: 3.17.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: 2023-09-04 00:00:00.000000000 Z
12
+ date: 2023-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -136,6 +136,7 @@ files:
136
136
  - spec/mangopay/payin_directdebit_direct_spec.rb
137
137
  - spec/mangopay/payin_directdebit_web_spec.rb
138
138
  - spec/mangopay/payin_googlepay_direct_spec.rb
139
+ - spec/mangopay/payin_klarna_web_spec.rb
139
140
  - spec/mangopay/payin_mbway_web_spec.rb
140
141
  - spec/mangopay/payin_multibanco_web_spec.rb
141
142
  - spec/mangopay/payin_payconiq_web_spec.rb
@@ -209,6 +210,7 @@ test_files:
209
210
  - spec/mangopay/payin_directdebit_direct_spec.rb
210
211
  - spec/mangopay/payin_directdebit_web_spec.rb
211
212
  - spec/mangopay/payin_googlepay_direct_spec.rb
213
+ - spec/mangopay/payin_klarna_web_spec.rb
212
214
  - spec/mangopay/payin_mbway_web_spec.rb
213
215
  - spec/mangopay/payin_multibanco_web_spec.rb
214
216
  - spec/mangopay/payin_payconiq_web_spec.rb