swiss-crm-activemerchant-v2 1.0.23 → 1.0.25

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: af3a2d531e5ddb1183fdad238a7087a6d77c68e0a3882ccf72c755143c29ca32
4
- data.tar.gz: d923b080a1268a0e8143bfb5e81b927e651fdfd2d131db3559348adba04b4ae0
3
+ metadata.gz: bd8c97a821e37c5f68735206a29b4f9633048aa884cad771c148236924215092
4
+ data.tar.gz: 8f2a182c09ef9168c09ba8e792338a1ccbee01fbabedd53ac9f0eaff41d6f806
5
5
  SHA512:
6
- metadata.gz: 3c2629ceac79372e2722b599a8ba02e3f0670d8eebd1c4405e703284d5db4d2cca654d78e89ea1c1b199366d6ddb5ea6cbd44792b83d66f0e6e51cad41bc4f1e
7
- data.tar.gz: 74311b6b4d445056f69e18e965bb6cdb337c63ff61c3230d36c45bc419b744646b4167947c326a1f648b85b9b7cfb4667b57bab84eb3cb0ca4f63444b90ecf7c
6
+ metadata.gz: 9cecc2fd882615b8797c67265d2ce9af85a7a9b7ddea35c16411cb53c68c3852eca2471fd44a4cfb92ba8419640be79f1dd71713eb30bdd858f806748c2bf8f6
7
+ data.tar.gz: dad2742d5a273f85b5e2d8c8313cd588b25567b86a7ed36cb52805ae064258759c49456890f4ea1ce1944fb671a91de9ef71f5d9eef44cffc558a3c354868b2f
@@ -16,7 +16,7 @@ module ActiveMerchant #:nodoc:
16
16
 
17
17
  self.test_url = 'https://api.mollie.com/v2'
18
18
  self.live_url = 'https://api.mollie.com/v2'
19
- self.supported_countries = %w[NL BE DE FR CH US GB]
19
+ self.supported_countries = %w[AT BE DE DK FI FR IE IT NL NO PT ES SE CH GB US LU]
20
20
  self.default_currency = 'EUR'
21
21
  self.supported_cardtypes = %i[visa master american_express]
22
22
  self.money_format = :cents
@@ -65,11 +65,11 @@ module ActiveMerchant #:nodoc:
65
65
  private
66
66
 
67
67
  def recurring_payment?(payment_method, options)
68
- options[:mollie_customer_id].present? && payment_method.mollie_mandate_id.present?
68
+ payment_method.mollie_customer_id.present? && payment_method.mollie_mandate_id.present?
69
69
  end
70
70
 
71
71
  def add_customer_to_payment(payment_method, options)
72
- return options[:mollie_customer_id] if existing_customer?(options)
72
+ return payment_method.mollie_customer_id if existing_customer?(payment_method)
73
73
 
74
74
  customer_response = create_customer(options)
75
75
  return customer_response unless customer_response.success?
@@ -77,8 +77,8 @@ module ActiveMerchant #:nodoc:
77
77
  customer_response.params['id']
78
78
  end
79
79
 
80
- def existing_customer?(options)
81
- options[:mollie_customer_id].present?
80
+ def existing_customer?(payment_method)
81
+ payment_method.mollie_customer_id.present?
82
82
  end
83
83
 
84
84
  def create_customer(options)
@@ -97,25 +97,58 @@ module ActiveMerchant #:nodoc:
97
97
  end
98
98
 
99
99
  def add_purchase_data(post, amount, payment_method, options)
100
- post[:amount] = format_amount(amount, options[:currency])
101
- post[:description] = "Order ##{options[:order_id]}"
102
- post[:method] = payment_method.mollie_payment_method
103
- post[:sequenceType] = 'first'
104
- post[:locale] = options[:locale]
100
+ post[:amount] = format_amount(amount, options[:currency])
101
+ post[:description] = "Order ##{options[:order_id]}"
102
+ post[:method] = payment_method.mollie_payment_method.to_s
103
+ post[:locale] = options[:locale]
104
+
105
+ unless %w[klarna paypal].include?(post[:method])
106
+ post[:sequenceType] = 'first'
107
+ end
105
108
 
106
109
  add_urls(post, options)
110
+ add_klarna_lines(post, options) if post[:method] == 'klarna'
107
111
  end
