arrow_payments 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/.gitignore +25 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +3 -0
  5. data/README.md +272 -0
  6. data/Rakefile +10 -0
  7. data/arrow_payments.gemspec +25 -0
  8. data/lib/arrow_payments.rb +25 -0
  9. data/lib/arrow_payments/address.rb +11 -0
  10. data/lib/arrow_payments/client.rb +57 -0
  11. data/lib/arrow_payments/client/customers.rb +45 -0
  12. data/lib/arrow_payments/client/payment_methods.rb +90 -0
  13. data/lib/arrow_payments/client/transactions.rb +64 -0
  14. data/lib/arrow_payments/configuration.rb +7 -0
  15. data/lib/arrow_payments/connection.rb +78 -0
  16. data/lib/arrow_payments/customer.rb +38 -0
  17. data/lib/arrow_payments/entity.rb +39 -0
  18. data/lib/arrow_payments/errors.rb +13 -0
  19. data/lib/arrow_payments/line_item.rb +10 -0
  20. data/lib/arrow_payments/payment_method.rb +19 -0
  21. data/lib/arrow_payments/recurring_billing.rb +30 -0
  22. data/lib/arrow_payments/transaction.rb +74 -0
  23. data/lib/arrow_payments/version.rb +3 -0
  24. data/spec/arrow_payments_spec.rb +40 -0
  25. data/spec/client_spec.rb +42 -0
  26. data/spec/configuration_spec.rb +24 -0
  27. data/spec/customer_spec.rb +29 -0
  28. data/spec/customers_spec.rb +160 -0
  29. data/spec/entity_spec.rb +55 -0
  30. data/spec/fixtures/complete_payment_method.json +37 -0
  31. data/spec/fixtures/customer.json +25 -0
  32. data/spec/fixtures/customers.json +133 -0
  33. data/spec/fixtures/headers/payment_method_complete.yml +9 -0
  34. data/spec/fixtures/headers/payment_method_start.yml +9 -0
  35. data/spec/fixtures/line_item.json +8 -0
  36. data/spec/fixtures/start_payment_method.json +6 -0
  37. data/spec/fixtures/transaction.json +29 -0
  38. data/spec/fixtures/transaction_capture.json +5 -0
  39. data/spec/fixtures/transactions.json +68 -0
  40. data/spec/line_item_spec.rb +17 -0
  41. data/spec/payment_method_spec.rb +16 -0
  42. data/spec/payment_methods_spec.rb +181 -0
  43. data/spec/recurring_billing_spec.rb +28 -0
  44. data/spec/spec_helper.rb +19 -0
  45. data/spec/transactions_spec.rb +101 -0
  46. metadata +225 -0
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe ArrowPayments::RecurringBilling do
4
+ it { should respond_to :id }
5
+ it { should respond_to :payment_method_id }
6
+ it { should respond_to :frequency }
7
+ it { should respond_to :total_amount }
8
+ it { should respond_to :shipping_amount }
9
+ it { should respond_to :description }
10
+ it { should respond_to :transaction_day }
11
+ it { should respond_to :date_created }
12
+ it { should respond_to :frequency_name }
13
+
14
+ describe '#frequency_name' do
15
+ let(:billing) { ArrowPayments::RecurringBilling.new }
16
+
17
+ it 'returns nil is frequency is not set' do
18
+ billing.frequency_name.should be_nil
19
+ end
20
+
21
+ it 'returns a human name for frequency' do
22
+ %w(W M Q Y).each do |s|
23
+ billing.frequency = s
24
+ billing.frequency_name.should_not be_nil
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ $:.unshift File.expand_path("../..", __FILE__)
2
+
3
+ require 'webmock'
4
+ require 'webmock/rspec'
5
+ require 'json'
6
+ require 'lib/arrow_payments'
7
+
8
+ def fixture_path(filename=nil)
9
+ path = File.expand_path("../fixtures", __FILE__)
10
+ filename.nil? ? path : File.join(path, filename)
11
+ end
12
+
13
+ def fixture(file)
14
+ File.read(File.join(fixture_path, file))
15
+ end
16
+
17
+ def json_fixture(file)
18
+ JSON.parse(fixture(file))
19
+ end
@@ -0,0 +1,101 @@
1
+ require 'spec_helper'
2
+
3
+ describe ArrowPayments::Transactions do
4
+ let(:client) { ArrowPayments.client }
5
+
6
+ before :all do
7
+ ArrowPayments::Configuration.api_key = 'foobar'
8
+ ArrowPayments::Configuration.merchant_id = 'foo'
9
+ ArrowPayments::Configuration.mode = 'sandbox'
10
+ end
11
+
12
+ describe '#transaction' do
13
+ it 'returns a transaction by ID' do
14
+ stub_request(:get, "http://demo.arrowpayments.com/api/foobar/transaction/40023").
15
+ to_return(:status => 200, :body => fixture('transaction.json'), :headers => {})
16
+
17
+ tran = client.transaction('40023')
18
+
19
+ tran.should_not be_nil
20
+ tran.id.should eq(40023)
21
+ end
22
+
23
+ it 'returns nil if transaction does not exist' do
24
+ stub_request(:get, "http://demo.arrowpayments.com/api/foobar/transaction/400231").
25
+ to_return(:status => 404, :body => "", :headers => {:error => "Transaction Not Found"})
26
+
27
+ client.transaction('400231').should be_nil
28
+ end
29
+ end
30
+
31
+ describe '#transactions' do
32
+ it 'raises error on invalid status argument' do
33
+ expect { client.transactions(10162, 'Foo') }.to raise_error "Invalid status: Foo"
34
+ end
35
+
36
+ it 'returns unsettled transactions' do
37
+ stub_request(:get, "http://demo.arrowpayments.com/api/foobar/customer/10162/Transactions/NotSettled").
38
+ to_return(:status => 200, :body => fixture('transactions.json'), :headers => {})
39
+
40
+ transactions = client.transactions(10162, 'NotSettled')
41
+
42
+ transactions.should_not be_empty
43
+ transactions.size.should eq(2)
44
+ transactions.map(&:status).uniq.first.should eq('Not Settled')
45
+ end
46
+
47
+ it 'returns transactions for status' do
48
+ pending 'API endpoint is not implemented'
49
+ end
50
+ end
51
+
52
+ describe '#create_transaction' do
53
+ pending
54
+ end
55
+
56
+ describe '#capture_transaction' do
57
+ it 'raises error if transaction does not exist' do
58
+ stub_request(:post, "http://demo.arrowpayments.com/api/transaction/capture").
59
+ with(
60
+ :body => "{\"TransactionId\":10162,\"Amount\":100,\"ApiKey\":\"foobar\",\"MID\":\"foo\"}",
61
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}
62
+ ).
63
+ to_return(:status => 404, :body => "", :headers => {:error => "Transaction Not Found"})
64
+
65
+ expect { client.capture_transaction(10162, 100) }.to raise_error "Transaction Not Found"
66
+ end
67
+
68
+ it 'captures transaction for amount' do
69
+ stub_request(:post, "http://demo.arrowpayments.com/api/transaction/capture").
70
+ with(
71
+ :body => "{\"TransactionId\":10162,\"Amount\":100,\"ApiKey\":\"foobar\",\"MID\":\"foo\"}",
72
+ :headers => {'Accept'=>'application/json', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}
73
+ ).
74
+ to_return(:status => 200, :body => fixture('transaction_capture.json'), :headers => {})
75
+
76
+ client.capture_transaction(10162, 100).should be_true
77
+ end
78
+
79
+ it 'raises a error if amount is greater than original' do
80
+ pending
81
+ end
82
+
83
+ it 'raises an error if transaction is already captured' do
84
+ pending
85
+ end
86
+ end
87
+
88
+ describe '#void_transaction' do
89
+ it 'raises an error if transaction does not exist' do
90
+ pending
91
+ end
92
+
93
+ it 'voids transaction' do
94
+ pending
95
+ end
96
+
97
+ it 'raises an error if transaction is already voided' do
98
+ pending
99
+ end
100
+ end
101
+ end
metadata ADDED
@@ -0,0 +1,225 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: arrow_payments
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Sosedoff
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: webmock
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.9'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.9'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.12'
62
+ - !ruby/object:Gem::Dependency
63
+ name: faraday
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '0.8'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '0.8'
78
+ - !ruby/object:Gem::Dependency
79
+ name: faraday_middleware
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '0.8'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.8'
94
+ - !ruby/object:Gem::Dependency
95
+ name: hashie
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '2.0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '2.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: json
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '1.7'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.7'
126
+ description: Ruby wrapper for ArrowPayments gateway
127
+ email:
128
+ - dan.sosedoff@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - .gitignore
134
+ - .rspec
135
+ - .travis.yml
136
+ - Gemfile
137
+ - README.md
138
+ - Rakefile
139
+ - arrow_payments.gemspec
140
+ - lib/arrow_payments.rb
141
+ - lib/arrow_payments/address.rb
142
+ - lib/arrow_payments/client.rb
143
+ - lib/arrow_payments/client/customers.rb
144
+ - lib/arrow_payments/client/payment_methods.rb
145
+ - lib/arrow_payments/client/transactions.rb
146
+ - lib/arrow_payments/configuration.rb
147
+ - lib/arrow_payments/connection.rb
148
+ - lib/arrow_payments/customer.rb
149
+ - lib/arrow_payments/entity.rb
150
+ - lib/arrow_payments/errors.rb
151
+ - lib/arrow_payments/line_item.rb
152
+ - lib/arrow_payments/payment_method.rb
153
+ - lib/arrow_payments/recurring_billing.rb
154
+ - lib/arrow_payments/transaction.rb
155
+ - lib/arrow_payments/version.rb
156
+ - spec/arrow_payments_spec.rb
157
+ - spec/client_spec.rb
158
+ - spec/configuration_spec.rb
159
+ - spec/customer_spec.rb
160
+ - spec/customers_spec.rb
161
+ - spec/entity_spec.rb
162
+ - spec/fixtures/complete_payment_method.json
163
+ - spec/fixtures/customer.json
164
+ - spec/fixtures/customers.json
165
+ - spec/fixtures/headers/payment_method_complete.yml
166
+ - spec/fixtures/headers/payment_method_start.yml
167
+ - spec/fixtures/line_item.json
168
+ - spec/fixtures/start_payment_method.json
169
+ - spec/fixtures/transaction.json
170
+ - spec/fixtures/transaction_capture.json
171
+ - spec/fixtures/transactions.json
172
+ - spec/line_item_spec.rb
173
+ - spec/payment_method_spec.rb
174
+ - spec/payment_methods_spec.rb
175
+ - spec/recurring_billing_spec.rb
176
+ - spec/spec_helper.rb
177
+ - spec/transactions_spec.rb
178
+ homepage: http://github.com/sosedoff/arrow_payments
179
+ licenses: []
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubyforge_project:
198
+ rubygems_version: 1.8.24
199
+ signing_key:
200
+ specification_version: 3
201
+ summary: Ruby wrapper for ArrowPayments gateway
202
+ test_files:
203
+ - spec/arrow_payments_spec.rb
204
+ - spec/client_spec.rb
205
+ - spec/configuration_spec.rb
206
+ - spec/customer_spec.rb
207
+ - spec/customers_spec.rb
208
+ - spec/entity_spec.rb
209
+ - spec/fixtures/complete_payment_method.json
210
+ - spec/fixtures/customer.json
211
+ - spec/fixtures/customers.json
212
+ - spec/fixtures/headers/payment_method_complete.yml
213
+ - spec/fixtures/headers/payment_method_start.yml
214
+ - spec/fixtures/line_item.json
215
+ - spec/fixtures/start_payment_method.json
216
+ - spec/fixtures/transaction.json
217
+ - spec/fixtures/transaction_capture.json
218
+ - spec/fixtures/transactions.json
219
+ - spec/line_item_spec.rb
220
+ - spec/payment_method_spec.rb
221
+ - spec/payment_methods_spec.rb
222
+ - spec/recurring_billing_spec.rb
223
+ - spec/spec_helper.rb
224
+ - spec/transactions_spec.rb
225
+ has_rdoc: