paymill 0.0.3 → 0.1.0

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.
data/README.md CHANGED
@@ -22,20 +22,21 @@ Now you can e.g. create a new client:
22
22
 
23
23
  Paymill::Client.create(email: "stefan.sprenger@dkd.de", description: "He is a Ruby guy.")
24
24
 
25
- Or find a existing client
25
+ Or find a existing client:
26
26
 
27
27
  Paymill::Client.find("client_88a388d9dd48f86c3136")
28
28
 
29
- For retrieving a collection of all clients
29
+ For retrieving a collection of all clients you might use the `all`
30
+ operation:
30
31
 
31
- Paymill::Client.all()
32
+ Paymill::Client.all
32
33
 
33
- We currently only support `create`, `find` and `all` operations.
34
+ We currently only support the operations `create`, `find` and `all`.
34
35
 
35
36
  Requirements
36
37
  =====
37
38
 
38
- This gem was developed using Ruby 1.9 and version 1 of Paymill's API. Nonetheless, it should also work with Ruby 1.8.
39
+ This gem was developed using Ruby 1.9 and version 2 of Paymill's API. Nonetheless, it should also work with Ruby 1.8.
39
40
 
40
41
  Bugs
41
42
  ======
@@ -56,4 +57,4 @@ Note on Patches/Pull Requests
56
57
  Copyright
57
58
  ======
58
59
 
59
- Copyright (c) 2012 dkd Internet Service GmbH, Stefan Sprenger. See LICENSE for details.
60
+ Copyright (c) 2012 dkd Internet Service GmbH, Stefan Sprenger. See LICENSE for details.
data/lib/paymill.rb CHANGED
@@ -4,13 +4,14 @@ require "json"
4
4
  require "paymill/version"
5
5
 
6
6
  module Paymill
7
- API_BASE = "api.paymill.de"
7
+ API_BASE = "api.paymill.de"
8
+ API_VERSION = "v2"
8
9
 
9
10
  @@api_key = nil
10
11
 
11
12
  autoload :Client, "paymill/client"
12
- autoload :CreditCard, "paymill/credit_card"
13
13
  autoload :Offer, "paymill/offer"
14
+ autoload :Payment, "paymill/payment"
14
15
  autoload :Subscription, "paymill/subscription"
15
16
  autoload :Transaction, "paymill/transaction"
16
17
 
@@ -44,7 +45,7 @@ module Paymill
44
45
  https.verify_mode = OpenSSL::SSL::VERIFY_PEER
45
46
  https.ca_file = File.join(File.dirname(__FILE__), "data/paymill.crt")
46
47
  https.start do |connection|
47
- url = "/v1/#{api_url}"
48
+ url = "/#{API_VERSION}/#{api_url}"
48
49
  https_request = case http_method
49
50
  when :post
50
51
  Net::HTTP::Post.new(url)
@@ -6,7 +6,7 @@ module Paymill
6
6
  include Paymill::Operations::Find
7
7
 
8
8
  attr_accessor :id, :email, :description, :attributes, :created_at,
9
- :updated_at, :creditcard, :subscription
9
+ :updated_at, :payment, :subscription
10
10
 
11
11
  def initialize(attributes = {})
12
12
  attributes.each_pair do |key, value|
@@ -1,5 +1,5 @@
1
1
  module Paymill
2
- class CreditCard
2
+ class Payment
3
3
  include Paymill::Operations::All
4
4
  include Paymill::Operations::Create
5
5
  include Paymill::Operations::Find
@@ -5,7 +5,7 @@ module Paymill
5
5
  include Paymill::Operations::Find
6
6
 
7
7
  attr_accessor :id, :amount, :status, :description, :livemode,
8
- :creditcard, :client, :created_at, :updated_at
8
+ :payment, :client, :created_at, :updated_at
9
9
 
10
10
  def initialize(attributes = {})
11
11
  attributes.each_pair do |key, value|
@@ -1,3 +1,3 @@
1
1
  module Paymill
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,50 @@
1
+ require "spec_helper"
2
+
3
+ describe Paymill::Payment do
4
+ let(:valid_attributes) do
5
+ {
6
+ card_type: "visa",
7
+ country: "germany",
8
+ expire_month: 12,
9
+ expire_year: 2012,
10
+ card_holder: "Stefan Sprenger",
11
+ last4: "1111"
12
+ }
13
+ end
14
+
15
+ let (:payment) do
16
+ Paymill::Payment.new(valid_attributes)
17
+ end
18
+
19
+ describe "#initialize" do
20
+ it "initializes all attributes correctly" do
21
+ payment.card_type.should eql("visa")
22
+ payment.country.should eql("germany")
23
+ payment.expire_month.should eql(12)
24
+ payment.expire_year.should eq(2012)
25
+ payment.card_holder.should eql("Stefan Sprenger")
26
+ payment.last4.should eql("1111")
27
+ end
28
+ end
29
+
30
+ describe ".find" do
31
+ it "makes a new GET request using the correct API endpoint to receive a specific creditcard" do
32
+ Paymill.should_receive(:request).with(:get, "payments/123", {}).and_return("data" => {})
33
+ Paymill::Payment.find("123")
34
+ end
35
+ end
36
+
37
+ describe ".all" do
38
+ it "makes a new GET request using the correct API endpoint to receive all payments" do
39
+ Paymill.should_receive(:request).with(:get, "payments/", {}).and_return("data" => {})
40
+ Paymill::Payment.all
41
+ end
42
+ end
43
+
44
+ describe ".create" do
45
+ it "makes a new POST request using the correct API endpoint" do
46
+ Paymill.should_receive(:request).with(:post, "payments", valid_attributes).and_return("data" => {})
47
+ Paymill::Payment.create(valid_attributes)
48
+ end
49
+ end
50
+ end
@@ -7,7 +7,7 @@ describe Paymill::Transaction do
7
7
  status: "pending",