108
112
 
109
113
  def add_recurring_data(post, amount, payment_method, options)
110
114
  post[:amount] = format_amount(amount, options[:currency])
111
115
  post[:description] = "Order ##{options[:order_id]}"
112
116
  post[:sequenceType] = 'recurring'
113
- post[:customerId] = options[:mollie_customer_id]
117
+ post[:customerId] = payment_method.mollie_customer_id
114
118
  post[:mandateId] = payment_method.mollie_mandate_id
115
119
 
116
120
  add_urls(post, options)
117
121
  end
118
122
 
123
+ def add_klarna_lines(post, options)
124
+ currency = options[:currency]
125
+
126
+ post[:lines] = options[:order_line_items].map do |item|
127
+ price = item[:price].to_f
128
+ quantity = item[:quantity].to_i
129
+ total = item[:final_amount].to_f
130
+
131
+ {
132
+ description: item[:name],
133
+ quantity: quantity,
134
+ unitPrice: {
135
+ currency: currency,
136
+ value: sprintf('%.2f', price)
137
+ },
138
+ totalAmount: {
139
+ currency: currency,
140
+ value: sprintf('%.2f', total)
141
+ },
142
+ vatRate: item[:vat_rate] || '0.00',
143
+ vatAmount: {
144
+ currency: currency,
145
+ value: item[:vat_amount] || '0.00'
146
+ },
147
+ type: item[:type] || 'physical'
148
+ }
149
+ end
150
+ end
151
+
119
152
  def add_refund_data(post, amount, authorization, options)
120
153
  post[:amount] = format_amount(amount, options[:currency])
121
154
  post[:description] = "Order ##{options[:order_id]} Refund at #{Time.current.to_i}"
@@ -139,7 +172,7 @@ module ActiveMerchant #:nodoc:
139
172
  def add_payment_token(post, payment_method, options)
140
173
  method = post[:method].to_s.downcase
141
174
 
142
- return unless %w[creditcard applepay googlepay].include?(method)
175
+ return if %w[klarna paypal].include?(method)
143
176
 
144
177
  token = payment_method.mollie_payment_token
145
178
  return unless token
@@ -155,11 +188,14 @@ module ActiveMerchant #:nodoc:
155
188
  end
156
189
 
157
190
  def add_addresses(post, options)
158
- post[:billingAddress] = build_address(options[:billing_address])
159
- post[:shippingAddress] = build_address(options[:shipping_address])
191
+ billing_address = build_address(options[:billing_address], options[:email])
192
+ shipping_address = build_address(options[:shipping_address])
193
+
194
+ post[:billingAddress] = billing_address
195
+ post[:shippingAddress] = shipping_address
160
196
  end
161
197
 
162
- def build_address(data)
198
+ def build_address(data, email)
163
199
  return if data.blank?
164
200
 
165
201
  first_name, last_name = split_names(data[:name])
@@ -175,7 +211,8 @@ module ActiveMerchant #:nodoc:
175
211
  city: data[:city],
176
212
  region: data[:state],
177
213
  country: data[:country],
178
- phone: data[:phone]
214
+ phone: data[:phone],
215
+ email: email
179
216
  }.compact
180
217
  end
181
218
 
@@ -267,9 +304,9 @@ module ActiveMerchant #:nodoc:
267
304
  end
268
305
 
269
306
  def error_code_from(succeeded, response)
270
- return nil if succeeded
307
+ return nil if succeeded || response['status'] == 'open'
271
308
 
272
- response['status'] || response['type']
309
+ response['status']
273
310
  end
274
311
 
275
312
  def authorization_from(response)
@@ -282,6 +319,7 @@ module ActiveMerchant #:nodoc:
282
319
 
283
320
  def response_type_from(response)
284
321
  return 'success' if response['sequenceType'] == 'recurring' && response['status'] == 'paid'
322
+ return 'failed' if response['sequenceType'] == 'recurring' && %w[failed canceled expired declined].include?(response['status'])
285
323
 
286
324
  nil
287
325
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = '1.0.23'
2
+ VERSION = '1.0.25'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swiss-crm-activemerchant-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.23
4
+ version: 1.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-07-21 00:00:00.000000000 Z
11
+ date: 2025-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport