mollie-ruby 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f2ddd5345adc0e656b61334bdf89dabf46ae80a
4
- data.tar.gz: 0730c68b44c3378e2286cf000eb884d1d1c1cef1
3
+ metadata.gz: b0fddf0df04e01df0ad52f53a615bc01fc93ad9f
4
+ data.tar.gz: 5a2f2996bf5a52d6d1b2a67c601e25663fcf8a5a
5
5
  SHA512:
6
- metadata.gz: adbe66a522ce7f2a62d7be0c298209c01ddd0697b0375cb4d8bcd9a88d28f7bfc101da9547ca4836af3ffeab8cffff3a3793c6999295469314d1f6983c1ae42a
7
- data.tar.gz: 51b17c14446d239917126b96af0c142c66613a4932148d6471e60aa976a4084a071b8858d56e85f7c20f6e3e392a8f12bfca4318f4e0028857f75d8047362be4
6
+ metadata.gz: 92c98f3eff7f02df5069a5ac470209490e653c74005a9c60872df877dfc834bf92a0968d98d205a7b5470f6dbf05917c72bdb57d847f65bb8c18684f7111eb90
7
+ data.tar.gz: d8487caafe1a2de0ec2467a43d454f5c128591b5e62033d0d5e2ddeda84f92d59940115a029523797edae946e05dc674d295bdadaacfca58d6145253179a2633
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem "codeclimate-test-reporter", group: :test, require: nil
3
4
  # Specify your gem's dependencies in mollie.gemspec
4
5
  gemspec
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Mollie API client for Ruby
2
2
 
