Skip to content

Commit

Permalink
Merge pull request #48 from mollie/2.0.0
Browse files Browse the repository at this point in the history
Release 2.0.0 (Fixes #45)
  • Loading branch information
Daan van Marsbergen authored Nov 10, 2016
2 parents 09ebb3d + 1fb3803 commit 5327900
Show file tree
Hide file tree
Showing 64 changed files with 1,403 additions and 436 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: ruby
before_install: gem install bundler
rvm:
- 2.0.0
- 2.1
- 2.2
- 2.3.0
- jruby
matrix:
allow_failures:
- rvm: 2.0.0
- rvm: jruby
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
All notable changes to this project will be documented in this file.


#### 2.0.0 - 2016-11-10
- Refactor to a more ruby like library.
- all methods use underscores
- payloads to call api functions will be camel cased before sending
- getters and setters are now just attr_accessors and omit get and set

#### v1.4.2 - 2016-10-19
- Added payment method KBC/CBC Payment Button
- Fixed an issue where the required `mime-types` dependency did not work correctly ([#32](https://github.com/mollie/mollie-api-ruby/pull/32)).
Expand Down
10 changes: 5 additions & 5 deletions README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Mollie API client for Ruby #

[![](https://travis-ci.org/mollie/mollie-api-ruby.png)](https://travis-ci.org/mollie/mollie-api-ruby)

Accepting [iDEAL](https://www.mollie.com/ideal/), [Bancontact/Mister Cash](https://www.mollie.com/mistercash/), [SOFORT Banking](https://www.mollie.com/sofort/), [Creditcard](https://www.mollie.com/creditcard/), [SEPA Bank transfer](https://www.mollie.com/overboeking/), [SEPA Direct debit](https://www.mollie.com/directdebit/), [Bitcoin](https://www.mollie.com/bitcoin/), [PayPal](https://www.mollie.com/paypal/), [KBC/CBC Payment Button](https://www.mollie.com/kbccbc/), [Belfius Direct Net](https://www.mollie.com/belfiusdirectnet/) and [paysafecard](https://www.mollie.com/paysafecard/) online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website or easily refund transactions to your customers.

## Requirements ##
Expand All @@ -11,7 +13,6 @@ To use the Mollie API client, the following things are required:
+ Create a new [Website profile](https://www.mollie.nl/beheer/account/profielen/) to generate API keys (live and test mode) and setup your webhook.
+ Now you're ready to use the Mollie API client in test mode.
+ In order to accept payments in live mode, payment methods must be activated in your account. Follow [a few of steps](https://www.mollie.nl/beheer/diensten), and let us handle the rest.
+ This API client requires the [REST Client](https://github.com/rest-client/rest-client) (with [mime-types](https://github.com/mime-types/ruby-mime-types/) version <3) and [JSON](https://rubygems.org/gems/json) gems.

## Installation ##

Expand All @@ -38,14 +39,13 @@ To successfully receive a payment, these steps should be implemented:
Requiring the Mollie API Client.

```ruby
require 'Mollie/API/Client'
require 'mollie/api/client'
```

Initializing the Mollie API client, and setting your API key.

```ruby
mollie = Mollie::API::Client.new
mollie.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
mollie = Mollie::API::Client.new('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')
```

Creating a new payment.
Expand All @@ -54,7 +54,7 @@ Creating a new payment.
payment = mollie.payments.create(
amount: 10.00,
description: 'My first API payment',
redirectUrl: 'https://webshop.example.org/order/12345/'
redirect_url: 'https://webshop.example.org/order/12345/'
)
```

Expand Down
6 changes: 6 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
task default: %w[test]

task :test do
ruby "test/run-test.rb"
end

9 changes: 4 additions & 5 deletions examples/1-new-payment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 1 - How to prepare a new payment with the Mollie API.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,7 +10,7 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# Generate a unique order id for this example. It is important to include this unique attribute
Expand All @@ -36,11 +36,10 @@
payment = mollie.payments.create \
:amount => 10.00,
:description => "My first API payment",
:redirectUrl => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
:redirect_url => "#{protocol}://#{hostname}:#{port}#{path}/3-return-page?order_id=#{order_id}",
:metadata => {
:order_id => order_id
}

#
# In this example we store the order with its payment status in a database.
#
Expand All @@ -49,7 +48,7 @@
#
# Send the customer off to complete the payment.
#
$response.redirect payment.getPaymentUrl
$response.redirect payment.payment_url
rescue Mollie::API::Exception => e
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
end
4 changes: 2 additions & 2 deletions examples/2-webhook-verification.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 2 - How to verify Mollie API Payments in a webhook.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,7 +10,7 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# Retrieve the payment's current state.
Expand Down
6 changes: 3 additions & 3 deletions examples/4-ideal-payment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 4 - How to prepare an iDEAL payment with the Mollie API.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,7 +10,7 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# First, let the customer pick the bank in a simple HTML form. This step is actually optional.
Expand Down Expand Up @@ -70,7 +70,7 @@
#
# Send the customer off to complete the payment.
#
$response.redirect payment.getPaymentUrl
$response.redirect payment.payment_url
end
rescue Mollie::API::Exception => e
$response.body << "API call failed: " << (CGI.escapeHTML e.message)
Expand Down
6 changes: 3 additions & 3 deletions examples/5-payments-history.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 5 - How to retrieve your payments history.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,14 +10,14 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# Get the all payments for this API key ordered by newest.
#
payments = mollie.payments.all

$response.body = "Your API key has #{payments.totalCount} payments, last #{payments.count}:<br>"
$response.body = "Your API key has #{payments.total_count} payments, last #{payments.count}:<br>"

payments.each { |payment|
$response.body << "&euro; #{payment.amount}, status: #{CGI.escapeHTML payment.status} (#{CGI.escapeHTML payment.id})<br>"
Expand Down
6 changes: 3 additions & 3 deletions examples/6-list-activated-methods.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 6 - How to get the currently activated payment methods.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,14 +10,14 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# Get the all the activated methods for this API key.
#
methods = mollie.methods.all

$response.body << "Your API key has #{methods.totalCount} activated payment methods:<br>"
$response.body << "Your API key has #{methods.total_count} activated payment methods:<br>"

methods.each { |method|
$response.body << '<div style="line-height:40px; vertical-align:top">'
Expand Down
10 changes: 5 additions & 5 deletions examples/7-refund-payment.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Example 7 - How to refund a payment programmatically.
#
require File.expand_path "../lib/Mollie/API/Client", File.dirname(__FILE__)
require File.expand_path "../lib/mollie/api/client", File.dirname(__FILE__)

begin
#
Expand All @@ -10,7 +10,7 @@
# See: https://www.mollie.nl/beheer/account/profielen/
#
mollie = Mollie::API::Client.new
mollie.setApiKey "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
mollie.api_key = "test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"

#
# Retrieve the payment you want to refund from the API.
Expand All @@ -30,9 +30,9 @@
refunds = mollie.payments_refunds.with(payment).all

refunds.each { |refund|
$response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refundedDatetime)
$response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amountRefunded)
$response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amountRemaining)
$response.body << '<br> Refund date: ' << (CGI.escapeHTML refund.refunded_datetime)
$response.body << '<br> Refunded: &euro; ' << (CGI.escapeHTML refund.amount_refunded)
$response.body << '<br> Remaining: &euro; ' << (CGI.escapeHTML refund.amount_remaining)
$response.body << '<br>'
}
rescue Mollie::API::Exception => e
Expand Down
130 changes: 0 additions & 130 deletions lib/Mollie/API/Client.rb

This file was deleted.

18 changes: 0 additions & 18 deletions lib/Mollie/API/Object/Base.rb

This file was deleted.

Loading

0 comments on commit 5327900

Please sign in to comment.