8
8
  description: "Test transaction.",
9
9
  livemode: false,
10
- creditcard: {
10
+ payment: {
11
11
  card_type: "visa",
12
12
  country: "germany"
13
13
  },
@@ -25,8 +25,8 @@ describe Paymill::Transaction do
25
25
  transaction.status.should eql("pending")
26
26
  transaction.description.should eql("Test transaction.")
27
27
  transaction.livemode.should eql(false)
28
- transaction.creditcard[:card_type].should eql("visa")
29
- transaction.creditcard[:country].should eql("germany")
28
+ transaction.payment[:card_type].should eql("visa")
29
+ transaction.payment[:country].should eql("germany")
30
30
  transaction.client.should eql("client_a013c")
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &2160826620 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2160826620
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &2160795040 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,7 +37,12 @@ dependencies:
32
37
  version: '0'
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2160795040
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  description: API wrapper for Paymill.
37
47
  email:
38
48
  - stefan.sprenger@dkd.de
@@ -49,19 +59,19 @@ files:
49
59
  - lib/data/paymill.crt
50
60
  - lib/paymill.rb
51
61
  - lib/paymill/client.rb
52
- - lib/paymill/credit_card.rb
53
62
  - lib/paymill/offer.rb
54
63
  - lib/paymill/operations/all.rb
55
64
  - lib/paymill/operations/create.rb
56
65
  - lib/paymill/operations/delete.rb
57
66
  - lib/paymill/operations/find.rb
67
+ - lib/paymill/payment.rb
58
68
  - lib/paymill/subscription.rb
59
69
  - lib/paymill/transaction.rb
60
70
  - lib/paymill/version.rb
61
71
  - paymill.gemspec
62
72
  - spec/paymill/client_spec.rb
63
- - spec/paymill/credit_card_spec.rb
64
73
  - spec/paymill/offer_spec.rb
74
+ - spec/paymill/payment_spec.rb
65
75
  - spec/paymill/subscription_spec.rb
66
76
  - spec/paymill/transaction_spec.rb
67
77
  - spec/paymill_spec.rb
@@ -80,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
90
  version: '0'
81
91
  segments:
82
92
  - 0
83
- hash: -3243121354173252569
93
+ hash: 4192098067474741217
84
94
  required_rubygems_version: !ruby/object:Gem::Requirement
85
95
  none: false
86
96
  requirements:
@@ -89,17 +99,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
99
  version: '0'
90
100
  segments:
91
101
  - 0
92
- hash: -3243121354173252569
102
+ hash: 4192098067474741217
93
103
  requirements: []
94
104
  rubyforge_project:
95
- rubygems_version: 1.8.10
105
+ rubygems_version: 1.8.19
96
106
  signing_key:
97
107
  specification_version: 3
98
108
  summary: API wrapper for Paymill.
99
109
  test_files:
100
110
  - spec/paymill/client_spec.rb
101
- - spec/paymill/credit_card_spec.rb
102
111
  - spec/paymill/offer_spec.rb
112
+ - spec/paymill/payment_spec.rb
103
113
  - spec/paymill/subscription_spec.rb
104
114
  - spec/paymill/transaction_spec.rb
105
115
  - spec/paymill_spec.rb
@@ -1,50 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Paymill::CreditCard do
4
- let(:valid_attributes) do
5
- {
6
- card_type: "visa",
7
- country: "germany",
8
- expire_month: 12,
9
- expire_year: 2012,
10
- card_holder: "Stefan Sprenger",
11
- last4: "1111"
12
- }
13
- end
14
-
15
- let (:credit_card) do
16
- Paymill::CreditCard.new(valid_attributes)
17
- end
18
-
19
- describe "#initialize" do
20
- it "initializes all attributes correctly" do
21
- credit_card.card_type.should eql("visa")
22
- credit_card.country.should eql("germany")
23
- credit_card.expire_month.should eql(12)
24
- credit_card.expire_year.should eq(2012)
25
- credit_card.card_holder.should eql("Stefan Sprenger")
26
- credit_card.last4.should eql("1111")
27
- end
28
- end
29
-
30
- describe ".find" do
31
- it "makes a new GET request using the correct API endpoint to receive a specific creditcard" do
32
- Paymill.should_receive(:request).with(:get, "creditcards/123", {}).and_return("data" => {})
33
- Paymill::CreditCard.find("123")
34
- end
35
- end
36
-
37
- describe ".all" do
38
- it "makes a new GET request using the correct API endpoint to receive all creditcards" do
39
- Paymill.should_receive(:request).with(:get, "creditcards/", {}).and_return("data" => {})
40
- Paymill::CreditCard.all
41
- end
42
- end
43
-
44
- describe ".create" do
45
- it "makes a new POST request using the correct API endpoint" do
46
- Paymill.should_receive(:request).with(:post, "creditcards", valid_attributes).and_return("data" => {})
47
- Paymill::CreditCard.create(valid_attributes)
48
- end
49
- end
50
- end