3
3
  [![wercker status](https://app.wercker.com/status/a8cb5d924bf5a477b7e7b0b971a51470/m/master "wercker status")](https://app.wercker.com/project/bykey/a8cb5d924bf5a477b7e7b0b971a51470)
4
+ [![Gem Version](https://badge.fury.io/rb/mollie-ruby.svg)](http://badge.fury.io/rb/mollie-ruby)
5
+ [![Code Climate](https://codeclimate.com/github/pero-ict-solutions/mollie-ruby/badges/gpa.svg)](https://codeclimate.com/github/pero-ict-solutions/mollie-ruby)
6
+ [![Test Coverage](https://codeclimate.com/github/pero-ict-solutions/mollie-ruby/badges/coverage.svg)](https://codeclimate.com/github/pero-ict-solutions/mollie-ruby)
4
7
 
5
8
  Accepting [iDEAL](https://www.mollie.nl/betaaldiensten/ideal/), [Mister Cash](https://www.mollie.nl/betaaldiensten/mistercash/), [Creditcard](https://www.mollie.nl/betaaldiensten/creditcard/), and [paysafecard](https://www.mollie.nl/betaaldiensten/paysafecard/) online payments without fixed monthly costs or any punishing registration procedures. Just use the Mollie API to receive payments directly on your website.
6
9
 
@@ -16,12 +19,18 @@ To use the Mollie API client, the following things are required:
16
19
 
17
20
  Add this line to your application's Gemfile:
18
21
 
19
- gem 'mollie-ruby', github: 'pero-ict-solutions/mollie-ruby', require: 'mollie'
22
+ gem 'mollie-ruby', require: 'mollie'
20
23
 
21
24
  And then execute:
22
25
 
23
26
  $ bundle
24
27
 
28
+ ### Using from github source
29
+
30
+ If you want to use the latest 'edge' code, you can use this line in your Gemfile:
31
+
32
+ gem 'mollie-ruby', github: 'pero-ict-solutions/mollie-ruby', require: 'mollie'
33
+
25
34
  ## Usage
26
35
 
27
36
  the most basic way of getting paid is to prepare the payment on the Mollie server and then redirect the user to the provided `paymentUrl`. Make sure you store the payment `id` for further references. When the user makes a payment, Mollie will call the provided `redirect_url` webhook with the `id` as the POST parameter.
data/lib/mollie/client.rb CHANGED
@@ -16,14 +16,15 @@ module Mollie
16
16
  "Bearer " + self.api_key
17
17
  end
18
18
 
19
- def prepare_payment(amount, description, redirect_url, metadata = {})
19
+ def prepare_payment(amount, description, redirect_url, metadata = {}, method=nil, method_params = {})
20
20
  response = self.class.post('/payments',
21
21
  :body => {
22
22
  :amount => amount,
23
23
  :description => description,
24
24
  :redirectUrl => redirect_url,
25
- :metadata => metadata
26
- },
25
+ :metadata => metadata,
26
+ :method => method
27
+ }.merge(method_params),
27
28
  :headers => {
28
29
  'Authorization' => auth_token
29
30
  }
@@ -31,6 +32,16 @@ module Mollie
31
32
  JSON.parse(response.body)
32
33
  end
33
34
 
35
+ def issuers
36
+ response = self.class.get("/issuers",
37
+ :headers => {
38
+ 'Authorization' => auth_token
39
+ }
40
+ )
41
+ response = JSON.parse(response.body)
42
+ response["data"].map {|issuer| {id: issuer["id"], name: issuer["name"]} }
43
+ end
44
+
34
45
  def payment_status(payment_id)
35
46
  response = self.class.get("/payments/#{payment_id}",
36
47
  :headers => {
@@ -1,3 +1,3 @@
1
1
  module Mollie
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/mollie.gemspec CHANGED
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rspec'
26
26
  spec.add_development_dependency 'vcr'
27
27
  spec.add_development_dependency 'webmock'
28
- spec.add_development_dependency 'simplecov'
28
+ spec.add_development_dependency 'pry'
29
+ spec.add_development_dependency 'codeclimate-test-reporter'
29
30
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  describe Mollie::Client do
4
4
 
5
- let(:api_key) { "test_6zjmE6z9SRyzUs7hRbl7AY6MU5jFoW" }
5
+ let(:api_key) { "test_4drFuX5HdjBaFxdXoaABYD8yO4HjuT" }
6
6
 
7
7
  context '#prepare' do
8
8
 
@@ -29,6 +29,17 @@ describe Mollie::Client do
29
29
  end
30
30
  end
31
31
 
32
+ context "issuers" do
33
+ it "returns a hash with the iDeal issuers" do
34
+ VCR.use_cassette('get_issuers_list') do
35
+ client = Mollie::Client.new(api_key)
36
+ response = client.issuers
37
+ expect(response.first[:id]).to eql "ideal_TESTNL99"
38
+ expect(response.first[:name]).to eql "TBM Bank"
39
+ end
40
+ end
41
+ end
42
+
32
43
  context 'status' do
33
44
  context 'when payment is paid' do
34
45
  it "returns the paid status" do
@@ -51,4 +62,14 @@ describe Mollie::Client do
51
62
  end
52
63
  end
53
64
 
65
+ context "error response" do
66
+ it "will raise an Exception" do
67
+ VCR.use_cassette('invalid_key') do
68
+ client = Mollie::Client.new(api_key << "foo")
69
+ response = client.refund_payment("tr_8NQDMOE7EC")
70
+ expect(response["error"]).to_not be nil
71
+ end
72
+ end
73
+ end
74
+
54
75
  end
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
- require 'simplecov'
2
- SimpleCov.start
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
3
3
 
4
4
  require 'mollie'
5
5
  require 'vcr'
6
+ require 'pry'
6
7
 
7
8
  # This file was generated by the `rspec --init` command. Conventionally, all
8
9
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
@@ -24,4 +25,5 @@ end
24
25
  VCR.configure do |c|
25
26
  c.cassette_library_dir = 'spec/vcr_cassettes'
26
27
  c.hook_into :webmock # or :fakeweb
28
+ c.ignore_hosts 'codeclimate.com'
27
29
  end
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.mollie.nl/v1/issuers
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer test_4drFuX5HdjBaFxdXoaABYD8yO4HjuT
12
+ response:
13
+ status:
14
+ code: 200
15
+ message: OK
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 08 Oct 2014 20:21:37 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Content-Length:
24
+ - '105'
25
+ Connection:
26
+ - keep-alive
27
+ Access-Control-Allow-Credentials:
28
+ - 'true'
29
+ Access-Control-Allow-Methods:
30
+ - GET, POST, HEAD, OPTIONS, DELETE
31
+ Access-Control-Max-Age:
32
+ - '300'
33
+ Strict-Transport-Security:
34
+ - max-age=31556926; includeSubDomains
35
+ X-Whom:
36
+ - dc1-web-1
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"totalCount":1,"offset":0,"count":1,"data":[{"id":"ideal_TESTNL99","name":"TBM
40
+ Bank","method":"ideal"}]}'
41
+ http_version:
42
+ recorded_at: Wed, 08 Oct 2014 20:21:37 GMT
43
+ recorded_with: VCR 2.9.3
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  Authorization:
11
- - Bearer test_6zjmE6z9SRyzUs7hRbl7AY6MU5jFoW
11
+ - Bearer test_4drFuX5HdjBaFxdXoaABYD8yO4HjuT
12
12
  response:
13
13
  status:
14
14
  code: 200
@@ -39,6 +39,6 @@ http_interactions:
39
39
  string: '{"id":"tr_8NQDMOE7EC","mode":"test","createdDatetime":"2014-08-12T12:27:26.0Z","status":"paid","paidDatetime":"2014-08-12T12:33:23.0Z","amount":"99.99","description":"My
40
40
  fantastic product","method":"ideal","metadata":null,"details":{"consumerName":"T.
41
41
  TEST","consumerAccount":"NL17RABO0213698412","consumerBic":"TESTNL99"},"locale":"nl","links":{"redirectUrl":"http://localhost:3000/payments/1/update"}}'
42
- http_version:
42
+ http_version:
43
43
  recorded_at: Tue, 12 Aug 2014 12:33:39 GMT
44
44
  recorded_with: VCR 2.9.2
@@ -0,0 +1,42 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mollie.nl/v1/payments/tr_8NQDMOE7EC/refunds
6
+ body:
7
+ encoding: UTF-8
8
+ string: ''
9
+ headers:
10
+ Authorization:
11
+ - Bearer test_4drFuX5HdjBaFxdXoaABYD8yO4HjuTfoo
12
+ response:
13
+ status:
14
+ code: 401
15
+ message: Authorization Required
16
+ headers:
17
+ Server:
18
+ - nginx
19
+ Date:
20
+ - Wed, 08 Oct 2014 20:27:36 GMT
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Content-Length:
24
+ - '121'
25
+ Connection:
26
+ - keep-alive
27
+ Access-Control-Allow-Credentials:
28
+ - 'true'
29
+ Access-Control-Allow-Methods:
30
+ - GET, POST, HEAD, OPTIONS, DELETE
31
+ Access-Control-Max-Age:
32
+ - '300'
33
+ Strict-Transport-Security:
34
+ - max-age=31556926; includeSubDomains
35
+ Www-Authenticate:
36
+ - Basic realm="Mollie API Key"
37
+ body:
38
+ encoding: UTF-8
39
+ string: '{"error":{"type":"request","message":"Unauthorized request","links":{"documentation":"https://www.mollie.nl/api/docs/"}}}'
40
+ http_version:
41
+ recorded_at: Wed, 08 Oct 2014 20:27:36 GMT
42
+ recorded_with: VCR 2.9.3
@@ -5,10 +5,10 @@ http_interactions:
5
5
  uri: https://api.mollie.nl/v1/payments
6
6
  body:
7
7
  encoding: UTF-8
8
- string: amount=99.99&description=My%20fantastic%20product&redirectUrl=http%3A%2F%2Flocalhost%3A3000%2Fpayments%2F1%2Fupdate&metadata[order_id]=R232454365
8
+ string: amount=99.99&description=My%20fantastic%20product&redirectUrl=http%3A%2F%2Flocalhost%3A3000%2Fpayments%2F1%2Fupdate&metadata[order_id]=R232454365&method=
9
9
  headers:
10
10
  Authorization:
11
- - Bearer test_6zjmE6z9SRyzUs7hRbl7AY6MU5jFoW
11
+ - Bearer test_4drFuX5HdjBaFxdXoaABYD8yO4HjuT
12
12
  response:
13
13
  status:
14
14
  code: 201
@@ -17,7 +17,7 @@ http_interactions:
17
17
  Server:
18
18
  - nginx
19
19
  Date:
20
- - Tue, 12 Aug 2014 14:16:33 GMT
20
+ - Wed, 08 Oct 2014 08:40:18 GMT
21
21
  Content-Type:
22
22
  - application/json; charset=utf-8
23
23
  Content-Length:
@@ -33,11 +33,11 @@ http_interactions:
33
33
  Strict-Transport-Security:
34
34
  - max-age=31556926; includeSubDomains
35
35
  X-Whom:
36
- - dc1-web-1
36
+ - dc1-web-2
37
37
  body:
38
38
  encoding: UTF-8
39
- string: '{"id":"tr_ALc7B2h9UM","mode":"test","createdDatetime":"2014-08-12T14:16:33.0Z","status":"open","expiryPeriod":"PT15M","amount":"99.99","description":"My
39
+ string: '{"id":"tr_ALc7B2h9UM","mode":"test","createdDatetime":"2014-10-08T08:40:18.0Z","status":"open","expiryPeriod":"PT15M","amount":"99.99","description":"My
40
40
  fantastic product","method":null,"metadata":{"order_id":"R232454365"},"details":null,"links":{"paymentUrl":"https://www.mollie.nl/payscreen/pay/ALc7B2h9UM","redirectUrl":"http://localhost:3000/payments/1/update"}}'
41
- http_version:
42
- recorded_at: Tue, 12 Aug 2014 14:16:34 GMT
43
- recorded_with: VCR 2.9.2
41
+ http_version:
42
+ recorded_at: Wed, 08 Oct 2014 08:40:17 GMT
43
+ recorded_with: VCR 2.9.3
@@ -8,7 +8,7 @@ http_interactions:
8
8
  string: ''
9
9
  headers:
10
10
  Authorization:
11
- - Bearer test_6zjmE6z9SRyzUs7hRbl7AY6MU5jFoW
11
+ - Bearer test_4drFuX5HdjBaFxdXoaABYD8yO4HjuT
12
12
  response:
13
13
  status:
14
14
  code: 201
@@ -39,6 +39,6 @@ http_interactions:
39
39
  string: '{"id":"re_O5sCpw4kwb","payment":{"id":"tr_8NQDMOE7EC","mode":"test","createdDatetime":"2014-08-12T12:27:26.0Z","status":"refunded","expiryPeriod":"PT","amount":"99.99","description":"My
40
40
  fantastic product","method":"ideal","metadata":null,"details":{"consumerName":"T.
41
41
  TEST","consumerAccount":"NL17RABO0213698412","consumerBic":"TESTNL99"},"locale":"nl","links":{"redirectUrl":"http://localhost:3000/payments/1/update"}},"amountRefunded":"99.99","amountRemaining":"0.00","refundedDatetime":"2014-08-12T14:11:32.0Z"}'
42
- http_version:
42
+ http_version:
43
43
  recorded_at: Tue, 12 Aug 2014 14:11:32 GMT
44
44
  recorded_with: VCR 2.9.2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mollie-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Berkenbosch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-08 00:00:00.000000000 Z
11
+ date: 2014-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -95,7 +95,21 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: simplecov
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: codeclimate-test-reporter
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -127,7 +141,9 @@ files:
127
141
  - mollie.gemspec
128
142
  - spec/mollie/client_spec.rb
129
143
  - spec/spec_helper.rb
144
+ - spec/vcr_cassettes/get_issuers_list.yml
130
145
  - spec/vcr_cassettes/get_status_paid.yml
146
+ - spec/vcr_cassettes/invalid_key.yml
131
147
  - spec/vcr_cassettes/prepare_payment.yml
132
148
  - spec/vcr_cassettes/refund_payment.yml
133
149
  - wercker.yml
@@ -158,6 +174,8 @@ summary: Ruby API Client for Mollie
158
174
  test_files:
159
175
  - spec/mollie/client_spec.rb
160
176
  - spec/spec_helper.rb
177
+ - spec/vcr_cassettes/get_issuers_list.yml
161
178
  - spec/vcr_cassettes/get_status_paid.yml
179
+ - spec/vcr_cassettes/invalid_key.yml
162
180
  - spec/vcr_cassettes/prepare_payment.yml
163
181
  - spec/vcr_cassettes/refund_payment.yml