balanced 1.0.1 → 1.0.2

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/CHANGELOG.md +5 -0
  4. data/lib/balanced/resources/credit.rb +2 -7
  5. data/lib/balanced/resources/debit.rb +2 -7
  6. data/lib/balanced/resources/order.rb +10 -9
  7. data/lib/balanced/version.rb +1 -1
  8. data/scenarios/api_key_create/ruby.mako +6 -6
  9. data/scenarios/api_key_delete/ruby.mako +2 -2
  10. data/scenarios/api_key_list/ruby.mako +10 -10
  11. data/scenarios/api_key_show/ruby.mako +6 -6
  12. data/scenarios/bank_account_associate_to_customer/definition.rb +1 -1
  13. data/scenarios/bank_account_associate_to_customer/request.rb +2 -2
  14. data/scenarios/bank_account_associate_to_customer/ruby.mako +15 -15
  15. data/scenarios/bank_account_create/ruby.mako +11 -11
  16. data/scenarios/bank_account_credit/ruby.mako +15 -15
  17. data/scenarios/bank_account_debit/ruby.mako +15 -15
  18. data/scenarios/bank_account_delete/ruby.mako +2 -2
  19. data/scenarios/bank_account_list/ruby.mako +22 -22
  20. data/scenarios/bank_account_show/ruby.mako +12 -12
  21. data/scenarios/bank_account_update/ruby.mako +12 -12
  22. data/scenarios/bank_account_verification_create/ruby.mako +9 -9
  23. data/scenarios/bank_account_verification_show/ruby.mako +9 -9
  24. data/scenarios/bank_account_verification_update/ruby.mako +9 -9
  25. data/scenarios/callback_create/ruby.mako +4 -4
  26. data/scenarios/callback_delete/ruby.mako +2 -2
  27. data/scenarios/callback_list/ruby.mako +4 -4
  28. data/scenarios/callback_show/ruby.mako +5 -5
  29. data/scenarios/card_associate_to_customer/definition.rb +1 -1
  30. data/scenarios/card_associate_to_customer/request.rb +1 -1
  31. data/scenarios/card_associate_to_customer/ruby.mako +13 -14
  32. data/scenarios/card_create/ruby.mako +9 -9
  33. data/scenarios/card_create_dispute/definition.rb +1 -0
  34. data/scenarios/card_create_dispute/request.rb +4 -0
  35. data/scenarios/card_create_dispute/ruby.mako +53 -0
  36. data/scenarios/card_debit/ruby.mako +16 -16
  37. data/scenarios/card_debit_dispute/definition.rb +1 -0
  38. data/scenarios/card_debit_dispute/request.rb +5 -0
  39. data/scenarios/card_debit_dispute/ruby.mako +49 -0
  40. data/scenarios/card_delete/ruby.mako +2 -2
  41. data/scenarios/card_hold_capture/ruby.mako +16 -16
  42. data/scenarios/card_hold_create/ruby.mako +14 -14
  43. data/scenarios/card_hold_list/ruby.mako +25 -25
  44. data/scenarios/card_hold_show/ruby.mako +14 -14
  45. data/scenarios/card_hold_update/ruby.mako +14 -14
  46. data/scenarios/card_hold_void/definition.rb +1 -1
  47. data/scenarios/card_hold_void/request.rb +1 -1
  48. data/scenarios/card_hold_void/ruby.mako +17 -17
  49. data/scenarios/card_list/ruby.mako +18 -18
  50. data/scenarios/card_show/ruby.mako +10 -10
  51. data/scenarios/card_update/ruby.mako +10 -10
  52. data/scenarios/credit_list/ruby.mako +14 -14
  53. data/scenarios/credit_list_bank_account/ruby.mako +2 -2
  54. data/scenarios/credit_show/ruby.mako +15 -15
  55. data/scenarios/credit_update/ruby.mako +15 -15
  56. data/scenarios/customer_create/ruby.mako +18 -18
  57. data/scenarios/customer_delete/ruby.mako +1 -1
  58. data/scenarios/customer_list/ruby.mako +35 -35
  59. data/scenarios/customer_show/ruby.mako +19 -19
  60. data/scenarios/customer_update/ruby.mako +19 -19
  61. data/scenarios/debit_dispute_show/definition.rb +1 -0
  62. data/scenarios/debit_dispute_show/request.rb +3 -0
  63. data/scenarios/debit_dispute_show/ruby.mako +31 -0
  64. data/scenarios/debit_list/ruby.mako +29 -29
  65. data/scenarios/debit_show/ruby.mako +16 -16
  66. data/scenarios/debit_update/ruby.mako +16 -16
  67. data/scenarios/dispute_list/definition.rb +1 -0
  68. data/scenarios/dispute_list/request.rb +2 -0
  69. data/scenarios/dispute_list/ruby.mako +29 -0
  70. data/scenarios/dispute_show/definition.rb +1 -0
  71. data/scenarios/dispute_show/request.rb +2 -0
  72. data/scenarios/dispute_show/ruby.mako +31 -0
  73. data/scenarios/event_list/ruby.mako +55 -55
  74. data/scenarios/event_show/ruby.mako +35 -40
  75. data/scenarios/order_create/ruby.mako +14 -14
  76. data/scenarios/order_list/ruby.mako +13 -13
  77. data/scenarios/order_show/ruby.mako +14 -14
  78. data/scenarios/order_update/ruby.mako +14 -14
  79. data/scenarios/refund_create/ruby.mako +13 -13
  80. data/scenarios/refund_list/ruby.mako +12 -12
  81. data/scenarios/refund_show/ruby.mako +13 -13
  82. data/scenarios/refund_update/ruby.mako +13 -13
  83. data/scenarios/render_mako.rb +15 -3
  84. data/scenarios/reversal_create/ruby.mako +12 -12
  85. data/scenarios/reversal_list/ruby.mako +11 -11
  86. data/scenarios/reversal_show/ruby.mako +12 -12
  87. data/scenarios/reversal_update/ruby.mako +12 -12
  88. data/spec/balanced/resources/credit_spec.rb +26 -5
  89. data/spec/balanced/resources/debit_spec.rb +7 -2
  90. data/spec/balanced/resources/order_spec.rb +25 -3
  91. metadata +17 -3
  92. data/scenario.cache +0 -619
