mollie-api-ruby 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ec284eeb3ad861560f79224359db2b81d358c71
4
- data.tar.gz: 8189a32dec6484191ed3e6e18c266af8f8774300
3
+ metadata.gz: e715e8bb3f17bcb8273f8de4d317f8e997509f0e
4
+ data.tar.gz: ee5baaa31d4386ef9a6530b7d15f06eae22cde93
5
5
  SHA512:
6
- metadata.gz: 083c8066728ea429cb3c9556b9eecb881a9bcc1103dde77b95abb15d20ab99c9d99630c4a3fe7e82b733216283a7a1f4804f97de8289b1642664d40d49a4e309
7
- data.tar.gz: 056a9182d27078ff5830d5f3254ee3ff2a57d66de09c38e13c804a8cf636c1ec3fd4967123c265bc9a2e03483ee1a73f056781912a74d4a502ac5d91fc38e1ef
6
+ metadata.gz: cccda5a9e67201819b9024e9764d254209b3d3e6647255b6683ecaea60484b0c52e3e56a3e0a588f29abfa8b1019bda486ceff136a6b2aef742e650f1c3a84ea
7
+ data.tar.gz: be187c4a79959128e3e41881c4fd67960ae27103224c4f1b493afb35c5a926e736ab07a00ee5ca6ae156b9b6b6b520dfd3b4734b3c71ba2e0091749f144f4d81
@@ -3,53 +3,53 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
- #
16
- # Generate a unique order id for this example. It is important to include this unique attribute
17
- # in the redirectUrl (below) so a proper return page can be shown to the customer.
18
- #
19
- order_id = Time.now.to_i
15
+ #
16
+ # Generate a unique order id for this example. It is important to include this unique attribute
17
+ # in the redirectUrl (below) so a proper return page can be shown to the customer.
18
+ #
19
+ order_id = Time.now.to_i
20
20
 
21
- #
22
- # Determine the url parts to these example files.
23
- #
24
- protocol = $request.secure? && "https" || "http"
25
- hostname = $request.host || "localhost"
26
- port = $request.port || 80
27
- path = $request.script_name || ""
21
+ #
22
+ # Determine the url parts to these example files.
23
+ #
24
+ protocol = $request.secure? && "https" || "http"
25
+ hostname = $request.host || "localhost"
26
+ port = $request.port || 80
27
+ path = $request.script_name || ""
28
28
 
29
- #
30
- # Payment parameters:
31
- # amount Amount in EUROs. This example creates a € 10,- payment.
32
- # description Description of the payment.
33
- # redirectUrl Redirect location. The customer will be redirected there after the payment.
34
- # metadata Custom metadata that is stored with the payment.
35
- #
36
- payment = mollie.payments.create \
37
- :amount => 10.00,
38
- :description => "My first API payment",
39
- :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
40
- :metadata => {
41
- :order_id => order_id
42
- }
29
+ #
30
+ # Payment parameters:
31
+ # amount Amount in EUROs. This example creates a € 10,- payment.
32
+ # description Description of the payment.
33
+ # redirectUrl Redirect location. The customer will be redirected there after the payment.
34
+ # metadata Custom metadata that is stored with the payment.
35
+ #
36
+ payment = mollie.payments.create \
37
+ :amount => 10.00,
38
+ :description => "My first API payment",
39
+ :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
40
+ :metadata => {
41
+ :order_id => order_id
42
+ }
43
43
 
44
- #
45
- # In this example we store the order with its payment status in a database.
46
- #
47
- database_write order_id, payment.status
44
+ #
45
+ # In this example we store the order with its payment status in a database.
46
+ #
47
+ database_write order_id, payment.status
48
48
 
49
- #
50
- # Send the customer off to complete the payment.
51
- #
52
- $response.redirect payment.getPaymentUrl
49
+ #
50
+ # Send the customer off to complete the payment.
51
+ #
52
+ $response.redirect payment.getPaymentUrl
53
53
  rescue Mollie::API::Exception => e
54
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
54
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
55
55
  end
@@ -3,39 +3,39 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
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
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
20
 
21
- #
22
- # Update the order in the database.
23
- #
24
- database_write order_id, payment.status
21
+ #
22
+ # Update the order in the database.
23
+ #
24
+ database_write order_id, payment.status
25
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
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
39
  rescue Mollie::API::Exception => e
40
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
40
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
41
41
  end
@@ -5,17 +5,17 @@
5
5
  # Here, it's unnecessary to use the Mollie API Client.
6
6
  #
7
7
  if $request.params.empty?
8
- $response.body << "No order"
8
+ $response.body << "No order"
9
9
  else
10
- status = database_read $request.params['order_id']
10
+ status = database_read $request.params['order_id']
11
11
 
12
- #
13
- # Determine the url parts to these example files.
14
- #
15
- path = $request.script_name || ""
12
+ #
13
+ # Determine the url parts to these example files.
14
+ #
15
+ path = $request.script_name || ""
16
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
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
@@ -3,75 +3,75 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
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
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
20
 
21
- $response.body << '<form method="post">Select your bank: <select name="issuer">'
21
+ $response.body << '<form method="post">Select your bank: <select name="issuer">'
22
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
- }
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
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
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
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 || ""
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
45
 
