balanced 0.8.2 → 1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rbenv-version +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +7 -3
- data/README.md +2 -10
- data/Rakefile +4 -18
- data/balanced.gemspec +8 -10
- data/lib/balanced.rb +28 -28
- data/lib/balanced/client.rb +15 -6
- data/lib/balanced/error.rb +21 -12
- data/lib/balanced/pager.rb +66 -25
- data/lib/balanced/resources.rb +18 -17
- data/lib/balanced/resources/api_key.rb +4 -0
- data/lib/balanced/resources/bank_account.rb +26 -75
- data/lib/balanced/resources/callback.rb +2 -0
- data/lib/balanced/resources/card.rb +15 -65
- data/lib/balanced/resources/card_hold.rb +38 -0
- data/lib/balanced/resources/credit.rb +6 -50
- data/lib/balanced/resources/customer.rb +33 -71
- data/lib/balanced/resources/debit.rb +6 -14
- data/lib/balanced/resources/event.rb +6 -0
- data/lib/balanced/resources/funding_instrument.rb +11 -0
- data/lib/balanced/resources/hypermedia.rb +28 -0
- data/lib/balanced/resources/marketplace.rb +5 -203
- data/lib/balanced/resources/order.rb +71 -0
- data/lib/balanced/resources/refund.rb +2 -7
- data/lib/balanced/resources/resource.rb +169 -106
- data/lib/balanced/resources/reversal.rb +2 -8
- data/lib/balanced/resources/transfer.rb +11 -0
- data/lib/balanced/response/balanced_exception_middleware.rb +2 -2
- data/lib/balanced/utils.rb +47 -14
- data/lib/balanced/version.rb +1 -1
- data/scenario.cache +526 -380
- data/scenarios/api_key_create/definition.rb +1 -0
- data/scenarios/api_key_create/request.rb +2 -0
- data/scenarios/api_key_create/ruby.mako +21 -0
- data/scenarios/api_key_delete/definition.rb +1 -0
- data/scenarios/api_key_delete/request.rb +3 -0
- data/scenarios/api_key_delete/ruby.mako +12 -0
- data/scenarios/api_key_list/definition.rb +1 -0
- data/scenarios/api_key_list/request.rb +2 -0
- data/scenarios/api_key_list/ruby.mako +28 -0
- data/scenarios/api_key_show/definition.rb +1 -0
- data/scenarios/api_key_show/request.rb +2 -0
- data/scenarios/api_key_show/ruby.mako +18 -0
- data/scenarios/{customer_add_bank_account → bank_account_associate_to_customer}/definition.rb +0 -0
- data/scenarios/bank_account_associate_to_customer/request.rb +3 -0
- data/scenarios/bank_account_associate_to_customer/ruby.mako +49 -0
- data/scenarios/bank_account_create/definition.rb +1 -1
- data/scenarios/bank_account_create/request.rb +1 -1
- data/scenarios/bank_account_create/ruby.mako +44 -7
- data/scenarios/{credit_create_existing_bank_account → bank_account_credit}/definition.rb +0 -0
- data/scenarios/bank_account_credit/request.rb +3 -0
- data/scenarios/bank_account_credit/ruby.mako +42 -0
- data/scenarios/bank_account_debit/definition.rb +1 -0
- data/scenarios/bank_account_debit/request.rb +5 -0
- data/scenarios/bank_account_debit/ruby.mako +50 -0
- data/scenarios/bank_account_delete/request.rb +1 -1
- data/scenarios/bank_account_delete/ruby.mako +5 -3
- data/scenarios/bank_account_list/ruby.mako +76 -2
- data/scenarios/bank_account_show/definition.rb +1 -1
- data/scenarios/bank_account_show/request.rb +1 -1
- data/scenarios/bank_account_show/ruby.mako +41 -5
- data/scenarios/bank_account_update/definition.rb +1 -0
- data/scenarios/bank_account_update/request.rb +6 -0
- data/scenarios/bank_account_update/ruby.mako +56 -0
- data/scenarios/bank_account_verification_create/request.rb +1 -1
- data/scenarios/bank_account_verification_create/ruby.mako +20 -3
- data/scenarios/bank_account_verification_show/definition.rb +1 -1
- data/scenarios/bank_account_verification_show/request.rb +1 -1
- data/scenarios/bank_account_verification_show/ruby.mako +21 -4
- data/scenarios/bank_account_verification_update/definition.rb +1 -1
- data/scenarios/bank_account_verification_update/request.rb +5 -5
- data/scenarios/bank_account_verification_update/ruby.mako +24 -8
- data/scenarios/callback_create/definition.rb +1 -1
- data/scenarios/callback_create/request.rb +2 -2
- data/scenarios/callback_create/ruby.mako +22 -0
- data/scenarios/callback_delete/definition.rb +1 -1
- data/scenarios/callback_delete/request.rb +2 -2
- data/scenarios/callback_delete/ruby.mako +12 -0
- data/scenarios/callback_list/definition.rb +1 -1
- data/scenarios/callback_list/request.rb +1 -2
- data/scenarios/callback_list/ruby.mako +20 -0
- data/scenarios/callback_show/definition.rb +1 -1
- data/scenarios/callback_show/request.rb +1 -1
- data/scenarios/callback_show/ruby.mako +20 -0
- data/scenarios/{customer_add_card → card_associate_to_customer}/definition.rb +0 -0
- data/scenarios/card_associate_to_customer/request.rb +3 -0
- data/scenarios/card_associate_to_customer/ruby.mako +49 -0
- data/scenarios/card_create/request.rb +1 -2
- data/scenarios/card_create/ruby.mako +44 -7
- data/scenarios/card_debit/definition.rb +1 -0
- data/scenarios/card_debit/request.rb +5 -0
- data/scenarios/card_debit/ruby.mako +49 -0
- data/scenarios/card_delete/request.rb +1 -1
- data/scenarios/card_delete/ruby.mako +5 -3
- data/scenarios/card_hold_capture/definition.rb +1 -0
- data/scenarios/card_hold_capture/request.rb +5 -0
- data/scenarios/card_hold_capture/ruby.mako +49 -0
- data/scenarios/card_hold_create/definition.rb +1 -0
- data/scenarios/card_hold_create/request.rb +5 -0
- data/scenarios/card_hold_create/ruby.mako +38 -0
- data/scenarios/card_hold_list/definition.rb +1 -0
- data/scenarios/card_hold_list/request.rb +2 -0
- data/scenarios/card_hold_list/ruby.mako +60 -0
- data/scenarios/card_hold_show/definition.rb +1 -0
- data/scenarios/card_hold_show/request.rb +2 -0
- data/scenarios/card_hold_show/ruby.mako +36 -0
- data/scenarios/card_hold_update/definition.rb +1 -0
- data/scenarios/card_hold_update/request.rb +7 -0
- data/scenarios/card_hold_update/ruby.mako +42 -0
- data/scenarios/card_hold_void/definition.rb +1 -0
- data/scenarios/card_hold_void/request.rb +3 -0
- data/scenarios/card_hold_void/ruby.mako +36 -0
- data/scenarios/card_list/definition.rb +1 -1
- data/scenarios/card_list/request.rb +1 -1
- data/scenarios/card_list/ruby.mako +78 -5
- data/scenarios/card_show/definition.rb +1 -1
- data/scenarios/card_show/request.rb +1 -1
- data/scenarios/card_show/ruby.mako +42 -4
- data/scenarios/card_update/definition.rb +1 -1
- data/scenarios/card_update/request.rb +1 -1
- data/scenarios/card_update/ruby.mako +45 -4
- data/scenarios/credit_list/request.rb +1 -3
- data/scenarios/credit_list/ruby.mako +34 -4
- data/scenarios/{credit_bank_account_list → credit_list_bank_account}/definition.rb +0 -0
- data/scenarios/credit_list_bank_account/request.rb +3 -0
- data/scenarios/credit_list_bank_account/ruby.mako +13 -0
- data/scenarios/credit_show/definition.rb +1 -1
- data/scenarios/credit_show/request.rb +1 -3
- data/scenarios/credit_show/ruby.mako +35 -5
- data/scenarios/{credit_create_new_bank_account → credit_update}/definition.rb +0 -0
- data/scenarios/credit_update/request.rb +7 -0
- data/scenarios/credit_update/ruby.mako +48 -0
- data/scenarios/customer_create/request.rb +4 -1
- data/scenarios/customer_create/ruby.mako +60 -3
- data/scenarios/customer_delete/request.rb +1 -1
- data/scenarios/customer_delete/ruby.mako +4 -2
- data/scenarios/customer_list/definition.rb +1 -0
- data/scenarios/customer_list/request.rb +2 -0
- data/scenarios/customer_list/ruby.mako +105 -0
- data/scenarios/customer_show/definition.rb +1 -0
- data/scenarios/customer_show/request.rb +2 -0
- data/scenarios/customer_show/ruby.mako +58 -0
- data/scenarios/customer_update/definition.rb +1 -0
- data/scenarios/customer_update/request.rb +7 -0
- data/scenarios/customer_update/ruby.mako +64 -0
- data/scenarios/debit_list/request.rb +1 -3
- data/scenarios/debit_list/ruby.mako +70 -4
- data/scenarios/debit_show/definition.rb +1 -1
- data/scenarios/debit_show/request.rb +1 -1
- data/scenarios/debit_show/ruby.mako +39 -4
- data/scenarios/debit_update/definition.rb +1 -1
- data/scenarios/debit_update/request.rb +1 -1
- data/scenarios/debit_update/ruby.mako +39 -4
- data/scenarios/event_list/definition.rb +1 -1
- data/scenarios/event_list/request.rb +1 -2
- data/scenarios/event_list/ruby.mako +54 -5
- data/scenarios/event_show/definition.rb +1 -1
- data/scenarios/event_show/request.rb +1 -1
- data/scenarios/event_show/ruby.mako +54 -4
- data/scenarios/helpers.rb +29 -2
- data/scenarios/order_create/definition.rb +1 -0
- data/scenarios/order_create/request.rb +5 -0
- data/scenarios/order_create/ruby.mako +46 -0
- data/scenarios/order_list/definition.rb +1 -0
- data/scenarios/order_list/request.rb +2 -0
- data/scenarios/order_list/ruby.mako +42 -0
- data/scenarios/order_show/definition.rb +1 -0
- data/scenarios/order_show/request.rb +2 -0
- data/scenarios/order_show/ruby.mako +44 -0
- data/scenarios/order_update/definition.rb +1 -0
- data/scenarios/order_update/request.rb +7 -0
- data/scenarios/order_update/ruby.mako +50 -0
- data/scenarios/refund_create/definition.rb +1 -1
- data/scenarios/refund_create/request.rb +2 -1
- data/scenarios/refund_create/ruby.mako +33 -5
- data/scenarios/refund_list/request.rb +1 -3
- data/scenarios/refund_list/ruby.mako +30 -4
- data/scenarios/refund_show/definition.rb +1 -1
- data/scenarios/refund_show/request.rb +1 -1
- data/scenarios/refund_show/ruby.mako +32 -4
- data/scenarios/refund_update/definition.rb +1 -1
- data/scenarios/refund_update/request.rb +1 -1
- data/scenarios/refund_update/ruby.mako +32 -4
- data/scenarios/render_mako.rb +59 -4
- data/scenarios/reversal_create/definition.rb +1 -0
- data/scenarios/reversal_create/request.rb +9 -0
- data/scenarios/reversal_create/ruby.mako +45 -0
- data/scenarios/reversal_list/definition.rb +1 -0
- data/scenarios/reversal_list/request.rb +2 -0
- data/scenarios/reversal_list/ruby.mako +36 -0
- data/scenarios/reversal_show/definition.rb +1 -0
- data/scenarios/reversal_show/request.rb +2 -0
- data/scenarios/reversal_show/ruby.mako +37 -0
- data/scenarios/reversal_update/definition.rb +1 -0
- data/scenarios/reversal_update/request.rb +7 -0
- data/scenarios/reversal_update/ruby.mako +44 -0
- data/spec/balanced/error_spec.rb +7 -7
- data/spec/balanced/pager_spec.rb +10 -10
- data/spec/balanced/resources/api_key_spec.rb +6 -35
- data/spec/balanced/resources/bank_account_spec.rb +123 -218
- data/spec/balanced/resources/callback_spec.rb +12 -13
- data/spec/balanced/resources/card_hold_spec.rb +103 -0
- data/spec/balanced/resources/card_spec.rb +101 -27
- data/spec/balanced/resources/credit_spec.rb +69 -35
- data/spec/balanced/resources/customer_spec.rb +91 -271
- data/spec/balanced/resources/debit_spec.rb +95 -0
- data/spec/balanced/resources/marketplace_spec.rb +17 -170
- data/spec/balanced/resources/order_spec.rb +364 -0
- data/spec/balanced/resources/resource_spec.rb +25 -32
- data/spec/balanced_spec.rb +18 -36
- data/spec/client_spec.rb +7 -7
- data/spec/spec_helper.rb +19 -18
- data/spec/utils_spec.rb +5 -5
- metadata +123 -165
- data/examples/bank_account_debits.rb +0 -57
- data/examples/customers.rb +0 -114
- data/examples/events_and_callbacks.rb +0 -81
- data/examples/examples.rb +0 -162
- data/examples/exception_handling.rb +0 -44
- data/lib/balanced/resources/account.rb +0 -179
- data/lib/balanced/resources/hold.rb +0 -61
- data/lib/balanced/resources/invoice.rb +0 -11
- data/lib/balanced/resources/merchant.rb +0 -21
- data/lib/balanced/resources/transaction.rb +0 -17
- data/scenarios/account_add_card/definition.rb +0 -1
- data/scenarios/account_add_card/request.rb +0 -3
- data/scenarios/account_add_card/ruby.mako +0 -11
- data/scenarios/account_capture_hold/definition.rb +0 -1
- data/scenarios/account_capture_hold/request.rb +0 -3
- data/scenarios/account_capture_hold/ruby.mako +0 -11
- data/scenarios/account_create/definition.rb +0 -1
- data/scenarios/account_create/request.rb +0 -2
- data/scenarios/account_create/ruby.mako +0 -10
- data/scenarios/account_create_buyer/definition.rb +0 -1
- data/scenarios/account_create_buyer/request.rb +0 -5
- data/scenarios/account_create_buyer/ruby.mako +0 -13
- data/scenarios/account_create_debit/definition.rb +0 -1
- data/scenarios/account_create_debit/request.rb +0 -3
- data/scenarios/account_create_debit/ruby.mako +0 -11
- data/scenarios/account_create_hold/definition.rb +0 -1
- data/scenarios/account_create_hold/request.rb +0 -3
- data/scenarios/account_create_hold/ruby.mako +0 -11
- data/scenarios/account_create_merchant/definition.rb +0 -1
- data/scenarios/account_create_merchant/request.rb +0 -3
- data/scenarios/account_create_merchant/ruby.mako +0 -11
- data/scenarios/account_underwrite_business/definition.rb +0 -1
- data/scenarios/account_underwrite_business/request.rb +0 -17
- data/scenarios/account_underwrite_business/ruby.mako +0 -37
- data/scenarios/account_underwrite_person/definition.rb +0 -1
- data/scenarios/account_underwrite_person/request.rb +0 -18
- data/scenarios/account_underwrite_person/ruby.mako +0 -31
- data/scenarios/bank_account_find_and_credit/definition.rb +0 -1
- data/scenarios/bank_account_find_and_credit/request.rb +0 -5
- data/scenarios/bank_account_find_and_credit/ruby.mako +0 -13
- data/scenarios/bank_account_find_and_delete/definition.rb +0 -1
- data/scenarios/bank_account_find_and_delete/request.rb +0 -3
- data/scenarios/bank_account_find_and_delete/ruby.mako +0 -10
- data/scenarios/bank_account_invalid_routing_number/definition.rb +0 -1
- data/scenarios/bank_account_invalid_routing_number/request.rb +0 -11
- data/scenarios/bank_account_invalid_routing_number/ruby.mako +0 -16
- data/scenarios/card_invalidate/definition.rb +0 -1
- data/scenarios/card_invalidate/request.rb +0 -3
- data/scenarios/card_invalidate/ruby.mako +0 -10
- data/scenarios/credit_account_list/definition.rb +0 -1
- data/scenarios/credit_account_list/request.rb +0 -3
- data/scenarios/credit_account_list/ruby.mako +0 -10
- data/scenarios/credit_account_merchant_create/definition.rb +0 -1
- data/scenarios/credit_account_merchant_create/request.rb +0 -5
- data/scenarios/credit_account_merchant_create/ruby.mako +0 -12
- data/scenarios/credit_bank_account_list/request.rb +0 -5
- data/scenarios/credit_bank_account_list/ruby.mako +0 -12
- data/scenarios/credit_create_existing_bank_account/request.rb +0 -5
- data/scenarios/credit_create_existing_bank_account/ruby.mako +0 -12
- data/scenarios/credit_create_new_bank_account/request.rb +0 -10
- data/scenarios/credit_create_new_bank_account/ruby.mako +0 -21
- data/scenarios/credit_customer_list/definition.rb +0 -1
- data/scenarios/credit_customer_list/request.rb +0 -4
- data/scenarios/credit_customer_list/ruby.mako +0 -12
- data/scenarios/credit_failed_state/definition.rb +0 -1
- data/scenarios/credit_failed_state/request.rb +0 -10
- data/scenarios/credit_failed_state/ruby.mako +0 -18
- data/scenarios/credit_paid_state/definition.rb +0 -1
- data/scenarios/credit_paid_state/request.rb +0 -11
- data/scenarios/credit_paid_state/ruby.mako +0 -19
- data/scenarios/credit_pending_state/definition.rb +0 -1
- data/scenarios/credit_pending_state/request.rb +0 -9
- data/scenarios/credit_pending_state/ruby.mako +0 -17
- data/scenarios/customer_add_bank_account/request.rb +0 -3
- data/scenarios/customer_add_bank_account/ruby.mako +0 -11
- data/scenarios/customer_add_card/request.rb +0 -3
- data/scenarios/customer_add_card/ruby.mako +0 -11
- data/scenarios/customer_capture_hold/definition.rb +0 -1
- data/scenarios/customer_capture_hold/request.rb +0 -3
- data/scenarios/customer_capture_hold/ruby.mako +0 -0
- data/scenarios/customer_create_debit/definition.rb +0 -1
- data/scenarios/customer_create_debit/request.rb +0 -3
- data/scenarios/customer_create_debit/ruby.mako +0 -11
- data/scenarios/customer_create_hold/definition.rb +0 -1
- data/scenarios/customer_create_hold/request.rb +0 -3
- data/scenarios/customer_create_hold/ruby.mako +0 -11
- data/scenarios/customer_credit/definition.rb +0 -1
- data/scenarios/customer_credit/request.rb +0 -2
- data/scenarios/customer_credit/ruby.mako +0 -8
- data/scenarios/debit_account_list/definition.rb +0 -1
- data/scenarios/debit_account_list/request.rb +0 -3
- data/scenarios/debit_account_list/ruby.mako +0 -10
- data/scenarios/debit_create/definition.rb +0 -1
- data/scenarios/debit_create/request.rb +0 -5
- data/scenarios/debit_create/ruby.mako +0 -15
- data/scenarios/debit_customer_list/definition.rb +0 -1
- data/scenarios/debit_customer_list/request.rb +0 -4
- data/scenarios/debit_customer_list/ruby.mako +0 -12
- data/scenarios/debit_refund/definition.rb +0 -1
- data/scenarios/debit_refund/request.rb +0 -3
- data/scenarios/debit_refund/ruby.mako +0 -10
- data/scenarios/delete.rb +0 -7
- data/scenarios/event_replay/definition.rb +0 -0
- data/scenarios/event_replay/request.rb +0 -1
- data/scenarios/event_replay/ruby.mako +0 -0
- data/scenarios/execute.rb +0 -27
- data/scenarios/hold_account_list/definition.rb +0 -1
- data/scenarios/hold_account_list/request.rb +0 -3
- data/scenarios/hold_account_list/ruby.mako +0 -10
- data/scenarios/hold_capture/definition.rb +0 -1
- data/scenarios/hold_capture/request.rb +0 -5
- data/scenarios/hold_capture/ruby.mako +0 -15
- data/scenarios/hold_create/definition.rb +0 -1
- data/scenarios/hold_create/request.rb +0 -5
- data/scenarios/hold_create/ruby.mako +0 -14
- data/scenarios/hold_customer_list/definition.rb +0 -1
- data/scenarios/hold_customer_list/request.rb +0 -3
- data/scenarios/hold_customer_list/ruby.mako +0 -11
- data/scenarios/hold_list/definition.rb +0 -1
- data/scenarios/hold_list/request.rb +0 -4
- data/scenarios/hold_list/ruby.mako +0 -11
- data/scenarios/hold_show/definition.rb +0 -1
- data/scenarios/hold_show/request.rb +0 -2
- data/scenarios/hold_show/ruby.mako +0 -10
- data/scenarios/hold_update/definition.rb +0 -1
- data/scenarios/hold_update/request.rb +0 -7
- data/scenarios/hold_update/ruby.mako +0 -16
- data/scenarios/hold_void/definition.rb +0 -1
- data/scenarios/hold_void/request.rb +0 -3
- data/scenarios/hold_void/ruby.mako +0 -10
- data/scenarios/refund_account_list/definition.rb +0 -1
- data/scenarios/refund_account_list/request.rb +0 -3
- data/scenarios/refund_account_list/ruby.mako +0 -10
- data/scenarios/refund_customer_list/definition.rb +0 -1
- data/scenarios/refund_customer_list/request.rb +0 -3
- data/scenarios/refund_customer_list/ruby.mako +0 -11
- data/scenarios/render.rb +0 -32
- data/scenarios/render_one.rb +0 -32
- data/spec/balanced/resources/account_spec.rb +0 -636
- data/spec/balanced/resources/hold_spec.rb +0 -48
- data/spec/balanced/resources/merchant_spec.rb +0 -6
- data/spec/scenarios_spec.rb +0 -39
- data/upload_docs.rb +0 -40
@@ -1,36 +1,35 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::Callback, :vcr do
|
4
4
|
before do
|
5
5
|
api_key = Balanced::ApiKey.new.save
|
6
6
|
Balanced.configure api_key.secret
|
7
|
-
|
8
7
|
@marketplace = Balanced::Marketplace.new.save
|
9
8
|
end
|
10
9
|
|
11
|
-
describe
|
10
|
+
describe 'create', :vcr do
|
12
11
|
before do
|
13
|
-
@callback =
|
14
|
-
:url =>
|
15
|
-
)
|
12
|
+
@callback = Balanced::Callback.new(
|
13
|
+
:url => 'http://www.example.com/balanced_callback'
|
14
|
+
).save
|
16
15
|
end
|
17
16
|
|
18
17
|
context 'check url' do
|
19
|
-
subject { @callback.url}
|
20
|
-
it { should eql
|
18
|
+
subject { @callback.url }
|
19
|
+
it { should eql 'http://www.example.com/balanced_callback' }
|
21
20
|
end
|
22
21
|
|
23
22
|
end
|
24
23
|
|
25
|
-
describe
|
24
|
+
describe 'delete', :vcr do
|
26
25
|
before do
|
27
|
-
@callback =
|
28
|
-
:url =>
|
29
|
-
)
|
26
|
+
@callback = Balanced::Callback.new(
|
27
|
+
:url => 'http://www.example.com/balanced_callback'
|
28
|
+
).save
|
30
29
|
end
|
31
30
|
|
32
31
|
context 'delete' do
|
33
|
-
it
|
32
|
+
it 'should delete without an error' do
|
34
33
|
@callback.destroy
|
35
34
|
end
|
36
35
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Balanced::CardHold, :vcr => true, :skip => true do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
api_key = Balanced::ApiKey.new.save
|
7
|
+
Balanced.configure api_key.secret
|
8
|
+
@marketplace = Balanced::Marketplace.new.save
|
9
|
+
@card = Balanced::Card.new(
|
10
|
+
:number => '5105105105105100',
|
11
|
+
:expiration_month => '12',
|
12
|
+
:expiration_year => '2015'
|
13
|
+
).save
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#create', :vcr do
|
17
|
+
|
18
|
+
subject do
|
19
|
+
@card_hold = Balanced::CardHold.new(
|
20
|
+
:href => @card.holds.href,
|
21
|
+
:amount => 100,
|
22
|
+
:currency => 'USD',
|
23
|
+
:appears_on_statement_as => 'My Market.Place-13',
|
24
|
+
:description => 'I be holding',
|
25
|
+
:meta => {
|
26
|
+
:campaign_id => SecureRandom.hex
|
27
|
+
}
|
28
|
+
).save
|
29
|
+
end
|
30
|
+
|
31
|
+
it { should_not be_nil }
|
32
|
+
its(:href) { should_not be nil }
|
33
|
+
its(:description) { should eq('I be holding') }
|
34
|
+
its(:appears_on_statement_as) { should eq('BAL*My Market.Place-13') }
|
35
|
+
its(:amount) { should == 100 }
|
36
|
+
its(:meta) {
|
37
|
+
should_not be_nil
|
38
|
+
should be_instance_of Hash
|
39
|
+
}
|
40
|
+
its(:currency) { should == 'USD' }
|
41
|
+
its(:expires_at) { should_not be_nil }
|
42
|
+
|
43
|
+
its(:debits) { should be_instance_of Balanced::Pager }
|
44
|
+
its(:debit) { should be_nil }
|
45
|
+
|
46
|
+
context '#card' do
|
47
|
+
its('card.href') { should eql(@card.href) }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#capture', :vcr do
|
53
|
+
before do
|
54
|
+
@card_hold = Balanced::CardHold.new(
|
55
|
+
:href => @card.holds.href,
|
56
|
+
:amount => 100,
|
57
|
+
:currency => 'USD',
|
58
|
+
:appears_on_statement_as => 'My Market.Place-13',
|
59
|
+
:description => 'I be holding',
|
60
|
+
:meta => {
|
61
|
+
:campaign_id => SecureRandom.hex
|
62
|
+
}
|
63
|
+
).save
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with no arguments - should just create a debit' do
|
67
|
+
subject { @card_hold.capture }
|
68
|
+
it { should be_instance_of Balanced::Debit }
|
69
|
+
its(:amount) { should eql @card_hold.amount }
|
70
|
+
its(:appears_on_statement_as) { should eql @card_hold.appears_on_statement_as }
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should update the card hold's debit" do
|
74
|
+
@card_hold.debit.should be_nil
|
75
|
+
debit = @card_hold.capture
|
76
|
+
@card_hold.debit.should_not be_nil
|
77
|
+
@card_hold.debit.href.should eql(debit.href)
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should fail when captured twice' do
|
81
|
+
@card_hold.debit.should be_nil
|
82
|
+
@card_hold.capture
|
83
|
+
lambda { @card_hold.capture }.should raise_error(Balanced::Conflict)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#destroy', :vcr do
|
88
|
+
before(:all) do
|
89
|
+
@hold = @card.hold(:amount => 100)
|
90
|
+
@hold_href = @hold.href
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should implicitly void the hold since it no longer exists' do
|
94
|
+
@hold.destroy
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should return a 404 when trying to access it again' do
|
98
|
+
lambda { Balanced::CardHold.find(@hold_href) }.should raise_error(Balanced::NotFound)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -1,36 +1,110 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Balanced::Card,
|
4
|
-
it 'raises an exception with an unassociated card' do
|
5
|
-
card = Balanced::Card.new
|
6
|
-
expect {
|
7
|
-
card.debit
|
8
|
-
}.to raise_error(Balanced::UnassociatedCardError)
|
9
|
-
end
|
10
|
-
end
|
3
|
+
describe Balanced::Card, :vcr do
|
11
4
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
before do
|
6
|
+
api_key = Balanced::ApiKey.new.save
|
7
|
+
Balanced.configure api_key.secret
|
8
|
+
@marketplace = Balanced::Marketplace.new.save
|
9
|
+
@card = Balanced::Card.new(
|
10
|
+
:number => '5105105105105100',
|
11
|
+
:expiration_month => '12',
|
12
|
+
:expiration_year => '2020',
|
13
|
+
:cvv => '123'
|
14
|
+
).save
|
18
15
|
end
|
19
|
-
end
|
20
16
|
|
21
|
-
describe
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
describe 'card', :vcr do
|
18
|
+
it 'should be a Balanced::Card' do
|
19
|
+
@card.should be_instance_of Balanced::Card
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'attributes', :vcr do
|
23
|
+
subject { @card }
|
24
|
+
its(:href) { should match "/cards/#{@card.id}" }
|
25
|
+
its(:number) { should end_with '5100' }
|
26
|
+
its(:expiration_month) { should eql 12 }
|
27
|
+
its(:expiration_year) { should eql 2020 }
|
28
|
+
its(:cvv) { should eql 'xxx' }
|
29
|
+
its(:cvv_match) { should eql 'yes' }
|
30
|
+
its(:cvv_result) { should eql 'Match' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'creating a one-time debit', :vcr => {:record => :new_episodes} do
|
34
|
+
subject do
|
35
|
+
@card.debit(
|
36
|
+
:amount => 100,
|
37
|
+
:appears_on_statement_as => 'A lolipop',
|
38
|
+
:description => 'My first debit!'
|
39
|
+
)
|
40
|
+
end
|
41
|
+
it { should_not be_nil }
|
42
|
+
it { should be_instance_of Balanced::Debit }
|
43
|
+
|
44
|
+
its(:href) { should_not be_nil }
|
45
|
+
its(:amount) { should eql 100 }
|
46
|
+
its(:appears_on_statement_as) { should eql 'BAL*A lolipop' }
|
47
|
+
its(:description) { should eql 'My first debit!' }
|
48
|
+
its(:status) { should eql 'succeeded' }
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'creating a one-time hold', :vcr => true, :skip => true do
|
52
|
+
subject do
|
53
|
+
@card.hold(
|
54
|
+
:amount => 100,
|
55
|
+
:appears_on_statement_as => 'HOLD.UP',
|
56
|
+
:description => 'HeldForEver'
|
57
|
+
)
|
58
|
+
end
|
59
|
+
it { should_not be_nil }
|
60
|
+
it { should be_instance_of Balanced::CardHold }
|
61
|
+
|
62
|
+
its(:href) { should_not be_nil }
|
63
|
+
its(:amount) { should eql 100 }
|
64
|
+
its(:description) { should eql 'HeldForEver' }
|
65
|
+
its(:appears_on_statement_as) { should eql 'BAL*HOLD.UP' }
|
66
|
+
end
|
29
67
|
|
30
|
-
#
|
31
|
-
|
68
|
+
describe '#debits', :vcr do
|
69
|
+
subject do
|
70
|
+
@card.debits
|
71
|
+
end
|
72
|
+
its(:href) { should eq("/cards/#{@card.id}/debits") }
|
73
|
+
it 'should be a page' do
|
74
|
+
should be_instance_of Balanced::Pager
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#holds', :vcr => true, :skip => true do
|
79
|
+
subject do
|
80
|
+
@card.holds
|
81
|
+
end
|
82
|
+
|
83
|
+
its(:href) { should eq("/cards/#{@card.id}/card_holds") }
|
84
|
+
|
85
|
+
it 'should be a page' do
|
86
|
+
should be_instance_of Balanced::Pager
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#customer', :vcr do
|
91
|
+
|
92
|
+
it 'should default to nil' do
|
93
|
+
@card.customer.should be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'after associating to a customer' do
|
97
|
+
before do
|
98
|
+
@customer = Balanced::Customer.new.save
|
99
|
+
@card.associate_to_customer(@customer)
|
100
|
+
@card.reload
|
101
|
+
end
|
102
|
+
subject { @card }
|
103
|
+
its(:customer) { should_not be_nil }
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
32
107
|
|
33
|
-
card = Balanced::Card.find(card.uri)
|
34
|
-
card.debit(:amount => 10000).should be_instance_of Balanced::Debit
|
35
108
|
end
|
109
|
+
|
36
110
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::Credit, :vcr do
|
4
4
|
before do
|
@@ -6,30 +6,26 @@ describe Balanced::Credit, :vcr do
|
|
6
6
|
Balanced.configure api_key.secret
|
7
7
|
@marketplace = Balanced::Marketplace.new.save
|
8
8
|
card = Balanced::Card.new(
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
:number => '5105105105105100',
|
10
|
+
:expiration_month => '12',
|
11
|
+
:expiration_year => '2015'
|
12
12
|
).save
|
13
13
|
|
14
14
|
# An initial balance for the marketplace
|
15
|
-
|
16
|
-
:email_address => 'buyer@example.org',
|
17
|
-
:card_uri => card.uri
|
18
|
-
)
|
19
|
-
@buyer.debit :amount => 10000000
|
15
|
+
card.debit(:amount => 1000000)
|
20
16
|
end
|
21
17
|
|
22
|
-
describe
|
18
|
+
describe '#create', :vcr do
|
23
19
|
before do
|
24
20
|
@credit = Balanced::Credit.new(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
21
|
+
:amount => 5000,
|
22
|
+
:description => 'A sweet ride',
|
23
|
+
:destination => {
|
24
|
+
:routing_number => '321174851',
|
25
|
+
:account_number => '0987654321',
|
26
|
+
:name => 'Timmy T. McTimmerson',
|
27
|
+
:type => 'checking'
|
28
|
+
}
|
33
29
|
).save
|
34
30
|
end
|
35
31
|
|
@@ -38,37 +34,75 @@ describe Balanced::Credit, :vcr do
|
|
38
34
|
it { should == 5000 }
|
39
35
|
end
|
40
36
|
|
41
|
-
describe '
|
42
|
-
subject { @credit.
|
37
|
+
describe 'customer', :vcr do
|
38
|
+
subject { @credit.customer }
|
43
39
|
it { should be_nil }
|
44
40
|
end
|
45
41
|
|
46
|
-
describe 'bank_account', :vcr do
|
47
|
-
subject { @credit.bank_account }
|
48
|
-
its([:account_number]) { should end_with '4321' }
|
49
|
-
end
|
50
42
|
end
|
51
43
|
|
52
|
-
describe
|
44
|
+
describe '#reverse', :vcr do
|
53
45
|
before do
|
54
46
|
@credit = Balanced::Credit.new(
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
47
|
+
:amount => 5000,
|
48
|
+
:description => 'A sweet ride',
|
49
|
+
:destination => {
|
50
|
+
:routing_number => '321174851',
|
51
|
+
:account_number => '0987654321',
|
52
|
+
:name => 'Timmy T. McTimmerson',
|
53
|
+
:type => 'checking'
|
54
|
+
}
|
63
55
|
).save
|
64
|
-
@
|
56
|
+
@reversal = @credit.reverse
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#amount', :vcr do
|
60
|
+
subject { @reversal.amount }
|
61
|
+
it { should == 5000 }
|
62
|
+
end
|
65
63
|
|
64
|
+
describe '#type', :vcr do
|
65
|
+
subject { @reversal }
|
66
|
+
it { should be_instance_of Balanced::Reversal }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'credit with underwritten customer' do
|
71
|
+
before do
|
72
|
+
@customer = Balanced::Customer.new(
|
73
|
+
:name => 'Henry Ford',
|
74
|
+
:dob_month => 7,
|
75
|
+
:dob_year => 1963,
|
76
|
+
:address => {
|
77
|
+
:postal_code => '48120'
|
78
|
+
}
|
79
|
+
).save
|
80
|
+
@bank_account = Balanced::BankAccount.new(
|
81
|
+
:routing_number => '321174851',
|
82
|
+
:account_number => '9900000003',
|
83
|
+
:name => 'Larry Bird',
|
84
|
+
:type => 'checking'
|
85
|
+
).save
|
86
|
+
@bank_account.associate_to_customer(@customer)
|
87
|
+
@credit = @bank_account.credit(
|
88
|
+
:amount => 5000,
|
89
|
+
:description => 'A sweet ride'
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'merchant_status', :vcr do
|
94
|
+
subject { @customer.merchant_status }
|
95
|
+
it { should eq 'underwritten' }
|
66
96
|
end
|
67
97
|
|
68
98
|
describe 'amount', :vcr do
|
69
|
-
subject { @
|
99
|
+
subject { @credit.amount }
|
70
100
|
it { should == 5000 }
|
71
101
|
end
|
72
102
|
|
103
|
+
describe 'status' do
|
104
|
+
subject { @credit.status }
|
105
|
+
it { should eq 'succeeded' }
|
106
|
+
end
|
73
107
|
end
|
74
108
|
end
|
@@ -1,313 +1,133 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::Customer, :vcr do
|
4
|
+
|
4
5
|
before do
|
5
|
-
api_key = Balanced::ApiKey.new.save
|
6
|
-
Balanced.configure api_key.secret
|
6
|
+
@api_key = Balanced::ApiKey.new.save
|
7
|
+
Balanced.configure @api_key.secret
|
7
8
|
@marketplace = Balanced::Marketplace.new.save
|
9
|
+
@customer = Balanced::Customer.new(
|
10
|
+
:name => 'Bill',
|
11
|
+
:email => 'bill@bill.com',
|
12
|
+
:business_name => 'Bill Inc.',
|
13
|
+
:ssn_last4 => '1234',
|
14
|
+
:address => {
|
15
|
+
:line1 => '1234 1st Street',
|
16
|
+
:city => 'San Francisco',
|
17
|
+
:state => 'CA'
|
18
|
+
}
|
19
|
+
).save
|
8
20
|
end
|
9
21
|
|
10
|
-
describe
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
22
|
+
describe 'attributes', :vcr do
|
23
|
+
subject { @customer }
|
24
|
+
its(:href) { should match "/customers/#{@customer.id}" }
|
25
|
+
its(:name) { should eq 'Bill' }
|
26
|
+
its(:email) { should eq 'bill@bill.com' }
|
27
|
+
its(:business_name) { should eq 'Bill Inc.' }
|
25
28
|
end
|
26
29
|
|
27
|
-
describe
|
28
|
-
|
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
|
30
|
+
describe '#add_source', :vcr do
|
31
|
+
before do
|
55
32
|
@card = Balanced::Card.new(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
it "should add a card to a customer" do
|
63
|
-
@customer.cards.size.should eq(1)
|
64
|
-
end
|
33
|
+
:number => '4111111111111111',
|
34
|
+
:expiration_month => '12',
|
35
|
+
:expiration_year => '2015'
|
36
|
+
).save
|
37
|
+
@card.associate_to_customer(@customer)
|
65
38
|
end
|
66
39
|
|
67
|
-
|
68
|
-
|
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
|
40
|
+
it 'assumes the card is associated', :vcr do
|
41
|
+
@customer.cards.total.should eql(1)
|
85
42
|
end
|
86
43
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
44
|
+
it 'should make the card a source', :vcr do
|
45
|
+
@customer.add_source(@card)
|
46
|
+
@customer.source.should be_instance_of Balanced::Card
|
47
|
+
@customer.source.href.should eql(@card.href)
|
105
48
|
end
|
106
49
|
|
107
|
-
|
108
|
-
before do
|
109
|
-
@card_2 = @marketplace.create_card(
|
110
|
-
:card_number => "4111111111111111",
|
111
|
-
:expiration_month => "12",
|
112
|
-
:expiration_year => "2015"
|
113
|
-
).save
|
114
|
-
@card_2.unstore
|
115
|
-
end
|
116
|
-
it "Should throw 404 on deleted card" do
|
117
|
-
expect{
|
118
|
-
Balanced::Card.find(@card_2.uri)
|
119
|
-
}.to raise_error
|
120
|
-
end
|
121
|
-
end
|
50
|
+
end
|
122
51
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
@bank_account_2.unstore
|
132
|
-
end
|
133
|
-
it "Should throw 404 on deleted card" do
|
134
|
-
expect {
|
135
|
-
Balanced::BankAccount.find(@bank_account_2.uri)
|
136
|
-
}.to raise_error
|
137
|
-
end
|
52
|
+
describe '#add_destination', :vcr do
|
53
|
+
before do
|
54
|
+
@bank_account = Balanced::BankAccount.new(
|
55
|
+
:account_number => '1234567980',
|
56
|
+
:routing_number => '111000025',
|
57
|
+
:name => 'Jack Q Merchant'
|
58
|
+
).save
|
59
|
+
@bank_account.associate_to_customer(@customer)
|
138
60
|
end
|
139
61
|
|
140
|
-
|
141
|
-
|
142
|
-
@customer = @marketplace.create_customer
|
143
|
-
@bank_account = @marketplace.create_bank_account(
|
144
|
-
:account_number => "1234567980",
|
145
|
-
:bank_code => "321174811",
|
146
|
-
:name => "Jack Q Merchant"
|
147
|
-
)
|
148
|
-
@customer.add_bank_account(@bank_account)
|
149
|
-
@customer_bank_account_id = @customer.bank_accounts.first.id
|
150
|
-
@bank_account_id = @bank_account.id
|
151
|
-
end
|
152
|
-
it "should add a bank account to a customer" do
|
153
|
-
@customer.bank_accounts.size.should eq(1)
|
154
|
-
end
|
155
|
-
it "bank account added should be the same bank account" do
|
156
|
-
@customer_bank_account_id = @bank_account_id
|
157
|
-
end
|
62
|
+
it 'assumes the bank account is associated', :vcr do
|
63
|
+
@customer.bank_accounts.total.should eql(1)
|
158
64
|
end
|
159
65
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
:account_number => "1234567980",
|
165
|
-
:bank_code => "321174811",
|
166
|
-
:name => "Jack Q Merchant"
|
167
|
-
)
|
168
|
-
@customer.add_bank_account(@bank_account.uri)
|
169
|
-
@customer_bank_account_id = @customer.bank_accounts.first.id
|
170
|
-
@bank_account_id = @bank_account.id
|
171
|
-
end
|
172
|
-
it "should add a bank account to a customer" do
|
173
|
-
@customer.bank_accounts.size.should eq(1)
|
174
|
-
end
|
175
|
-
it "bank account added should be the same bank account" do
|
176
|
-
@customer_bank_account_id = @bank_account_id
|
177
|
-
end
|
66
|
+
it 'should make the bank account a destination', :vcr do
|
67
|
+
@customer.add_destination(@bank_account)
|
68
|
+
@customer.destination.should be_instance_of Balanced::BankAccount
|
69
|
+
@customer.destination.href.should eql(@bank_account.href)
|
178
70
|
end
|
179
71
|
|
180
|
-
|
181
|
-
before do
|
182
|
-
api_key = Balanced::ApiKey.new.save
|
183
|
-
Balanced.configure api_key.secret
|
184
|
-
@marketplace = Balanced::Marketplace.new.save
|
185
|
-
customer = @marketplace.create_customer(
|
186
|
-
:name => "Bill",
|
187
|
-
:email => "bill@bill.com",
|
188
|
-
:business_name => "Bill Inc.",
|
189
|
-
:ssn_last4 => "1234",
|
190
|
-
:address => {
|
191
|
-
:line1 => "1234 1st Street",
|
192
|
-
:city => "San Francisco",
|
193
|
-
:state => "CA"
|
194
|
-
}
|
195
|
-
).save
|
196
|
-
end
|
72
|
+
end
|
197
73
|
|
198
|
-
|
199
|
-
it "should return customer object" do
|
200
|
-
Balanced::Customer.find_by_email("bill@bill.com").should be_instance_of Balanced::Customer
|
201
|
-
end
|
202
|
-
end
|
74
|
+
describe '#find_by_email', :vcr do
|
203
75
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
76
|
+
context 'email address is in system', :vcr do
|
77
|
+
it 'should return customer object' do
|
78
|
+
bill = Balanced::Customer.find_by_email('bill@bill.com')
|
79
|
+
bill.should be_instance_of Balanced::Customer
|
208
80
|
end
|
209
81
|
end
|
210
82
|
|
211
|
-
|
212
|
-
|
213
|
-
@
|
214
|
-
@card = @marketplace.create_card(
|
215
|
-
:card_number => "4111111111111111",
|
216
|
-
:expiration_month => "12",
|
217
|
-
:expiration_year => "2015"
|
218
|
-
).save
|
219
|
-
@customer.add_card(@card)
|
220
|
-
@customer.debit :amount => 1000
|
221
|
-
end
|
222
|
-
context "customer debit should be added" do
|
223
|
-
subject {@customer.debits.first}
|
224
|
-
its(:amount) { should eq 1000}
|
83
|
+
context 'email address does not exist', :vcr do
|
84
|
+
it 'should return nil' do
|
85
|
+
Balanced::Customer.find_by_email('foo@bar.com').should be_nil
|
225
86
|
end
|
226
87
|
end
|
88
|
+
end
|
227
89
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
:
|
233
|
-
:
|
234
|
-
|
235
|
-
)
|
236
|
-
@card = Balanced::Card.new(
|
237
|
-
:card_number => "4111111111111111",
|
238
|
-
:expiration_month => "12",
|
239
|
-
:expiration_year => "2015"
|
240
|
-
).save
|
241
|
-
@customer.add_card(@card)
|
242
|
-
@customer.add_bank_account(@bank_account)
|
243
|
-
@customer.debit :amount => 1250
|
244
|
-
end
|
245
|
-
|
246
|
-
context "args passed by name via options hash" do
|
247
|
-
subject {
|
248
|
-
@customer.credit(
|
249
|
-
:amount => 1250,
|
250
|
-
:description => "description",
|
251
|
-
:meta => {}
|
252
|
-
)
|
253
|
-
}
|
254
|
-
|
255
|
-
its(:amount) { should == 1250 }
|
256
|
-
its(:meta) { should == {} }
|
257
|
-
its(:description) { should == "description" }
|
258
|
-
end
|
90
|
+
describe 'update' do
|
91
|
+
before do
|
92
|
+
@customer = Balanced::Customer.new(
|
93
|
+
:name => 'Bill',
|
94
|
+
:email => 'bill@bill.com',
|
95
|
+
:business_name => 'Bill Inc.'
|
96
|
+
).save
|
259
97
|
end
|
260
98
|
|
261
|
-
|
262
|
-
|
263
|
-
@customer = @marketplace.create_customer
|
264
|
-
@card = @marketplace.create_card(
|
265
|
-
:card_number => "4111111111111111",
|
266
|
-
:expiration_month => "12",
|
267
|
-
:expiration_year => "2015"
|
268
|
-
).save
|
269
|
-
@customer.add_card(@card)
|
270
|
-
end
|
271
|
-
it "should display the most recently added valid card" do
|
272
|
-
@customer.active_card.should_not be_nil
|
273
|
-
end
|
99
|
+
subject do
|
100
|
+
@customer
|
274
101
|
end
|
275
102
|
|
276
|
-
|
277
|
-
|
278
|
-
@customer = @marketplace.create_customer
|
279
|
-
@bank_account = @marketplace.create_bank_account(
|
280
|
-
:account_number => "1234567980",
|
281
|
-
:bank_code => "321174811",
|
282
|
-
:name => "Jack Q Merchant"
|
283
|
-
)
|
284
|
-
@customer.add_bank_account(@bank_account)
|
285
|
-
end
|
286
|
-
it "should display the most recently added valid card" do
|
287
|
-
@customer.active_bank_account.should_not be_nil
|
288
|
-
end
|
289
|
-
end
|
103
|
+
its(:name) { should eq 'Bill' }
|
104
|
+
its(:merchant_status) { should eq 'no-match' }
|
290
105
|
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
:email => "balanced-ruby-issue-110@example.com"
|
295
|
-
)
|
296
|
-
end
|
106
|
+
it 'update name' do
|
107
|
+
@customer.name = 'William'
|
108
|
+
@customer.save
|
297
109
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
expect {
|
303
|
-
Balanced::Customer.find(
|
304
|
-
:first,
|
305
|
-
:email => "balanced-ruby-issue-110@example.com")
|
306
|
-
}.to raise_error Balanced::Unauthorized
|
307
|
-
Balanced.configure(key)
|
308
|
-
end
|
110
|
+
# Fetch the customer again
|
111
|
+
@customer.reload
|
112
|
+
@customer.name.should eq 'William'
|
113
|
+
end
|
309
114
|
|
115
|
+
it 'can be underwritten' do
|
116
|
+
@customer.name = 'Henry Ford'
|
117
|
+
@customer.dob_month = 7
|
118
|
+
@customer.dob_year = 1963
|
119
|
+
@customer.business_name = nil
|
120
|
+
@customer.address['postal_code'] = 48120
|
121
|
+
@customer.save
|
122
|
+
|
123
|
+
@customer.name.should eq 'Henry Ford'
|
124
|
+
@customer.dob_month.should eql 7
|
125
|
+
@customer.dob_year.should eql 1963
|
126
|
+
@customer.business_name.should be_nil
|
127
|
+
@customer.address['postal_code'].should eql '48120'
|
128
|
+
@customer.merchant_status.should eq 'underwritten'
|
310
129
|
end
|
130
|
+
|
311
131
|
end
|
312
132
|
|
313
133
|
end
|