@@ -3,9 +3,9 @@ Balanced::Refund.save
3
3
 
4
4
  % elif mode == 'request':
5
5
  require 'balanced'
6
- Balanced.configure('ak-test-2ADpvITfpgBn8uBzEGsQ2bIgWaftUWiul')
6
+ Balanced.configure('ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV')
7
7
 
8
- refund = Balanced::Refund.fetch('/refunds/RF6HsnqferSuES9VZEWrthG2')
8
+ refund = Balanced::Refund.fetch('/refunds/RF4VbbS5LdgSxlECITkHg0Zf')
9
9
  refund.description = 'update this description'
10
10
  refund.meta = {
11
11
  'refund.reason' => 'user not happy with product',
@@ -15,31 +15,31 @@ refund.meta = {
15
15
  refund.save
16
16
 
17
17
  % elif mode == 'response':
18
- #<Balanced::Refund:0x007fa4e4a31b10
18
+ #<Balanced::Refund:0x007fa93b73c148
19
19
  @attributes=
20
20
  {"amount"=>3000,
21
- "created_at"=>"2014-03-06T19:23:46.176138Z",
21
+ "created_at"=>"2014-04-25T20:10:22.593252Z",
22
22
  "currency"=>"USD",
23
23
  "description"=>"update this description",
24
- "href"=>"/refunds/RF6HsnqferSuES9VZEWrthG2",
25
- "id"=>"RF6HsnqferSuES9VZEWrthG2",
24
+ "href"=>"/refunds/RF4VbbS5LdgSxlECITkHg0Zf",
25
+ "id"=>"RF4VbbS5LdgSxlECITkHg0Zf",
26
26
  "links"=>
27
- {"debit"=>"WD6BKYhbRzlRhfKSE1DcpqS5", "dispute"=>nil, "order"=>nil},
27
+ {"debit"=>"WD4SOTNKiZbBFrmMk6mfszIl", "dispute"=>nil, "order"=>nil},
28
28
  "meta"=>
29
29
  {"refund.reason"=>"user not happy with product",
30
30
  "user.notes"=>"very polite on the phone",
31
31
  "user.refund.count"=>"3"},
32
32
  "status"=>"succeeded",
33
- "transaction_number"=>"RF348-549-7723",
34
- "updated_at"=>"2014-03-06T19:23:53.123358Z"},
33
+ "transaction_number"=>"RF854-846-2859",
34
+ "updated_at"=>"2014-04-25T20:18:50.969971Z"},
35
35
  @hyperlinks=
36
36
  {"debit"=>
37
- #<Proc:0x007fa4e4a2af90/lib/balanced/resources/resource.rb:60 (lambda)>,
37
+ #<Proc:0x007fa93b735cf8/lib/balanced/resources/resource.rb:60 (lambda)>,
38
38
  "dispute"=>
39
- #<Proc:0x007fa4e4a2b620/lib/balanced/utils.rb:6 (lambda)>,
39
+ #<Proc:0x007fa93b734ee8/lib/balanced/utils.rb:6 (lambda)>,
40
40
  "events"=>
41
- #<Proc:0x007fa4e4a22bb0/lib/balanced/utils.rb:6 (lambda)>,
41
+ #<Proc:0x007fa93b72ebd8/lib/balanced/utils.rb:6 (lambda)>,
42
42
  "order"=>
43
- #<Proc:0x007fa4e4a22ca0/lib/balanced/utils.rb:6 (lambda)>}>
43
+ #<Proc:0x007fa93b72e200/lib/balanced/utils.rb:6 (lambda)>}>
44
44
 
45
45
  % endif
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'erb'
3
3
  require 'json'
4
- #require 'ruby-debug'
5
4
  require './scenarios/helpers'
6
5
  require './lib/balanced'
7
6
  require 'pp'
8
- require 'json'
7
+ require 'open-uri'
8
+
9
+ SCENARIO_CACHE_URL = 'https://raw.githubusercontent.com/balanced/balanced-docs/master/scenario.cache'
9
10
 
10
11
  class BalancedResourceObject
11
12
  include Balanced::Resource
@@ -45,6 +46,17 @@ def tidy_response(response)
45
46
  return response.gsub(/@\S(.*?)\Sbalanced-ruby/, '')
46
47
  end
47
48
 
49
+ def fetch_scenario_cache
50
+ File.delete 'scenario.cache' if File.exist? 'scenario.cache'
51
+ open('scenario.cache', 'wb') do |f|
52
+ f << open(SCENARIO_CACHE_URL).read
53
+ end
54
+ end
55
+
56
+ #fetch_scenario_cache
57
+
58
+ raise RuntimeError, "scenario.cache not present" if ! File.exists? 'scenario.cache'
59
+
48
60
  parsed_data = JSON.parse(File.read('scenario.cache'))
49
61
 
50
62
  Dir.chdir("./scenarios")
@@ -93,4 +105,4 @@ subdir_list.each do |scenario|
93
105
  puts e.backtrace
94
106
  puts "Error rendering #{scenario}'s mako"
95
107
  end
96
- end
108
+ end
@@ -2,9 +2,9 @@
2
2
  Balanced::Credit.reverse
3
3
  % elif mode == 'request':
4
4
  require 'balanced'
5
- Balanced.configure('ak-test-2ADpvITfpgBn8uBzEGsQ2bIgWaftUWiul')
5
+ Balanced.configure('ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV')
6
6
 
7
- reversal = Balanced::Credit.fetch('/credits/CR6NpuEtezCdLTYngDrSEODv')
7
+ reversal = Balanced::Credit.fetch('/credits/CR6nBcaGvGc4dtflEB1bjKBP')
8
8
  credit.reverse(
9
9
  :amount => 3000,
10
10
  :description => 'Reversal for Order #1111',
@@ -16,30 +16,30 @@ credit.reverse(
16
16
  )
17
17
 
18
18
  % elif mode == 'response':
19
- #<Balanced::Reversal:0x007fa4e3276bd8
19
+ #<Balanced::Reversal:0x007fa93b70ee00
20
20
  @attributes=
21
21
  {"amount"=>3000,
22
- "created_at"=>"2014-03-06T19:23:55.596399Z",
22
+ "created_at"=>"2014-04-25T20:18:55.008280Z",
23
23
  "currency"=>"USD",
24
24
  "description"=>"Reversal for Order #1111",
25
25
  "failure_reason"=>nil,
26
26
  "failure_reason_code"=>nil,
27
- "href"=>"/reversals/RV6OCxJ1UhkG84is6H9PHjkZ",
28
- "id"=>"RV6OCxJ1UhkG84is6H9PHjkZ",
29
- "links"=>{"credit"=>"CR6NpuEtezCdLTYngDrSEODv", "order"=>nil},
27
+ "href"=>"/reversals/RV6qrEOTouLeIJuPu4s73Ra1",
28
+ "id"=>"RV6qrEOTouLeIJuPu4s73Ra1",
29
+ "links"=>{"credit"=>"CR6nBcaGvGc4dtflEB1bjKBP", "order"=>nil},
30
30
  "meta"=>
31
31
  {"fulfillment.item.condition"=>"OK",
32
32
  "merchant.feedback"=>"positive",
33
33
  "user.refund_reason"=>"not happy with product"},
34
34
  "status"=>"succeeded",
35
- "transaction_number"=>"RV542-861-3670",
36
- "updated_at"=>"2014-03-06T19:23:56.470321Z"},
35
+ "transaction_number"=>"RV296-883-6069",
36
+ "updated_at"=>"2014-04-25T20:18:57.393905Z"},
37
37
  @hyperlinks=
38
38
  {"credit"=>
39
- #<Proc:0x007fa4e326f798/lib/balanced/resources/resource.rb:60 (lambda)>,
39
+ #<Proc:0x007fa93b70d1e0/lib/balanced/resources/resource.rb:60 (lambda)>,
40
40
  "events"=>
41
- #<Proc:0x007fa4e326c980/lib/balanced/utils.rb:6 (lambda)>,
41
+ #<Proc:0x007fa93b707290/lib/balanced/utils.rb:6 (lambda)>,
42
42
  "order"=>
43
- #<Proc:0x007fa4e3267f48/lib/balanced/utils.rb:6 (lambda)>}>
43
+ #<Proc:0x007fa93b7068b8/lib/balanced/utils.rb:6 (lambda)>}>
44
44
 
45
45
  % endif
@@ -3,34 +3,34 @@ Balanced::Reversal.all
3
3
 
4
4
  % elif mode == 'request':
5
5
  require 'balanced'
6
- Balanced.configure('ak-test-2ADpvITfpgBn8uBzEGsQ2bIgWaftUWiul')
6
+ Balanced.configure('ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV')
7
7
 
8
8
  reversals = Balanced::Reversal.all
9
9
  % elif mode == 'response':
10
- [#<Balanced::Reversal:0x007fa4e49eb340
10
+ [#<Balanced::Reversal:0x007fa93b6e73f0
11
11
  @attributes=
12
12
  {"amount"=>3000,
13
- "created_at"=>"2014-03-06T19:23:55.596399Z",
13
+ "created_at"=>"2014-04-25T20:18:55.008280Z",
14
14
  "currency"=>"USD",
15
15
  "description"=>"Reversal for Order #1111",
16
16
  "failure_reason"=>nil,
17
17
  "failure_reason_code"=>nil,
18
- "href"=>"/reversals/RV6OCxJ1UhkG84is6H9PHjkZ",
19
- "id"=>"RV6OCxJ1UhkG84is6H9PHjkZ",
20
- "links"=>{"credit"=>"CR6NpuEtezCdLTYngDrSEODv", "order"=>nil},
18
+ "href"=>"/reversals/RV6qrEOTouLeIJuPu4s73Ra1",
19
+ "id"=>"RV6qrEOTouLeIJuPu4s73Ra1",
20
+ "links"=>{"credit"=>"CR6nBcaGvGc4dtflEB1bjKBP", "order"=>nil},
21
21
  "meta"=>
22
22
  {"fulfillment.item.condition"=>"OK",
23
23
  "merchant.feedback"=>"positive",
24
24
  "user.refund_reason"=>"not happy with product"},
25
25
  "status"=>"succeeded",
26
- "transaction_number"=>"RV542-861-3670",
27
- "updated_at"=>"2014-03-06T19:23:56.470321Z"},
26
+ "transaction_number"=>"RV296-883-6069",
27
+ "updated_at"=>"2014-04-25T20:18:57.393905Z"},
28
28
  @hyperlinks=
29
29
  {"credit"=>
30
- #<Proc:0x007fa4e49e8ed8/lib/balanced/resources/resource.rb:60 (lambda)>,
30
+ #<Proc:0x007fa93b6e5848/lib/balanced/resources/resource.rb:60 (lambda)>,
31
31
  "events"=>
32
- #<Proc:0x007fa4e49e3050/lib/balanced/utils.rb:6 (lambda)>,
32
+ #<Proc:0x007fa93b6df330/lib/balanced/utils.rb:6 (lambda)>,
33
33
  "order"=>
34
- #<Proc:0x007fa4e49e2448/lib/balanced/utils.rb:6 (lambda)>}>]
34
+ #<Proc:0x007fa93b6de908/lib/balanced/utils.rb:6 (lambda)>}>]
35
35
 
36
36
  % endif
@@ -3,35 +3,35 @@ Balanced::Reversal.fetch
3
3
 
4
4
  % elif mode == 'request':
5
5
  require 'balanced'
6
- Balanced.configure('ak-test-2ADpvITfpgBn8uBzEGsQ2bIgWaftUWiul')
6
+ Balanced.configure('ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV')
7
7
 
8
- reversal = Balanced::Reversal.fetch('/reversals/RV6OCxJ1UhkG84is6H9PHjkZ')
8
+ reversal = Balanced::Reversal.fetch('/reversals/RV6qrEOTouLeIJuPu4s73Ra1')
9
9
 
10
10
  % elif mode == 'response':
11
- #<Balanced::Reversal:0x007fa4e49c3340
11
+ #<Balanced::Reversal:0x007fa93b6c4c38
12
12
  @attributes=
13
13
  {"amount"=>3000,
14
- "created_at"=>"2014-03-06T19:23:55.596399Z",
14
+ "created_at"=>"2014-04-25T20:18:55.008280Z",
15
15
  "currency"=>"USD",
16
16
  "description"=>"Reversal for Order #1111",
17
17
  "failure_reason"=>nil,
18
18
  "failure_reason_code"=>nil,
19
- "href"=>"/reversals/RV6OCxJ1UhkG84is6H9PHjkZ",
20
- "id"=>"RV6OCxJ1UhkG84is6H9PHjkZ",
21
- "links"=>{"credit"=>"CR6NpuEtezCdLTYngDrSEODv", "order"=>nil},
19
+ "href"=>"/reversals/RV6qrEOTouLeIJuPu4s73Ra1",
20
+ "id"=>"RV6qrEOTouLeIJuPu4s73Ra1",
21
+ "links"=>{"credit"=>"CR6nBcaGvGc4dtflEB1bjKBP", "order"=>nil},
22
22
  "meta"=>
23
23
  {"fulfillment.item.condition"=>"OK",
24
24
  "merchant.feedback"=>"positive",
25
25
  "user.refund_reason"=>"not happy with product"},
26
26
  "status"=>"succeeded",
27
- "transaction_number"=>"RV542-861-3670",
28
- "updated_at"=>"2014-03-06T19:23:56.470321Z"},
27
+ "transaction_number"=>"RV296-883-6069",
28
+ "updated_at"=>"2014-04-25T20:18:57.393905Z"},
29
29
  @hyperlinks=
30
30
  {"credit"=>
31
- #<Proc:0x007fa4e49c1d88/lib/balanced/resources/resource.rb:60 (lambda)>,
31
+ #<Proc:0x007fa93b6bf030/lib/balanced/resources/resource.rb:60 (lambda)>,
32
32
  "events"=>
33
- #<Proc:0x007fa4e49bb640/lib/balanced/utils.rb:6 (lambda)>,
33
+ #<Proc:0x007fa93b6bd0c8/lib/balanced/utils.rb:6 (lambda)>,
34
34
  "order"=>
35
- #<Proc:0x007fa4e49bb488/lib/balanced/utils.rb:6 (lambda)>}>
35
+ #<Proc:0x007fa93b6bc6a0/lib/balanced/utils.rb:6 (lambda)>}>
36
36
 
37
37
  % endif
@@ -3,9 +3,9 @@ Balanced::Reversal.save
3
3
 
4
4
  % elif mode == 'request':
5
5
  require 'balanced'
6
- Balanced.configure('ak-test-2ADpvITfpgBn8uBzEGsQ2bIgWaftUWiul')
6
+ Balanced.configure('ak-test-22IOkhevjZlmRP2do6CZixkkDshTiOjTV')
7
7
 
8
- reversal = Balanced::Reversal.fetch('/reversals/RV6OCxJ1UhkG84is6H9PHjkZ')
8
+ reversal = Balanced::Reversal.fetch('/reversals/RV6qrEOTouLeIJuPu4s73Ra1')
9
9
  reversal.description = 'update this description'
10
10
  reversal.meta = {
11
11
  'refund.reason' => 'user not happy with product',
@@ -15,30 +15,30 @@ reversal.meta = {
15
15
  reversal.save
16
16
 
17
17
  % elif mode == 'response':
18
- #<Balanced::Reversal:0x007fa4e49991f8
18
+ #<Balanced::Reversal:0x007fa93b66d2a8
19
19
  @attributes=
20
20
  {"amount"=>3000,
21
- "created_at"=>"2014-03-06T19:23:55.596399Z",
21
+ "created_at"=>"2014-04-25T20:18:55.008280Z",
22
22
  "currency"=>"USD",
23
23
  "description"=>"update this description",
24
24
  "failure_reason"=>nil,
25
25
  "failure_reason_code"=>nil,
26
- "href"=>"/reversals/RV6OCxJ1UhkG84is6H9PHjkZ",
27
- "id"=>"RV6OCxJ1UhkG84is6H9PHjkZ",
28
- "links"=>{"credit"=>"CR6NpuEtezCdLTYngDrSEODv", "order"=>nil},
26
+ "href"=>"/reversals/RV6qrEOTouLeIJuPu4s73Ra1",
27
+ "id"=>"RV6qrEOTouLeIJuPu4s73Ra1",
28
+ "links"=>{"credit"=>"CR6nBcaGvGc4dtflEB1bjKBP", "order"=>nil},
29
29
  "meta"=>
30
30
  {"refund.reason"=>"user not happy with product",
31
31
  "user.notes"=>"very polite on the phone",
32
32
  "user.satisfaction"=>"6"},
33
33
  "status"=>"succeeded",
34
- "transaction_number"=>"RV542-861-3670",
35
- "updated_at"=>"2014-03-06T19:24:00.271458Z"},
34
+ "transaction_number"=>"RV296-883-6069",
35
+ "updated_at"=>"2014-04-25T20:19:01.228936Z"},
36
36
  @hyperlinks=
37
37
  {"credit"=>
38
- #<Proc:0x007fa4e49932a8/lib/balanced/resources/resource.rb:60 (lambda)>,
38
+ #<Proc:0x007fa93b666318/lib/balanced/resources/resource.rb:60 (lambda)>,
39
39
  "events"=>
40
- #<Proc:0x007fa4e49900f8/lib/balanced/utils.rb:6 (lambda)>,
40
+ #<Proc:0x007fa93b65c098/lib/balanced/utils.rb:6 (lambda)>,
41
41
  "order"=>
42
- #<Proc:0x007fa4e293b398/lib/balanced/utils.rb:6 (lambda)>}>
42
+ #<Proc:0x007fa93b655dd8/lib/balanced/utils.rb:6 (lambda)>}>
43
43
 
44
44
  % endif
@@ -13,6 +13,7 @@ describe Balanced::Credit, :vcr do
13
13
 
14
14
  # An initial balance for the marketplace
15
15
  card.debit(:amount => 1000000)
16
+ @meta = {"order_id" => "1111"}
16
17
  end
17
18
 
18
19
  describe '#create', :vcr do
@@ -25,7 +26,8 @@ describe Balanced::Credit, :vcr do
25
26
  :account_number => '0987654321',
26
27
  :name => 'Timmy T. McTimmerson',
27
28
  :type => 'checking'
28
- }
29
+ },
30
+ :meta => @meta
29
31
  ).save
30
32
  end
31
33
 
@@ -39,6 +41,11 @@ describe Balanced::Credit, :vcr do
39
41
  it { should be_nil }
40
42
  end
41
43
 
44
+ describe 'meta', :vcr do
45
+ subject { @credit.meta }
46
+ it { should eq @meta }
47
+ end
48
+
42
49
  end
43
50
 
44
51
  describe '#reverse', :vcr do
@@ -51,9 +58,10 @@ describe Balanced::Credit, :vcr do
51
58
  :account_number => '0987654321',
52
59
  :name => 'Timmy T. McTimmerson',
53
60
  :type => 'checking'
54
- }
61
+ },
62
+ :meta => @meta
55
63
  ).save
56
- @reversal = @credit.reverse
64
+ @reversal = @credit.reverse({:meta => @meta})
57
65
  end
58
66
 
59
67
  describe '#amount', :vcr do
@@ -65,6 +73,12 @@ describe Balanced::Credit, :vcr do
65
73
  subject { @reversal }
66
74
  it { should be_instance_of Balanced::Reversal }
67
75
  end
76
+
77
+ describe '#meta', :vcr do
78
+ subject { @reversal.meta }
79
+ it { should == @meta }
80
+ end
81
+
68
82
  end
69
83
 
70
84
  describe 'credit with underwritten customer' do
@@ -75,7 +89,8 @@ describe Balanced::Credit, :vcr do
75
89
  :dob_year => 1963,
76
90
  :address => {
77
91
  :postal_code => '48120'
78
- }
92
+ },
93
+ :meta => @meta
79
94
  ).save
