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 +4 -4
- data/lib/active_merchant/billing/gateways/mollie.rb +56 -18
- data/lib/active_merchant/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd8c97a821e37c5f68735206a29b4f9633048aa884cad771c148236924215092
|
4
|
+
data.tar.gz: 8f2a182c09ef9168c09ba8e792338a1ccbee01fbabedd53ac9f0eaff41d6f806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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[
|
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
|
-
|
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
|
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?(
|
81
|
-
|
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]
|
101
|
-
post[:description]
|
102
|
-
post[:method]
|
103
|
-
post[:
|
104
|
-
|
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] =
|
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
|
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
|
-
|
159
|
-
|
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']
|
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
|
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.
|
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-
|
11
|
+
date: 2025-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|