paylane 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Paylane
1
+ # Paylane [![Build Status](https://travis-ci.org/shellycloud/paylane.png)](https://travis-ci.org/shellycloud/paylane) [![Code Climate](https://codeclimate.com/github/shellycloud/paylane.png)](https://codeclimate.com/github/shellycloud/paylane)
2
2
 
3
3
  Ruby client for [PayLane](http://www.paylane.com) payments.
4
4
 
@@ -2,6 +2,7 @@ require "savon"
2
2
  require "paylane/version"
3
3
  require "paylane/gateway"
4
4
  require "paylane/api"
5
+ require "paylane/product"
5
6
  require "paylane/payment"
6
7
  require "paylane/recurring_payment"
7
8
  require "paylane/railtie" if defined?(Rails)
@@ -4,6 +4,7 @@ module PayLane
4
4
  gateway = Gateway.new(PayLane.login, PayLane.password)
5
5
  @api = API.new(gateway.connect)
6
6
  @options = options
7
+ @product = Product.new @options[:product]
7
8
  end
8
9
 
9
10
  def charge_card(amount)
@@ -14,15 +15,6 @@ module PayLane
14
15
  do_payment(amount, {'account_data' => account_data})
15
16
  end
16
17
 
17
- private
18
-
19
- def do_payment(amount, payment_method)
20
- @amount = amount
21
- response = @api.multi_sale(params.merge('payment_method' => payment_method))
22
- PayLane.logger.info("[PayLane] #{response}")
23
- response
24
- end
25
-
26
18
  protected
27
19
 
28
20
  def params
@@ -32,7 +24,7 @@ module PayLane
32
24
  'currency_code' => PayLane.currency,
33
25
  'processing_date' => "#{Date.today}",
34
26
  'product' => {
35
- 'description' => "[#{@options[:product]}][#{Time.now.getutc}]"
27
+ 'description' => @product.description
36
28
  }
37
29
  }
38
30
  end
@@ -48,6 +40,15 @@ module PayLane
48
40
  def customer
49
41
  {}
50
42
  end
43
+
44
+ private
45
+
46
+ def do_payment(amount, payment_method)
47
+ @amount = amount
48
+ response = @api.multi_sale(params.merge('payment_method' => payment_method))
49
+ PayLane.logger.info("[PayLane] #{response}")
50
+ response
51
+ end
51
52
  end
52
53
  end
53
54
 
@@ -0,0 +1,13 @@
1
+ module PayLane
2
+ class Product
3
+ def initialize(attributes)
4
+ @attributes = attributes
5
+ end
6
+
7
+ def description
8
+ attributes = Array(@attributes) << Time.now.getutc
9
+ attributes.map { |a| "[#{a}]" }.join ''
10
+ end
11
+ end
12
+ end
13
+
@@ -5,6 +5,7 @@ module PayLane
5
5
  @api = API.new(gateway.connect)
6
6
  @previous_sale_id = previous_sale_id
7
7
  @options = options
8
+ @product = Product.new @options[:product]
8
9
  end
9
10
 
10
11
  def charge_card(amount)
@@ -21,7 +22,7 @@ module PayLane
21
22
  'id_sale' => @previous_sale_id,
22
23
  'amount' => @amount,
23
24
  'currency' => PayLane.currency,
24
- 'description' => "[#{@options[:product]}][#{Time.now.getutc}]"
25
+ 'description' => @product.description
25
26
  }
26
27
  end
27
28
  end
@@ -1,3 +1,3 @@
1
1
  module PayLane
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -12,14 +12,15 @@ describe PayLane::Payment do
12
12
  'currency_code' => 'EUR',
13
13
  'processing_date' => "#{Date.today}",
14
14
  'product' => {
15
- 'description' => '[][2012-11-30 06:30:00 UTC]'
15
+ 'description' => '[2012-11-30 06:30:00 UTC]'
16
16
  }
17
17
  }
18
18
  end
19
19
 
20
20
  before do
21
21
  PayLane.stub_chain(:logger, :info)
22
- Time.stub_chain(:now, :getutc).and_return(Time.utc(2012, 11, 30, 6, 30))
22
+ PayLane::Product.stub_chain(:new, :description).
23
+ and_return('[2012-11-30 06:30:00 UTC]')
23
24
  end
24
25
 
25
26
  describe '#charge_card' do
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe PayLane::Product do
4
+ before do
5
+ Time.stub_chain(:now, :getutc).and_return(Time.utc(2012, 11, 30, 6, 30))
6
+ end
7
+
8
+ describe '#description' do
9
+ it 'handles product description' do
10
+ product = PayLane::Product.new 'tank'
11
+ product.description.should == '[tank][2012-11-30 06:30:00 UTC]'
12
+
13
+ product = PayLane::Product.new %w(black tank)
14
+ product.description.should == '[black][tank][2012-11-30 06:30:00 UTC]'
15
+ end
16
+ end
17
+ end
18
+
@@ -2,23 +2,25 @@ require 'spec_helper'
2
2
 
3
3
  describe PayLane::RecurringPayment do
4
4
  let(:api) { PayLane::API }