80
95
  @bank_account = Balanced::BankAccount.new(
81
96
  :routing_number => '321174851',
@@ -86,7 +101,8 @@ describe Balanced::Credit, :vcr do
86
101
  @bank_account.associate_to_customer(@customer)
87
102
  @credit = @bank_account.credit(
88
103
  :amount => 5000,
89
- :description => 'A sweet ride'
104
+ :description => 'A sweet ride',
105
+ :meta => @meta
90
106
  )
91
107
  end
92
108
 
@@ -104,5 +120,10 @@ describe Balanced::Credit, :vcr do
104
120
  subject { @credit.status }
105
121
  it { should eq 'succeeded' }
106
122
  end
123
+
124
+ describe 'meta', :vcr do
125
+ subject { @credit.meta }
126
+ it { should eq @meta }
127
+ end
107
128
  end
108
129
  end
@@ -61,6 +61,9 @@ describe Balanced::Debit, :vcr do
61
61
  end
62
62
 
63
63
  describe '#refund', :vcr do
64
+ before do
65
+ @meta = {"order_id" => "11111"}
66
+ end
64
67
  subject do
65
68
  debit = Balanced::Debit.new(
66
69
  :amount => 1234,
@@ -68,15 +71,17 @@ describe Balanced::Debit, :vcr do
68
71
  :number => '5105105105105100',
69
72
  :expiration_month => '12',
70
73
  :expiration_year => '2015'
71
- })
74
+ },
75
+ :meta => @meta)
72
76
  debit.save
