swiss-crm-activemerchant-v2 1.0.20 → 1.0.22
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10b566d3f08b9618f3d388ca8a9cc3c65b9f33284cc2f3b33ffc78594e36e5a1
|
4
|
+
data.tar.gz: 19593bf9c7e4be5d20337ffeeba40e0dc4be4d5e43373f30a360e57ccc1b7013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2192ddf6220e465fb44881042a0aa91a56d6b194680ed93147672777ee8f1a7701aa0d3f9d0b0d975a2b497ff85bcd756d0d67cb66f4603b85605fc2c696b48
|
7
|
+
data.tar.gz: d8ec8c557433f4d9b0acf5f7e6de78c278c06953e0cc8ba7841aafb40723fed4581c58534dfcd3373303b5021418a958dc9eac7a7a15b56321ac8b59bcb4d231
|
@@ -39,8 +39,12 @@ module ActiveMerchant #:nodoc:
|
|
39
39
|
def purchase(amount, payment_source, options = {})
|
40
40
|
post = {}
|
41
41
|
add_invoice(post, amount, options)
|
42
|
-
|
42
|
+
|
43
|
+
result = add_payment_source(post, payment_source, options)
|
44
|
+
return result if result.is_a?(Response) && !result.success?
|
45
|
+
|
43
46
|
add_idempotency_id(post, options)
|
47
|
+
add_statement_descriptor(post, options)
|
44
48
|
|
45
49
|
verification_data = options[:verification_data] || {}
|
46
50
|
commit('transaction', post, verification_data, options)
|
@@ -145,6 +149,10 @@ module ActiveMerchant #:nodoc:
|
|
145
149
|
post[:idempotency_id] = options['idempotency_id']
|
146
150
|
end
|
147
151
|
|
152
|
+
def add_statement_descriptor(post, options)
|
153
|
+
post[:statement_descriptor] = options['descriptor']
|
154
|
+
end
|
155
|
+
|
148
156
|
def add_identity_data(post, options)
|
149
157
|
billing = options[:billing_address] || {}
|
150
158
|
first_name, last_name = split_names(billing[:name])
|
@@ -254,6 +262,7 @@ module ActiveMerchant #:nodoc:
|
|
254
262
|
merchant: @merchant_id,
|
255
263
|
source: params[:instrument_id],
|
256
264
|
idempotency_id: params[:idempotency_id],
|
265
|
+
statement_descriptor: params[:statement_descriptor],
|
257
266
|
tags: params[:tags]
|
258
267
|
}
|
259
268
|
else
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# lib/swiss/gateways/mollie_gateway.rb
|
2
|
+
|
3
|
+
require 'mollie'
|
4
|
+
|
5
|
+
module ActiveMerchant
|
6
|
+
module Billing
|
7
|
+
class MollieGateway < Gateway
|
8
|
+
self.supported_countries = %w[NL DE BE FR AT FI UK US]
|
9
|
+
self.supported_cardtypes = %i[visa master american_express]
|
10
|
+
self.default_currency = 'EUR'
|
11
|
+
self.money_format = :cents
|
12
|
+
self.display_name = 'Mollie'
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :api_key)
|
16
|
+
super
|
17
|
+
Mollie::Client.configure do |config|
|
18
|
+
config.api_key = options[:api_key]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def purchase(amount, _payment_source, options = {})
|
23
|
+
payload = build_payment_payload(amount, options)
|
24
|
+
mollie_payment = Mollie::Payment.create(payload)
|
25
|
+
|
26
|
+
Response.new(
|
27
|
+
true,
|
28
|
+
mollie_payment.status,
|
29
|
+
mollie_payment.to_h,
|
30
|
+
test: test?,
|
31
|
+
authorization: mollie_payment.id,
|
32
|
+
redirect_url: mollie_payment.checkout_url,
|
33
|
+
params: {
|
34
|
+
mollie_checkout_url: mollie_payment.checkout_url,
|
35
|
+
payment_method: mollie_payment.method,
|
36
|
+
status: mollie_payment.status
|
37
|
+
}
|
38
|
+
)
|
39
|
+
rescue Mollie::Exception => e
|
40
|
+
Response.new(false, e.message, {}, test: test?)
|
41
|
+
end
|
42
|
+
|
43
|
+
def refund(amount, authorization, options = {})
|
44
|
+
payment = Mollie::Payment.get(authorization)
|
45
|
+
refund = payment.refunds.create(
|
46
|
+
amount: {
|
47
|
+
value: sprintf('%.2f', amount / 100.0),
|
48
|
+
currency: payment.amount['currency']
|
49
|
+
}
|
50
|
+
)
|
51
|
+
|
52
|
+
Response.new(true, 'Refund initiated', refund.to_h, test: test?, authorization: refund.id)
|
53
|
+
rescue Mollie::Exception => e
|
54
|
+
Response.new(false, e.message, {}, test: test?)
|
55
|
+
end
|
56
|
+
|
57
|
+
def fetch_payment_status(authorization)
|
58
|
+
payment = Mollie::Payment.get(authorization)
|
59
|
+
Response.new(payment.paid?, payment.status, payment.to_h, test: test?)
|
60
|
+
rescue Mollie::Exception => e
|
61
|
+
Response.new(false, e.message, {}, test: test?)
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def build_payment_payload(amount, options)
|
67
|
+
{
|
68
|
+
amount: {
|
69
|
+
value: sprintf('%.2f', amount.to_f / 100),
|
70
|
+
currency: options[:currency] || default_currency
|
71
|
+
},
|
72
|
+
method: options[:payment_method],
|
73
|
+
description: options[:description] || "Order ##{options[:order_id]}",
|
74
|
+
redirect_url: options[:redirect_url],
|
75
|
+
webhook_url: options[:webhook_url],
|
76
|
+
metadata: {
|
77
|
+
order_id: options[:order_id],
|
78
|
+
customer_id: options[:customer_id]
|
79
|
+
}.compact
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def test?
|
84
|
+
ENV['MOLLIE_ENV'] == 'test'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
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.22
|
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-
|
11
|
+
date: 2025-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -334,6 +334,7 @@ files:
|
|
334
334
|
- lib/active_merchant/billing/gateways/modern_payments.rb
|
335
335
|
- lib/active_merchant/billing/gateways/modern_payments_cim.rb
|
336
336
|
- lib/active_merchant/billing/gateways/moka.rb
|
337
|
+
- lib/active_merchant/billing/gateways/mollie.rb
|
337
338
|
- lib/active_merchant/billing/gateways/monei.rb
|
338
339
|
- lib/active_merchant/billing/gateways/moneris.rb
|
339
340
|
- lib/active_merchant/billing/gateways/money_movers.rb
|