5
- let(:recurring_payment) { PayLane::RecurringPayment.new(12345) }
6
5
 
7
6
  before do
8
7
  PayLane.stub_chain(:logger, :info)
9
- Time.stub_chain(:now, :getutc).and_return(Time.utc(2012, 11, 30, 6, 30))
8
+ PayLane::Product.stub_chain(:new, :description).
9
+ and_return('[2012-11-30 06:30:00 UTC]')
10
10
  end
11
11
 
12
12
  describe '#charge_card' do
13
13
  it 'charges previosuly charged account' do
14
+ payment = PayLane::RecurringPayment.new(1)
14
15
  expected_params = {
15
- 'id_sale' => 12345,
16
+ 'id_sale' => 1,
16
17
  'amount' => 20.00,
17
18
  'currency' => 'EUR',
18
- 'description' => '[][2012-11-30 06:30:00 UTC]'
19
+ 'description' => '[2012-11-30 06:30:00 UTC]'
19
20
  }
21
+
20
22
  api.any_instance.should_receive(:resale).with(expected_params)
21
- recurring_payment.charge_card(20.00)
23
+ payment.charge_card 20.00
22
24
  end
23
25
  end
24
26
  end
metadata CHANGED
@@ -2,79 +2,79 @@
2
2
  name: paylane
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bartlomiej Kozal
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
12
+ date: 2013-05-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
16
16
  type: :runtime
17
17
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
18
  requirements:
20
19
  - - '='
21
20
  - !ruby/object:Gem::Version
22
21
  version: 1.2.0
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
22
  none: false
23
+ version_requirements: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '='
28
26
  - !ruby/object:Gem::Version
29
27
  version: 1.2.0
28
+ none: false
29
+ prerelease: false
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  type: :development
33
33
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
34
  requirements:
36
35
  - - ! '>='
37
36
  - !ruby/object:Gem::Version
38
37
  version: '0'
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
38
  none: false
39
+ version_requirements: !ruby/object:Gem::Requirement
42
40
  requirements:
43
41
  - - ! '>='
44
42
  - !ruby/object:Gem::Version
45
43
  version: '0'
44
+ none: false
45
+ prerelease: false
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec
48
48
  type: :development
49
49
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
50
  requirements:
52
51
  - - ! '>='
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0'
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
54
  none: false
55
+ version_requirements: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - ! '>='
60
58
  - !ruby/object:Gem::Version
61
59
  version: '0'
60
+ none: false
61
+ prerelease: false
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: fakeweb
64
64
  type: :development
65
65
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
66
  requirements:
68
67
  - - ! '>='
69
68
  - !ruby/object:Gem::Version
70
69
  version: '0'
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
70
  none: false
71
+ version_requirements: !ruby/object:Gem::Requirement
74
72
  requirements:
75
73
  - - ! '>='
76
74
  - !ruby/object:Gem::Version
77
75
  version: '0'
76
+ none: false
77
+ prerelease: false
78
78
  description: Ruby client for PayLane service.
79
79
  email:
80
80
  - bkzl@me.com
@@ -94,6 +94,7 @@ files:
94
94
  - lib/paylane/connection_error.rb
95
95
  - lib/paylane/gateway.rb
96
96
  - lib/paylane/payment.rb
97
+ - lib/paylane/product.rb
97
98
  - lib/paylane/railtie.rb
98
99
  - lib/paylane/recurring_payment.rb
99
100
  - lib/paylane/response.rb
@@ -103,6 +104,7 @@ files:
103
104
  - spec/paylane/api_spec.rb
104
105
  - spec/paylane/gateway_spec.rb
105
106
  - spec/paylane/payment_spec.rb
107
+ - spec/paylane/product_spec.rb
106
108
  - spec/paylane/recurring_payment_spec.rb
107
109
  - spec/paylane/resposne_spec.rb
108
110
  - spec/spec_helper.rb
@@ -113,17 +115,23 @@ rdoc_options: []
113
115
  require_paths:
114
116
  - lib
115
117
  required_ruby_version: !ruby/object:Gem::Requirement
116
- none: false
117
118
  requirements:
118
119
  - - ! '>='
119
120
  - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ hash: -486414746515133137
120
124
  version: '0'
121
- required_rubygems_version: !ruby/object:Gem::Requirement
122
125
  none: false
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
127
  requirements:
124
128
  - - ! '>='
125
129
  - !ruby/object:Gem::Version
130
+ segments:
131
+ - 0
132
+ hash: -486414746515133137
126
133
  version: '0'
134
+ none: false
127
135
  requirements: []
128
136
  rubyforge_project:
129
137
  rubygems_version: 1.8.23
@@ -135,6 +143,7 @@ test_files:
135
143
  - spec/paylane/api_spec.rb
136
144
  - spec/paylane/gateway_spec.rb
137
145
  - spec/paylane/payment_spec.rb
146
+ - spec/paylane/product_spec.rb
138
147
  - spec/paylane/recurring_payment_spec.rb
139
148
  - spec/paylane/resposne_spec.rb
140
149
  - spec/spec_helper.rb