73
- refund = debit.refund
77
+ refund = debit.refund({:meta => @meta})
74
78
  refund
75
79
  end
76
80
 
77
81
  it { should_not be_nil }
78
82
  it { should be_instance_of Balanced::Refund }
79
83
  its(:amount) { should eql 1234 }
84
+ its(:meta) {should eq @meta}
80
85
 
81
86
  end
82
87
  end
@@ -53,23 +53,45 @@ describe Balanced::Order, :vcr, :marketplace => true do
53
53
  end
54
54
 
55
55
  it 'should debit buyer and pay merchant' do
56
+ # statement/description to test passthrough to debit/credit
57
+ @debit_description = 'Debit Description'
58
+ @debit_statement_message = 'Debit Message'
59
+ @credit_description = 'Credit Description'
60
+ @credit_statement_message = 'Credit Message'
61
+ @meta = {"order_id" => "1111"}
62
+
56
63
  debit = @order.debit_from(
57
64
  :source => @card,
58
- :amount => 10000
65
+ :amount => 10000,
66
+ :appears_on_statement_as => @debit_statement_message,
67
+ :description => @debit_description,
68
+ :meta => @meta
59
69
  )
60
70
 
61
71
  @order.reload
62
72
  @order.amount.should eq 10000
63
73
  @order.amount_escrowed.should eq 10000
64
74
 
65
- @order.credit_to(
75
+ debit.description.should eq @debit_description
76
+ debit.meta.should eq @meta
77
+ debit.appears_on_statement_as.should eq "BAL*" << @debit_statement_message
78
+
79
+ credit = @order.credit_to(
66
80
  :destination => @bank_account,
67
- :amount => 8000
81
+ :amount => 8000,
82
+ :appears_on_statement_as => @credit_statement_message,
83
+ :description => @credit_description,
84
+ :meta => @meta
68
85
  )
86
+
69
87
  @order.reload
70
88
  @order.amount.should eq 10000
71
89
  @order.amount_escrowed.should eq 2000
72
90
  @order.debits.map { |d| d.href }.should include(debit.href)
91
+
92
+ credit.description.should eq @credit_description
93
+ credit.meta.should eq @meta
94
+ credit.appears_on_statement_as.should eq @credit_statement_message
73
95
  end
74
96
 
75
97
  end