mollie-api-ruby 2.2.0 → 2.2.1
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/CHANGELOG.md +6 -0
- data/README.md +15 -2
- data/examples/apis/api_docs.rb +37 -0
- data/examples/apis/connect.rb +58 -0
- data/examples/apis/customers.rb +115 -0
- data/examples/apis/invoices.rb +38 -0
- data/examples/apis/issuers.rb +35 -0
- data/examples/apis/mandates.rb +83 -0
- data/examples/apis/methods.rb +50 -0
- data/examples/apis/organizations.rb +16 -0
- data/examples/apis/payments.rb +140 -0
- data/examples/apis/permissions.rb +32 -0
- data/examples/apis/profiles.rb +126 -0
- data/examples/apis/refunds.rb +17 -0
- data/examples/apis/settlements.rb +84 -0
- data/examples/apis/subscriptions.rb +165 -0
- data/examples/config.ru +58 -0
- data/examples/public/images/collapse.gif +0 -0
- data/examples/public/images/expand.gif +0 -0
- data/examples/public/images/explorer_icons.png +0 -0
- data/examples/public/images/favicon-16x16.png +0 -0
- data/examples/public/images/favicon-32x32.png +0 -0
- data/examples/public/images/favicon.ico +0 -0
- data/examples/public/images/logo_small.png +0 -0
- data/examples/public/images/pet_store_api.png +0 -0
- data/examples/public/images/throbber.gif +0 -0
- data/examples/public/images/wordnik_api.png +0 -0
- data/examples/public/index.html +101 -0
- data/examples/public/javascripts/lib/backbone-min.js +1 -0
- data/examples/public/javascripts/lib/es5-shim.js +1 -0
- data/examples/public/javascripts/lib/handlebars-4.0.5.js +3 -0
- data/examples/public/javascripts/lib/highlight.9.1.0.pack.js +1 -0
- data/examples/public/javascripts/lib/highlight.9.1.0.pack_extended.js +1 -0
- data/examples/public/javascripts/lib/jquery-1.8.0.min.js +3 -0
- data/examples/public/javascripts/lib/jquery.ba-bbq.min.js +1 -0
- data/examples/public/javascripts/lib/jquery.slideto.min.js +1 -0
- data/examples/public/javascripts/lib/jquery.wiggle.min.js +1 -0
- data/examples/public/javascripts/lib/js-yaml.min.js +2 -0
- data/examples/public/javascripts/lib/jsoneditor.min.js +5 -0
- data/examples/public/javascripts/lib/lodash.min.js +2 -0
- data/examples/public/javascripts/lib/marked.js +1 -0
- data/examples/public/javascripts/lib/object-assign-pollyfill.js +1 -0
- data/examples/public/javascripts/lib/sanitize-html.min.js +4 -0
- data/examples/public/javascripts/lib/swagger-oauth.js +1 -0
- data/examples/public/javascripts/swagger-ui.js +25378 -0
- data/examples/public/javascripts/swagger-ui.min.js +15 -0
- data/examples/public/javascripts/swagger_docs.js +14 -0
- data/examples/public/o2c.html +20 -0
- data/examples/public/stylesheets/reset.css +1 -0
- data/examples/public/stylesheets/screen.css +1545 -0
- data/examples/public/stylesheets/swagger_docs.css +4 -0
- data/examples/public/stylesheets/typography.css +0 -0
- data/lib/mollie/api/client.rb +42 -22
- data/lib/mollie/api/client/version.rb +1 -1
- data/lib/mollie/api/object/invoice.rb +70 -0
- data/lib/mollie/api/object/method.rb +1 -0
- data/lib/mollie/api/object/organization.rb +1 -1
- data/lib/mollie/api/object/payment.rb +21 -7
- data/lib/mollie/api/object/payment/refund.rb +5 -1
- data/lib/mollie/api/resource/base.rb +6 -6
- data/lib/mollie/api/resource/invoices.rb +11 -0
- data/lib/mollie/api/resource/permissions.rb +20 -0
- data/lib/mollie/api/resource/profiles/apikeys.rb +6 -0
- data/lib/mollie/api/resource/refunds.rb +11 -0
- data/lib/mollie/api/resource/settlements.rb +8 -0
- data/lib/mollie/api/resource/settlements/payments.rb +27 -0
- data/mollie.gemspec +7 -0
- data/test/mollie/api/client_test.rb +12 -5
- data/test/mollie/api/object/invoice_test.rb +59 -0
- data/test/mollie/api/object/organization_test.rb +0 -6
- data/test/mollie/api/object/payment_test.rb +15 -0
- data/test/mollie/api/resource/invoices_test.rb +13 -0
- metadata +159 -12
- data/examples/1-new-payment.rb +0 -56
- data/examples/2-webhook-verification.rb +0 -41
- data/examples/3-return-page.rb +0 -21
- data/examples/4-ideal-payment.rb +0 -79
- data/examples/5-payments-history.rb +0 -27
- data/examples/6-list-activated-methods.rb +0 -30
- data/examples/7-refund-payment.rb +0 -40
- data/examples/app.rb +0 -58
- data/examples/orders/.gitignore +0 -1
@@ -1,41 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 2 - How to verify Mollie API Payments in a webhook.
|
3
|
-
#
|
4
|
-
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
|
5
|
-
|
6
|
-
begin
|
7
|
-
#
|
8
|
-
# Initialize the Mollie API library with your API key.
|
9
|
-
#
|
10
|
-
# See: https://www.mollie.nl/beheer/account/profielen/
|
11
|
-
#
|
12
|
-
mollie = Mollie::API::Client.new
|
13
|
-
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
|
14
|
-
|
15
|
-
#
|
16
|
-
# Retrieve the payment's current state.
|
17
|
-
#
|
18
|
-
payment = mollie.payments.get $request.params['id']
|
19
|
-
order_id = payment.metadata.order_id
|
20
|
-
|
21
|
-
#
|
22
|
-
# Update the order in the database.
|
23
|
-
#
|
24
|
-
database_write order_id, payment.status
|
25
|
-
|
26
|
-
if payment.paid?
|
27
|
-
#
|
28
|
-
# At this point you'd probably want to start the process of delivering the product to the customer.
|
29
|
-
#
|
30
|
-
$response.body << "Paid"
|
31
|
-
elsif payment.open? == false
|
32
|
-
#
|
33
|
-
# The payment isn't paid and isn't open anymore. We can assume it was aborted.
|
34
|
-
#
|
35
|
-
$response.body << "Cancelled"
|
36
|
-
else
|
37
|
-
$response.body << "In progress"
|
38
|
-
end
|
39
|
-
rescue Mollie::API::Exception => e
|
40
|
-
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
|
41
|
-
end
|
data/examples/3-return-page.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 3 - How to show a return page to the customer.
|
3
|
-
#
|
4
|
-
# In this example we retrieve the order stored in the database.
|
5
|
-
# Here, it's unnecessary to use the Mollie API Client.
|
6
|
-
#
|
7
|
-
if $request.params.empty?
|
8
|
-
$response.body << "No order"
|
9
|
-
else
|
10
|
-
status = database_read $request.params['order_id']
|
11
|
-
|
12
|
-
#
|
13
|
-
# Determine the url parts to these example files.
|
14
|
-
#
|
15
|
-
path = $request.script_name || ""
|
16
|
-
|
17
|
-
$response.body << "<p>Your payment status is '" << (CGI.escapeHTML status) << "'.</p>"
|
18
|
-
$response.body << "<p>"
|
19
|
-
$response.body << '<a href="' << path << '/">Back to examples</a><br>'
|
20
|
-
$response.body << "</p>"
|
21
|
-
end
|
data/examples/4-ideal-payment.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 4 - How to prepare an iDEAL payment with the Mollie API.
|
3
|
-
#
|
4
|
-
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
|
5
|
-
|
6
|
-
begin
|
7
|
-
#
|
8
|
-
# Initialize the Mollie API library with your API key.
|
9
|
-
#
|
10
|
-
# See: https://www.mollie.nl/beheer/account/profielen/
|
11
|
-
#
|
12
|
-
mollie = Mollie::API::Client.new
|
13
|
-
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
|
14
|
-
|
15
|
-
#
|
16
|
-
# First, let the customer pick the bank in a simple HTML form. This step is actually optional.
|
17
|
-
#
|
18
|
-
if $request.params.empty?
|
19
|
-
issuers = mollie.issuers.all
|
20
|
-
|
21
|
-
$response.body << '<form method="post">Select your bank: <select name="issuer">'
|
22
|
-
|
23
|
-
issuers.each { |issuer|
|
24
|
-
if issuer.method == Mollie::API::Object::Method::IDEAL
|
25
|
-
$response.body << '<option value=' << (CGI.escapeHTML issuer.id) << '>' << (CGI.escapeHTML issuer.name)
|
26
|
-
end
|
27
|
-
}
|
28
|
-
|
29
|
-
$response.body << '<option value="">or select later</option>'
|
30
|
-
$response.body << '</select><button>OK</button></form>'
|
31
|
-
else
|
32
|
-
#
|
33
|
-
# Generate a unique order id for this example. It is important to include this unique attribute
|
34
|
-
# in the redirectUrl (below) so a proper return page can be shown to the customer.
|
35
|
-
#
|
36
|
-
order_id = Time.now.to_i
|
37
|
-
|
38
|
-
#
|
39
|
-
# Determine the url parts to these example files.
|
40
|
-
#
|
41
|
-
protocol = $request.secure? && "https" || "http"
|
42
|
-
hostname = $request.host || "localhost"
|
43
|
-
port = $request.port || 80
|
44
|
-
path = $request.script_name || ""
|
45
|
-
|
46
|
-
#
|
47
|
-
# Payment parameters:
|
48
|
-
# amount Amount in EUROs. This example creates a € 27,50 payment.
|
49
|
-
# description Description of the payment.
|
50
|
-
# redirect_url Redirect location. The customer will be redirected there after the payment.
|
51
|
-
# webhook_url Webhook location, used to report when the payment changes state.
|
52
|
-
# metadata Custom metadata that is stored with the payment.
|
53
|
-
# method Payment method "ideal".
|
54
|
-
# issuer The customer's bank. If empty the customer can select it later.
|
55
|
-
#
|
56
|
-
payment = mollie.payments.create \
|
57
|
-
:amount => 27.50,
|
58
|
-
:description => "My first API payment",
|
59
|
-
:redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
|
60
|
-
:webhook_url => "#{protocol}://#{hostname}:#{port}#{path}/2-webhook-verification",
|
61
|
-
:metadata => {
|
62
|
-
:order_id => order_id
|
63
|
-
},
|
64
|
-
:method => Mollie::API::Object::Method::IDEAL,
|
65
|
-
:issuer => !$request.params['issuer'].empty? ? $request.params['issuer'] : nil
|
66
|
-
|
67
|
-
#
|
68
|
-
# In this example we store the order with its payment status in a database.
|
69
|
-
#
|
70
|
-
database_write order_id, payment.status
|
71
|
-
|
72
|
-
#
|
73
|
-
# Send the customer off to complete the payment.
|
74
|
-
#
|
75
|
-
$response.redirect payment.payment_url
|
76
|
-
end
|
77
|
-
rescue Mollie::API::Exception => e
|
78
|
-
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
|
79
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 5 - How to retrieve your payments history.
|
3
|
-
#
|
4
|
-
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
|
5
|
-
|
6
|
-
begin
|
7
|
-
#
|
8
|
-
# Initialize the Mollie API library with your API key.
|
9
|
-
#
|
10
|
-
# See: https://www.mollie.nl/beheer/account/profielen/
|
11
|
-
#
|
12
|
-
mollie = Mollie::API::Client.new
|
13
|
-
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
|
14
|
-
|
15
|
-
#
|
16
|
-
# Get the all payments for this API key ordered by newest.
|
17
|
-
#
|
18
|
-
payments = mollie.payments.all
|
19
|
-
|
20
|
-
$response.body = "Your API key has #{payments.total_count} payments, last #{payments.count}:<br>"
|
21
|
-
|
22
|
-
payments.each { |payment|
|
23
|
-
$response.body << "€ #{payment.amount}, status: #{CGI.escapeHTML payment.status} (#{CGI.escapeHTML payment.id})<br>"
|
24
|
-
}
|
25
|
-
rescue Mollie::API::Exception => e
|
26
|
-
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
|
27
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 6 - How to get the currently activated payment methods.
|
3
|
-
#
|
4
|
-
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
|
5
|
-
|
6
|
-
begin
|
7
|
-
#
|
8
|
-
# Initialize the Mollie API library with your API key.
|
9
|
-
#
|
10
|
-
# See: https://www.mollie.nl/beheer/account/profielen/
|
11
|
-
#
|
12
|
-
mollie = Mollie::API::Client.new
|
13
|
-
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
|
14
|
-
|
15
|
-
#
|
16
|
-
# Get the all the activated methods for this API key.
|
17
|
-
#
|
18
|
-
methods = mollie.methods.all
|
19
|
-
|
20
|
-
$response.body << "Your API key has #{methods.total_count} activated payment methods:<br>"
|
21
|
-
|
22
|
-
methods.each { |method|
|
23
|
-
$response.body << '<div style="line-height:40px; vertical-align:top">'
|
24
|
-
$response.body << '<img src="' << (CGI.escapeHTML method.image.normal) << '"> '
|
25
|
-
$response.body << (CGI.escapeHTML method.description) << ' (' << (CGI.escapeHTML method.id) << ')'
|
26
|
-
$response.body << '</div>'
|
27
|
-
}
|
28
|
-
rescue Mollie::API::Exception => e
|
29
|
-
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
|
30
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Example 7 - How to refund a payment programmatically.
|
3
|
-
#
|
4
|
-
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)
|
5
|
-
|
6
|
-
begin
|
7
|
-
#
|
8
|
-
# Initialize the Mollie API library with your API key.
|
9
|
-
#
|
10
|
-
# See: https://www.mollie.nl/beheer/account/profielen/
|
11
|
-
#
|
12
|
-
mollie = Mollie::API::Client.new
|
13
|
-
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
|
14
|
-
|
15
|
-
#
|
16
|
-
# Retrieve the payment you want to refund from the API.
|
17
|
-
#
|
18
|
-
payment = mollie.payments.get "tr_47uEE1su8q"
|
19
|
-
|
20
|
-
#
|
21
|
-
# Refund the payment.
|
22
|
-
#
|
23
|
-
refund = mollie.payments_refunds.with(payment).create
|
24
|
-
|
25
|
-
$response.body << "The payment #{payment.id} is now refunded.<br>"
|
26
|
-
|
27
|
-
#
|
28
|
-
# Retrieve refunds on a payment.
|
29
|
-
#
|
30
|
-
refunds = mollie.payments_refunds.with(payment).all
|
31
|
-
|
32
|
-
refunds.each { |refund|
|
33
|
-
$response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refunded_datetime)
|
34
|
-
$response.body << '<br> Refunded: € ' << (CGI.escapeHTML refund.amount_refunded)
|
35
|
-
$response.body << '<br> Remaining: € ' << (CGI.escapeHTML refund.amount_remaining)
|
36
|
-
$response.body << '<br>'
|
37
|
-
}
|
38
|
-
rescue Mollie::API::Exception => e
|
39
|
-
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
|
40
|
-
end
|
data/examples/app.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'sinatra'
|
2
|
-
|
3
|
-
#
|
4
|
-
# Show all examples as links.
|
5
|
-
#
|
6
|
-
examples = [
|
7
|
-
'1-new-payment',
|
8
|
-
'2-webhook-verification',
|
9
|
-
'3-return-page',
|
10
|
-
'4-ideal-payment',
|
11
|
-
'5-payments-history',
|
12
|
-
'6-list-activated-methods',
|
13
|
-
'7-refund-payment'
|
14
|
-
]
|
15
|
-
|
16
|
-
get "/" do
|
17
|
-
index = ""
|
18
|
-
|
19
|
-
examples.each { |example|
|
20
|
-
index << "<a href='/#{example}'>#{example}</a><br>"
|
21
|
-
}
|
22
|
-
|
23
|
-
index
|
24
|
-
end
|
25
|
-
|
26
|
-
#
|
27
|
-
# Register all examples as pages.
|
28
|
-
#
|
29
|
-
examples.each { |example|
|
30
|
-
get "/#{example}" do
|
31
|
-
$request = request
|
32
|
-
$response = response
|
33
|
-
load File.expand_path "#{example}.rb", File.dirname(__FILE__)
|
34
|
-
end
|
35
|
-
|
36
|
-
post "/#{example}" do
|
37
|
-
$request = request
|
38
|
-
$response = response
|
39
|
-
load File.expand_path "#{example}.rb", File.dirname(__FILE__)
|
40
|
-
end
|
41
|
-
}
|
42
|
-
|
43
|
-
#
|
44
|
-
# NOTE: This example uses a text file as a database. Please use a real database like MySQL in production code.
|
45
|
-
#
|
46
|
-
def database_write (order_id, status)
|
47
|
-
order_id = order_id.to_i
|
48
|
-
database = File.expand_path "orders/order-#{order_id}.txt", File.dirname(__FILE__)
|
49
|
-
|
50
|
-
File.open(database, 'w') { |file| file.write status }
|
51
|
-
end
|
52
|
-
|
53
|
-
def database_read (order_id)
|
54
|
-
order_id = order_id.to_i
|
55
|
-
database = File.expand_path "orders/order-#{order_id}.txt", File.dirname(__FILE__)
|
56
|
-
|
57
|
-
status = File.read(database) || "unknown order"
|
58
|
-
end
|
data/examples/orders/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*.txt
|