46
- #
47
- # Payment parameters:
48
- # amount Amount in EUROs. This example creates a € 27,50 payment.
49
- # description Description of the payment.
50
- # redirectUrl Redirect location. The customer will be redirected there after the payment.
51
- # metadata Custom metadata that is stored with the payment.
52
- # method Payment method "ideal".
53
- # issuer The customer's bank. If empty the customer can select it later.
54
- #
55
- payment = mollie.payments.create \
56
- :amount => 27.50,
57
- :description => "My first API payment",
58
- :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
59
- :metadata => {
60
- :order_id => order_id
61
- },
62
- :method => Mollie::API::Object::Method::IDEAL,
63
- :issuer => !$request.params['issuer'].empty? ? $request.params['issuer'] : nil
64
-
65
- #
66
- # In this example we store the order with its payment status in a database.
67
- #
68
- database_write order_id, payment.status
46
+ #
47
+ # Payment parameters:
48
+ # amount Amount in EUROs. This example creates a € 27,50 payment.
49
+ # description Description of the payment.
50
+ # redirectUrl Redirect location. The customer will be redirected there after the payment.
51
+ # metadata Custom metadata that is stored with the payment.
52
+ # method Payment method "ideal".
53
+ # issuer The customer's bank. If empty the customer can select it later.
54
+ #
55
+ payment = mollie.payments.create \
56
+ :amount => 27.50,
57
+ :description => "My first API payment",
58
+ :redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
59
+ :metadata => {
60
+ :order_id => order_id
61
+ },
62
+ :method => Mollie::API::Object::Method::IDEAL,
63
+ :issuer => !$request.params['issuer'].empty? ? $request.params['issuer'] : nil
69
64
 
70
- #
71
- # Send the customer off to complete the payment.
72
- #
73
- $response.redirect payment.getPaymentUrl
74
- end
65
+ #
66
+ # In this example we store the order with its payment status in a database.
67
+ #
68
+ database_write order_id, payment.status
69
+
70
+ #
71
+ # Send the customer off to complete the payment.
72
+ #
73
+ $response.redirect payment.getPaymentUrl
74
+ end
75
75
  rescue Mollie::API::Exception => e
76
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
76
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
77
77
  end
@@ -3,25 +3,25 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
- #
16
- # Get the all payments for this API key ordered by newest.
17
- #
18
- payments = mollie.payments.all
15
+ #
16
+ # Get the all payments for this API key ordered by newest.
17
+ #
18
+ payments = mollie.payments.all
19
19
 
20
- $response.body = "Your API key has #{payments.totalCount} payments, last #{payments.count}:<br>"
20
+ $response.body = "Your API key has #{payments.totalCount} payments, last #{payments.count}:<br>"
21
21
 
22
- payments.each { |payment|
23
- $response.body << "&euro; #{payment.amount}, status: #{CGI.escapeHTML payment.status} (#{CGI.escapeHTML payment.id})<br>"
24
- }
22
+ payments.each { |payment|
23
+ $response.body << "&euro; #{payment.amount}, status: #{CGI.escapeHTML payment.status} (#{CGI.escapeHTML payment.id})<br>"
24
+ }
25
25
  rescue Mollie::API::Exception => e
26
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
26
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
27
27
  end
@@ -3,28 +3,28 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
- #
16
- # Get the all the activated methods for this API key.
17
- #
18
- methods = mollie.methods.all
15
+ #
16
+ # Get the all the activated methods for this API key.
17
+ #
18
+ methods = mollie.methods.all
19
19
 
20
- $response.body << "Your API key has #{methods.totalCount} activated payment methods:<br>"
20
+ $response.body << "Your API key has #{methods.totalCount} activated payment methods:<br>"
21
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
- }
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
28
  rescue Mollie::API::Exception => e
29
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
29
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
30
30
  end
@@ -3,38 +3,38 @@
3
3
  #
4
4
  require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
5
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
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.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
14
14
 
15
- #
16
- # Retrieve the payment you want to refund from the API.
17
- #
18
- payment = mollie.payments.get "tr_47uEE1su8q"
15
+ #
16
+ # Retrieve the payment you want to refund from the API.
17
+ #
18
+ payment = mollie.payments.get "tr_47uEE1su8q"
19
19
 
20
- #
21
- # Refund the payment.
22
- #
23
- refund = mollie.payments_refunds.with(payment).create
20
+ #
21
+ # Refund the payment.
22
+ #
23
+ refund = mollie.payments_refunds.with(payment).create
24
24
 
25
- $response.body << "The payment #{payment.id} is now refunded.<br>"
25
+ $response.body << "The payment #{payment.id} is now refunded.<br>"
26
26
 
27
- #
28
- # Retrieve refunds on a payment.
29
- #
30
- refunds = mollie.payments_refunds.with(payment).all
27
+ #
28
+ # Retrieve refunds on a payment.
29
+ #
30
+ refunds = mollie.payments_refunds.with(payment).all
31
31
 
32
- refunds.each { |refund|
33
- $response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refundedDatetime)
34
- $response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amountRefunded)
35
- $response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amountRemaining)
36
- $response.body << '<br>'
37
- }
32
+ refunds.each { |refund|
33
+ $response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refundedDatetime)
34
+ $response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amountRefunded)
35
+ $response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amountRemaining)
36
+ $response.body << '<br>'
37
+ }
38
38
  rescue Mollie::API::Exception => e
39
- $response.body << "API call failed: " << (CGI.escapeHTML e.message)
39
+ $response.body << "API call failed: " << (CGI.escapeHTML e.message)
40
40
  end