balanced 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e69cc58c7b89500cead1e3ed9a7e87488942aa72
4
+ data.tar.gz: 845faa189939c479db8234bbe615ad68c0fbcc59
5
+ SHA512:
6
+ metadata.gz: 00a427992fe65be31e2caeb435dc4ee25fa6e85c26559ae321fd53a3f83be55305541e4f2f16e14f4e9838d190888d4458c15aa2389d60ec612085bd77a08090
7
+ data.tar.gz: 69f1756cee7c1c263b341502299bcbe4102cdb128c982f2393354b85738e315ec70d310058c4ef17448ef6987f60e8d70409b4c2aa46fd5ec46b2b0511a87ac8
data/README.md CHANGED
@@ -19,10 +19,12 @@ Or install it yourself as:
19
19
 
20
20
  $ gem install balanced
21
21
 
22
- ## Usage
23
-
24
- See https://www.balancedpayments.com/docs/overview?language=ruby for tutorials and documentation.
22
+ ## Documentation & Usage
25
23
 
24
+ * [Balanced Overview](https://www.balancedpayments.com/docs/overview?language=ruby)
25
+ * [RDoc](http://rubydoc.info/gems/balanced)
26
+ * [Balanced API with Ruby examples](https://www.balancedpayments.com/docs/api?language=ruby)
27
+ * [Example scripts](https://github.com/balanced/balanced-ruby/tree/master/examples)
26
28
 
27
29
  ## Contributing
28
30
 
@@ -75,4 +77,4 @@ Documentation is built using YARD - http://rubydoc.info/docs/yard
75
77
  #####OpenSSL
76
78
  SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
77
79
 
78
- The machine's Ruby/OpenSSL environment can't find any root certificates to trust. Please refer [here](http://www.google.com/search?q=SSL+connect+returned=1+errno=0+state=SSLv3) to find the best solution for your environment.
80
+ The machine's Ruby/OpenSSL environment can't find any root certificates to trust. Please refer [here](http://www.google.com/search?q=SSL+connect+returned=1+errno=0+state=SSLv3) to find the best solution for your environment.
@@ -0,0 +1,115 @@
1
+ cwd = File.dirname(File.dirname(File.absolute_path(__FILE__)))
2
+ $:.unshift(cwd + "/lib")
3
+ require 'balanced'
4
+ require 'ruby-debug'
5
+
6
+
7
+ begin
8
+ Balanced::Card
9
+ rescue NameError
10
+ raise "wtf"
11
+ end
12
+
13
+ host = ENV.fetch('BALANCED_HOST') { nil }
14
+ options = {}
15
+ if host
16
+ options[:scheme] = 'http'
17
+ options[:host] = host
18
+ options[:port] = 5000
19
+ end
20
+
21
+ Balanced.configure(nil, options)
22
+
23
+ puts "create our new api key"
24
+ api_key = Balanced::ApiKey.new.save
25
+ puts "Our secret is: ", api_key.secret
26
+ secret = api_key.secret
27
+
28
+ puts "configure with our secret #{secret}"
29
+ Balanced.configure(secret)
30
+
31
+ puts "create our marketplace"
32
+ begin
33
+ marketplace = Balanced::Marketplace.new.save
34
+ rescue Balanced::Conflict => ex
35
+ marketplace = Balanced::Marketplace.mine
36
+ end
37
+
38
+ puts "create a customer"
39
+ #
40
+ customer = marketplace.create_customer(
41
+ :name => "Bill",
42
+ :email => "bill@bill.com",
43
+ :business_name => "Bill Inc.",
44
+ :ssn_last4 => "1234",
45
+ :address => {
46
+ :line1 => "1234 1st Street",
47
+ :city => "San Francisco",
48
+ :state => "CA"
49
+ }
50
+ ).save
51
+
52
+ puts "our customer uri is #{customer.uri}"
53
+
54
+ puts "create a card and a bank account for our customer"
55
+
56
+ bank_account = marketplace.create_bank_account(
57
+ :account_number => "1234567980",
58
+ :bank_code => "321174811",
59
+ :name => "Jack Q Merchant"
60
+ )
61
+
62
+ card = marketplace.create_card(
63
+ :card_number => "4111111111111111",
64
+ :expiration_month => "12",
65
+ :expiration_year => "2015",
66
+ ).save
67
+
68
+ puts "our bank account uri is #{bank_account.uri}"
69
+ puts "our card uri is #{card.uri}"
70
+
71
+ puts "associate the newly created bank account and card to our customer"
72
+ debugger
73
+ customer.add_card(card)
74
+ customer.add_bank_account(bank_account)
75
+
76
+ puts "check and make sure our customer now has a card and bank account listed"
77
+
78
+ raise "customer's cards should not be empty" unless customer.cards.any?
79
+ raise "customer's bank accounts should not be empty" unless customer.bank_accounts.any?
80
+
81
+ puts "create a debit on our customer"
82
+
83
+ customer.debit(
84
+ :amount => 5000,
85
+ :description => "new debit"
86
+ )
87
+
88
+ puts "check to make sure debit is added"
89
+
90
+ raise "customer should not have 0 debits" unless customer.debits.any?
91
+ raise "customer debit should be 5000" unless customer.debits.first.amount == 5000
92
+
93
+ puts "create a credit on our customer"
94
+
95
+ customer.credit(
96
+ :amount => 2500,
97
+ :description => "new credit"
98
+ )
99
+
100
+ puts "check to make sure credit is added"
101
+
102
+ raise "customer should not have 0 credits" unless customer.credits.any?
103
+ raise "customer should be 2500" unless customer.credits.first.amount == 2500
104
+
105
+ puts "check to see what is the active card for a customer"
106
+
107
+ raise "active card is incorrect" unless customer.active_card.id == card.id
108
+
109
+ puts "check to see what is the active bank_account for a customer"
110
+
111
+ raise "active bank account is incorrect" unless customer.active_bank_account.id == bank_account.id
112
+
113
+
114
+
115
+
@@ -13,3 +13,5 @@ require "refund"
13
13
  require "transaction"
14
14
  require "callback"
15
15
  require "event"
16
+ require "customer"
17
+
@@ -0,0 +1,102 @@
1
+ module Balanced
2
+ # A customer represents a business or person within your Marketplace. A
3
+ # customer can have many funding instruments such as cards and bank accounts
4
+ # associated to them.
5
+ #
6
+ class Customer
7
+ include Balanced::Resource
8
+
9
+ def self.uri
10
+ # Override the default nesting
11
+ self.collection_path
12
+ end
13
+
14
+ def initialize attributes = {}
15
+ Balanced::Utils.stringify_keys! attributes
16
+ unless attributes.has_key? 'uri'
17
+ attributes['uri'] = self.class.uri
18
+ end
19
+ super attributes
20
+ end
21
+
22
+ def debit(options = {})
23
+ amount = options[:amount]
24
+ appears_on_statement_as = options[:appears_on_statement_as]
25
+ hold_uri = options[:hold_uri]
26
+ meta = options[:meta]
27
+ description = options[:description]
28
+ source_uri = options[:source_uri]
29
+ on_behalf_of = options[:on_behalf_of] || options[:on_behalf_of_uri]
30
+
31
+ if on_behalf_of
32
+ if on_behalf_of.respond_to? :uri
33
+ on_behalf_of = on_behalf_of.uri
34
+ end
35
+ if !on_behalf_of.is_a?(String)
36
+ raise ArgumentError, 'The on_behalf_of parameter needs to be a customer URI'
37
+ end
38
+ if on_behalf_of == self.uri
39
+ raise ArgumentError, 'The on_behalf_of parameter MAY NOT be the same account as the customer you are debiting!'
40
+ end
41
+ end
42
+
43
+ debit = Debit.new(
44
+ :uri => self.debits_uri,
45
+ :amount => amount,
46
+ :appears_on_statement_as => appears_on_statement_as,
47
+ :hold_uri => hold_uri,
48
+ :meta => meta,
49
+ :description => description,
50
+ :source_uri => source_uri,
51
+ :on_behalf_of_uri => on_behalf_of,
52
+ )
53
+ debit.save
54
+ end
55
+
56
+ def credit(options = {})
57
+ options.merge!(:uri => self.credits_uri)
58
+ Credit.new(options).save
59
+ end
60
+
61
+ # Associates the Card represented by 'card' with this Customer.
62
+ #
63
+ # @return [Card]
64
+
65
+ def add_card(card)
66
+ card.save if card.kind_of?(Balanced::Card) && card.hash.nil?
67
+ self.card_uri = Balanced::Utils.extract_uri_from_object(card)
68
+ save
69
+ end
70
+
71
+ # Associates the BankAccount represented by bank_account with this
72
+ # Customer.
73
+ #
74
+ # @return [BankAccount]
75
+ def add_bank_account(bank_account)
76
+ if bank_account.kind_of?(Balanced::BankAccount) && bank_account.hash.nil?
77
+ bank_account.save
78
+ end
79
+ self.bank_account_uri = Balanced::Utils.extract_uri_from_object(bank_account)
80
+ save
81
+ end
82
+
83
+ def active_card
84
+ pager = Pager.new(
85
+ self.cards_uri,
86
+ :is_active => true,
87
+ :sort => 'created_at,desc',
88
+ :limit => 1)
89
+ pager.first
90
+ end
91
+
92
+ def active_bank_account
93
+ pager = Pager.new(
94
+ self.bank_accounts_uri,
95
+ :is_active => true,
96
+ :sort => 'created_at,desc',
97
+ :limit => 1)
98
+ pager.first
99
+ end
100
+
101
+ end
102
+ end
@@ -209,6 +209,11 @@ module Balanced
209
209
  card.save
210
210
  end
211
211
 
212
+ def create_customer(options = {})
213
+ customer = Customer.new(options)
214
+ customer.save
215
+ end
216
+
212
217
  def create_callback *args
213
218
  warn_on_positional args
214
219
 
@@ -30,6 +30,10 @@ module Balanced
30
30
  word
31
31
  end
32
32
 
33
+ def extract_uri_from_object(object)
34
+ object.respond_to?(:uri) ? object.uri : object
35
+ end
36
+
33
37
  def hash_with_indifferent_read_access base = {}
34
38
  indifferent = Hash.new do |hash, key|
35
39
  hash[key.to_s] if key.is_a? Symbol
@@ -1,3 +1,3 @@
1
1
  module Balanced
2
- VERSION = '0.7.0'
2
+ VERSION = '0.7.1'
3
3
  end
@@ -0,0 +1,228 @@
1
+ require 'spec_helper'
2
+
3
+ describe Balanced::Customer, :vcr do
4
+ before do
5
+ api_key = Balanced::ApiKey.new.save
6
+ Balanced.configure api_key.secret
7
+ @marketplace = Balanced::Marketplace.new.save
8
+ end
9
+
10
+ describe "Customer.uri", :vcr do
11
+
12
+ context "when Api Key is configured properly", :vcr do
13
+ before do
14
+ api_key = Balanced::ApiKey.new.save
15
+ Balanced.configure api_key.secret
16
+ Balanced::Customer.new
17
+ end
18
+
19
+ it "matches the resource's uri structure" do
20
+ uri = Balanced::Customer.uri
21
+ uri.should_not be_nil
22
+ uri.should match CUSTOMERS_URI_REGEX
23
+ end
24
+ end
25
+ end
26
+
27
+ describe "customer", :vcr do
28
+ describe "#create", :vcr do
29
+ before do
30
+ @customer = @marketplace.create_customer(
31
+ :name => "Bill",
32
+ :email => "bill@bill.com",
33
+ :business_name => "Bill Inc.",
34
+ :ssn_last4 => "1234",
35
+ :address => {
36
+ :line1 => "1234 1st Street",
37
+ :city => "San Francisco",
38
+ :state => "CA"
39
+ }
40
+ ).save
41
+ end
42
+ it "should create a new customer" do
43
+ @customer.should_not be_nil
44
+ end
45
+ it "should contain the correct attributes" do
46
+ @customer.name.should eq("Bill")
47
+ @customer.email.should eq("bill@bill.com")
48
+ @customer.business_name.should eq("Bill Inc.")
49
+ end
50
+ end
51
+
52
+ describe "#add_card using untokenized object", :vcr do
53
+ before do
54
+ @customer = @marketplace.create_customer
55
+ @card = Balanced::Card.new(
56
+ :card_number => "4111111111111111",
57
+ :expiration_month => "12",
58
+ :expiration_year => "2015",
59
+ )
60
+ @customer.add_card(@card)
61
+ end
62
+ it "should add a card to a customer" do
63
+ @customer.cards.size.should eq(1)
64
+ end
65
+ end
66
+
67
+ describe "#add_card using tokenized object", :vcr do
68
+ before do
69
+ @customer = @marketplace.create_customer
70
+ @card = @marketplace.create_card(
71
+ :card_number => "4111111111111111",
72
+ :expiration_month => "12",
73
+ :expiration_year => "2015",
74
+ ).save
75
+ @customer.add_card(@card)
76
+ @customer_card_id = @customer.cards.first.id
77
+ @card_id = @card.id
78
+ end
79
+ it "should add a card to a customer" do
80
+ @customer.cards.size.should eq(1)
81
+ end
82
+ it "card added should be the same card" do
83
+ @customer_card_id.should eq(@card_id)
84
+ end
85
+ end
86
+
87
+ describe "#add_card using uri", :vcr do
88
+ before do
89
+ @customer = @marketplace.create_customer
90
+ @card = @marketplace.create_card(
91
+ :card_number => "4111111111111111",
92
+ :expiration_month => "12",
93
+ :expiration_year => "2015",
94
+ ).save
95
+ @customer.add_card(@card.uri)
96
+ @customer_card_id = @customer.cards.first.id
97
+ @card_id = @card.id
98
+ end
99
+ it "should add a card to a customer" do
100
+ @customer.cards.size.should eq(1)
101
+ end
102
+ it "card added should be the same card" do
103
+ @customer_card_id.should eq(@card_id)
104
+ end
105
+ end
106
+
107
+ describe "#add_bank_account using tokenized object", :vcr do
108
+ before do
109
+ @customer = @marketplace.create_customer
110
+ @bank_account = @marketplace.create_bank_account(
111
+ :account_number => "1234567980",
112
+ :bank_code => "321174811",
113
+ :name => "Jack Q Merchant"
114
+ )
115
+ @customer.add_bank_account(@bank_account)
116
+ @customer_bank_account_id = @customer.bank_accounts.first.id
117
+ @bank_account_id = @bank_account.id
118
+ end
119
+ it "should add a bank account to a customer" do
120
+ @customer.bank_accounts.size.should eq(1)
121
+ end
122
+ it "bank account added should be the same bank account" do
123
+ @customer_bank_account_id = @bank_account_id
124
+ end
125
+ end
126
+
127
+ describe "#add_bank_account using uri", :vcr do
128
+ before do
129
+ @customer = @marketplace.create_customer
130
+ @bank_account = @marketplace.create_bank_account(
131
+ :account_number => "1234567980",
132
+ :bank_code => "321174811",
133
+ :name => "Jack Q Merchant"
134
+ )
135
+ @customer.add_bank_account(@bank_account.uri)
136
+ @customer_bank_account_id = @customer.bank_accounts.first.id
137
+ @bank_account_id = @bank_account.id
138
+ end
139
+ it "should add a bank account to a customer" do
140
+ @customer.bank_accounts.size.should eq(1)
141
+ end
142
+ it "bank account added should be the same bank account" do
143
+ @customer_bank_account_id = @bank_account_id
144
+ end
145
+ end
146
+
147
+ describe "#debit" do
148
+ before do
149
+ @customer = @marketplace.create_customer
150
+ @card = @marketplace.create_card(
151
+ :card_number => "4111111111111111",
152
+ :expiration_month => "12",
153
+ :expiration_year => "2015",
154
+ ).save
155
+ @customer.add_card(@card)
156
+ @customer.debit :amount => 1000
157
+ end
158
+ context "customer debit should be added" do
159
+ subject {@customer.debits.first}
160
+ its(:amount) { should eq 1000}
161
+ end
162
+ end
163
+
164
+ describe "compound credit and debit", :vcr do
165
+ before do
166
+ @customer = @marketplace.create_customer
167
+ @bank_account = @marketplace.create_bank_account(
168
+ :account_number => "1234567980",
169
+ :bank_code => "321174811",
170
+ :name => "Jack Q Merchant"
171
+ )
172
+ @card = Balanced::Card.new(
173
+ :card_number => "4111111111111111",
174
+ :expiration_month => "12",
175
+ :expiration_year => "2015",
176
+ ).save
177
+ @customer.add_card(@card)
178
+ @customer.add_bank_account(@bank_account)
179
+ @customer.debit :amount => 1250
180
+ end
181
+
182
+ context "args passed by name via options hash" do
183
+ subject {
184
+ @customer.credit(
185
+ amount: 1250,
186
+ description: "description",
187
+ meta: {}
188
+ )
189
+ }
190
+
191
+ its(:amount) { should == 1250 }
192
+ its(:meta) { should == {} }
193
+ its(:description) { should == "description" }
194
+ end
195
+ end
196
+
197
+ describe "#active_card", :vcr do
198
+ before do
199
+ @customer = @marketplace.create_customer
200
+ @card = @marketplace.create_card(
201
+ :card_number => "4111111111111111",
202
+ :expiration_month => "12",
203
+ :expiration_year => "2015",
204
+ ).save
205
+ @customer.add_card(@card)
206
+ end
207
+ it "should display the most recently added valid card" do
208
+ @customer.active_card.should_not be_nil
209
+ end
210
+ end
211
+
212
+ describe "#active_bank_account", :vcr do
213
+ before do
214
+ @customer = @marketplace.create_customer
215
+ @bank_account = @marketplace.create_bank_account(
216
+ :account_number => "1234567980",
217
+ :bank_code => "321174811",
218
+ :name => "Jack Q Merchant"
219
+ )
220
+ @customer.add_bank_account(@bank_account)
221
+ end
222
+ it "should display the most recently added valid card" do
223
+ @customer.active_bank_account.should_not be_nil
224
+ end
225
+ end
226
+ end
227
+
228
+ end
data/spec/spec_helper.rb CHANGED
@@ -48,3 +48,4 @@ DEBITS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/debits/
48
48
  TRANSACTIONS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/transactions/
49
49
  CREDITS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/credits/
50
50
  CARDS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/cards/
51
+ CUSTOMERS_URI_REGEX = /\/v1\/customers/
data/upload_docs.rb CHANGED
@@ -22,7 +22,8 @@ args = [
22
22
  'lib/balanced/resources/hold.rb',
23
23
  'lib/balanced/resources/marketplace.rb',
24
24
  'lib/balanced/resources/merchant.rb',
25
- 'lib/balanced/resources/transaction.rb'
25
+ 'lib/balanced/resources/transaction.rb',
26
+ 'lib/balanced/resources/customer.rb'
26
27
  ]
27
28
 
28
29
  YARD::CLI::CommandParser.run(*args)
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: balanced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
5
- prerelease:
4
+ version: 0.7.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mahmoud Abdelkader
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-27 00:00:00.000000000 Z
11
+ date: 2013-05-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: faraday
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.8.6
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.8.6
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: faraday_middleware
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,17 +34,15 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.9.0
46
- description: ! "Balanced is the payments platform for marketplaces.\n Integrate
47
- a payments experience just like Amazon for your marketplace.\n Forget about dealing
41
+ description: "Balanced is the payments platform for marketplaces.\n Integrate a
42
+ payments experience just like Amazon for your marketplace.\n Forget about dealing
48
43
  with banking systems, compliance, fraud, and security.\n "
49
44
  email:
50
- - !binary |-
51
- bWFobW91ZEBwb3VuZHBheS5jb20=
45
+ - mahmoud@poundpay.com
52
46
  executables: []
53
47
  extensions: []
54
48
  extra_rdoc_files: []
@@ -75,6 +69,7 @@ files:
75
69
  - doc/balanced_templates/default/onefile/html/setup.rb
76
70
  - doc/balanced_templates/default/tags/html/index.erb
77
71
  - examples/bank_account_debits.rb
72
+ - examples/customers.rb
78
73
  - examples/events_and_callbacks.rb
79
74
  - examples/examples.rb
80
75
  - lib/balanced.rb
@@ -88,6 +83,7 @@ files:
88
83
  - lib/balanced/resources/callback.rb
89
84
  - lib/balanced/resources/card.rb
90
85
  - lib/balanced/resources/credit.rb
86
+ - lib/balanced/resources/customer.rb
91
87
  - lib/balanced/resources/debit.rb
92
88
  - lib/balanced/resources/event.rb
93
89
  - lib/balanced/resources/hold.rb
@@ -106,11 +102,11 @@ files:
106
102
  - spec/balanced/resources/bank_account_spec.rb
107
103
  - spec/balanced/resources/callback_spec.rb
108
104
  - spec/balanced/resources/credit_spec.rb
105
+ - spec/balanced/resources/customer_spec.rb
109
106
  - spec/balanced/resources/hold_spec.rb
110
107
  - spec/balanced/resources/marketplace_spec.rb
111
108
  - spec/balanced/resources/merchant_spec.rb
112
109
  - spec/balanced/resources/resource_spec.rb
113
- - spec/balanced/resources/transactions_spec.rb
114
110
  - spec/balanced/response/balanced_exception_middleware_spec.rb
115
111
  - spec/balanced_spec.rb
116
112
  - spec/client_spec.rb
@@ -119,27 +115,26 @@ files:
119
115
  - upload_docs.rb
120
116
  homepage: https://balancedpayments.com
121
117
  licenses: []
118
+ metadata: {}
122
119
  post_install_message:
123
120
  rdoc_options: []
124
121
  require_paths:
125
122
  - lib
126
123
  required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
124
  requirements:
129
- - - ! '>='
125
+ - - '>='
130
126
  - !ruby/object:Gem::Version
131
127
  version: '0'
132
128
  required_rubygems_version: !ruby/object:Gem::Requirement
133
- none: false
134
129
  requirements:
135
- - - ! '>='
130
+ - - '>='
136
131
  - !ruby/object:Gem::Version
137
132
  version: '0'
138
133
  requirements: []
139
134
  rubyforge_project:
140
- rubygems_version: 1.8.24
135
+ rubygems_version: 2.0.3
141
136
  signing_key:
142
- specification_version: 3
137
+ specification_version: 4
143
138
  summary: Sign up on https://balancedpayments.com/
144
139
  test_files:
145
140
  - spec/balanced/error_spec.rb
@@ -149,14 +144,13 @@ test_files:
149
144
  - spec/balanced/resources/bank_account_spec.rb
150
145
  - spec/balanced/resources/callback_spec.rb
151
146
  - spec/balanced/resources/credit_spec.rb
147
+ - spec/balanced/resources/customer_spec.rb
152
148
  - spec/balanced/resources/hold_spec.rb
153
149
  - spec/balanced/resources/marketplace_spec.rb
154
150
  - spec/balanced/resources/merchant_spec.rb
155
151
  - spec/balanced/resources/resource_spec.rb
156
- - spec/balanced/resources/transactions_spec.rb
157
152
  - spec/balanced/response/balanced_exception_middleware_spec.rb
158
153
  - spec/balanced_spec.rb
159
154
  - spec/client_spec.rb
160
155
  - spec/spec_helper.rb
161
156
  - spec/utils_spec.rb
162
- has_rdoc:
@@ -1,66 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Balanced::Transaction, :vcr do
4
- before do
5
- api_key = Balanced::ApiKey.new.save
6
- Balanced.configure api_key.secret
7
- @marketplace = Balanced::Marketplace.new.save
8
-
9
- @merchant_attributes = {
10
- :type => "person",
11
- :name => "Billy Jones",
12
- :street_address => "801 High St.",
13
- :postal_code => "94301",
14
- :country => "USA",
15
- :dob => "1842-01",
16
- :phone_number => "+16505551234",
17
- }
18
- bank_account = @marketplace.create_bank_account(
19
- :account_number => "1234567890",
20
- :bank_code => "321174851",
21
- :name => "Jack Q Merchant"
22
- )
23
- card = Balanced::Card.new(
24
- :card_number => "4111111111111111",
25
- :expiration_month => "1",
26
- :expiration_year => "2015",
27
- ).save
28
- @merchant = @marketplace.create_merchant(
29
- :email_address => "merchant@example.org",
30
- :merchant => @merchant_attributes,
31
- :bank_account_uri => bank_account.uri,
32
- :name => "Jack Q Merchant"
33
- )
34
- @buyer = @marketplace.create_buyer(
35
- :email_address => "buyer+transactions@example.org",
36
- :card_uri => card.uri,
37
- :name => "Jack Q Buyer"
38
- ).save
39
-
40
- 1.upto 5 do |n|
41
- @buyer.debit(:amount => 1000, :description => "Transaction ##{n}")
42
- @merchant.credit(:amount => 500, :description => "Credit from Debit ##{n}")
43
- end
44
-
45
- end
46
-
47
- describe "Transaction", :vcr do
48
- it "#all" do
49
- Balanced::Transaction.all.length.should eql(15)
50
- end
51
-
52
- describe "#paginate", :vcr do
53
- it "#total" do
54
- Balanced::Transaction.paginate.total.should eql(15)
55
- end
56
-
57
- it "#each" do
58
- counter = 0
59
- Balanced::Transaction.paginate.each do |transaction|
60
- counter += 1
61
- end
62
- counter.should eql(15)
63
- end
64
- end
65
- end
66
- end