stripe 1.30.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitattributes +4 -0
- data/.github/ISSUE_TEMPLATE.md +5 -0
- data/.travis.yml +3 -14
- data/Gemfile +28 -4
- data/History.txt +180 -0
- data/README.md +147 -0
- data/Rakefile +10 -0
- data/VERSION +1 -1
- data/bin/stripe-console +12 -5
- data/lib/data/ca-certificates.crt +3868 -5114
- data/lib/stripe/account.rb +43 -23
- data/lib/stripe/alipay_account.rb +20 -0
- data/lib/stripe/api_operations/create.rb +2 -2
- data/lib/stripe/api_operations/delete.rb +2 -2
- data/lib/stripe/api_operations/list.rb +2 -3
- data/lib/stripe/api_operations/request.rb +9 -3
- data/lib/stripe/api_operations/save.rb +85 -0
- data/lib/stripe/api_resource.rb +38 -5
- data/lib/stripe/apple_pay_domain.rb +12 -0
- data/lib/stripe/application_fee.rb +8 -8
- data/lib/stripe/application_fee_refund.rb +7 -3
- data/lib/stripe/balance_transaction.rb +1 -1
- data/lib/stripe/bank_account.rb +13 -4
- data/lib/stripe/bitcoin_receiver.rb +6 -6
- data/lib/stripe/bitcoin_transaction.rb +1 -1
- data/lib/stripe/card.rb +9 -5
- data/lib/stripe/charge.rb +38 -20
- data/lib/stripe/country_spec.rb +9 -0
- data/lib/stripe/coupon.rb +1 -1
- data/lib/stripe/customer.rb +12 -10
- data/lib/stripe/dispute.rb +4 -5
- data/lib/stripe/errors.rb +92 -0
- data/lib/stripe/file_upload.rb +1 -1
- data/lib/stripe/invoice.rb +7 -7
- data/lib/stripe/invoice_item.rb +1 -1
- data/lib/stripe/list_object.rb +8 -7
- data/lib/stripe/order.rb +12 -4
- data/lib/stripe/order_return.rb +9 -0
- data/lib/stripe/plan.rb +1 -1
- data/lib/stripe/product.rb +2 -10
- data/lib/stripe/recipient.rb +1 -1
- data/lib/stripe/refund.rb +1 -1
- data/lib/stripe/reversal.rb +7 -3
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/sku.rb +2 -2
- data/lib/stripe/source.rb +11 -0
- data/lib/stripe/stripe_client.rb +396 -0
- data/lib/stripe/stripe_object.rb +167 -91
- data/lib/stripe/stripe_response.rb +48 -0
- data/lib/stripe/subscription.rb +15 -9
- data/lib/stripe/subscription_item.rb +12 -0
- data/lib/stripe/three_d_secure.rb +9 -0
- data/lib/stripe/transfer.rb +4 -5
- data/lib/stripe/util.rb +105 -33
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +69 -266
- data/spec/fixtures.json +1409 -0
- data/spec/fixtures.yaml +1153 -0
- data/spec/spec.json +19949 -0
- data/spec/spec.yaml +15504 -0
- data/stripe.gemspec +5 -18
- data/test/api_fixtures.rb +29 -0
- data/test/api_stub_helpers.rb +125 -0
- data/test/stripe/account_test.rb +163 -211
- data/test/stripe/alipay_account_test.rb +19 -0
- data/test/stripe/api_operations_test.rb +31 -0
- data/test/stripe/api_resource_test.rb +174 -340
- data/test/stripe/apple_pay_domain_test.rb +33 -0
- data/test/stripe/application_fee_refund_test.rb +22 -31
- data/test/stripe/application_fee_test.rb +6 -14
- data/test/stripe/balance_test.rb +3 -3
- data/test/stripe/bank_account_test.rb +41 -0
- data/test/stripe/bitcoin_receiver_test.rb +51 -42
- data/test/stripe/bitcoin_transaction_test.rb +11 -19
- data/test/stripe/charge_test.rb +39 -98
- data/test/stripe/country_spec_test.rb +20 -0
- data/test/stripe/coupon_test.rb +35 -11
- data/test/stripe/customer_card_test.rb +25 -46
- data/test/stripe/customer_test.rb +89 -61
- data/test/stripe/dispute_test.rb +28 -31
- data/test/stripe/errors_test.rb +18 -0
- data/test/stripe/file_upload_test.rb +32 -24
- data/test/stripe/invoice_item_test.rb +55 -0
- data/test/stripe/invoice_test.rb +50 -24
- data/test/stripe/list_object_test.rb +57 -45
- data/test/stripe/order_return_test.rb +21 -0
- data/test/stripe/order_test.rb +41 -34
- data/test/stripe/plan_test.rb +52 -0
- data/test/stripe/product_test.rb +31 -25
- data/test/stripe/recipient_card_test.rb +23 -40
- data/test/stripe/recipient_test.rb +50 -0
- data/test/stripe/refund_test.rb +20 -36
- data/test/stripe/reversal_test.rb +27 -31
- data/test/stripe/sku_test.rb +39 -13
- data/test/stripe/source_test.rb +43 -0
- data/test/stripe/stripe_client_test.rb +428 -0
- data/test/stripe/stripe_object_test.rb +186 -13
- data/test/stripe/stripe_response_test.rb +46 -0
- data/test/stripe/subscription_item_test.rb +54 -0
- data/test/stripe/subscription_test.rb +40 -52
- data/test/stripe/three_d_secure_test.rb +23 -0
- data/test/stripe/transfer_test.rb +38 -13
- data/test/stripe/util_test.rb +48 -16
- data/test/stripe_test.rb +25 -0
- data/test/test_data.rb +5 -621
- data/test/test_helper.rb +24 -24
- metadata +60 -139
- data/README.rdoc +0 -68
- data/gemfiles/default-with-activesupport.gemfile +0 -10
- data/gemfiles/json.gemfile +0 -12
- data/gemfiles/yajl.gemfile +0 -12
- data/lib/stripe/api_operations/update.rb +0 -58
- data/lib/stripe/errors/api_connection_error.rb +0 -4
- data/lib/stripe/errors/api_error.rb +0 -4
- data/lib/stripe/errors/authentication_error.rb +0 -4
- data/lib/stripe/errors/card_error.rb +0 -12
- data/lib/stripe/errors/invalid_request_error.rb +0 -11
- data/lib/stripe/errors/rate_limit_error.rb +0 -4
- data/lib/stripe/errors/stripe_error.rb +0 -26
- data/test/stripe/charge_refund_test.rb +0 -55
- data/test/stripe/metadata_test.rb +0 -129
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class ChargeRefundTest < Test::Unit::TestCase
|
5
|
-
should "refunds should be listable" do
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_charge))
|
7
|
-
|
8
|
-
charge = Stripe::Charge.retrieve('test_charge')
|
9
|
-
|
10
|
-
assert charge.refunds.first.kind_of?(Stripe::Refund)
|
11
|
-
end
|
12
|
-
|
13
|
-
should "refunds should be refreshable" do
|
14
|
-
@mock.expects(:get).twice.returns(make_response(make_charge), make_response(make_refund(:id => 'refreshed_refund')))
|
15
|
-
|
16
|
-
charge = Stripe::Charge.retrieve('test_charge')
|
17
|
-
refund = charge.refunds.first
|
18
|
-
refund.refresh
|
19
|
-
|
20
|
-
assert_equal 'refreshed_refund', refund.id
|
21
|
-
end
|
22
|
-
|
23
|
-
should "refunds should be updateable" do
|
24
|
-
@mock.expects(:get).
|
25
|
-
with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
|
26
|
-
once.returns(make_response(make_charge))
|
27
|
-
@mock.expects(:post).
|
28
|
-
with("#{Stripe.api_base}/v1/refunds/ref_test_refund", nil, 'metadata[key]=value').
|
29
|
-
once.returns(make_response(make_refund(:metadata => {'key' => 'value'})))
|
30
|
-
|
31
|
-
charge = Stripe::Charge.retrieve('test_charge')
|
32
|
-
refund = charge.refunds.first
|
33
|
-
|
34
|
-
assert_equal nil, refund.metadata['key']
|
35
|
-
|
36
|
-
refund.metadata['key'] = 'value'
|
37
|
-
refund.save
|
38
|
-
|
39
|
-
assert_equal 'value', refund.metadata['key']
|
40
|
-
end
|
41
|
-
|
42
|
-
should "create should return a new refund" do
|
43
|
-
@mock.expects(:get).
|
44
|
-
with("#{Stripe.api_base}/v1/charges/test_charge", nil, nil).
|
45
|
-
once.returns(make_response(make_charge(:id => 'test_charge')))
|
46
|
-
@mock.expects(:post).
|
47
|
-
with("#{Stripe.api_base}/v1/charges/test_charge/refunds", nil, 'amount=20').
|
48
|
-
once.returns(make_response(make_refund(:id => 'test_new_refund')))
|
49
|
-
|
50
|
-
charge = Stripe::Charge.retrieve('test_charge')
|
51
|
-
refund = charge.refunds.create(:amount => 20)
|
52
|
-
assert_equal 'test_new_refund', refund.id
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
require File.expand_path('../../test_helper', __FILE__)
|
2
|
-
|
3
|
-
module Stripe
|
4
|
-
class MetadataTest < Test::Unit::TestCase
|
5
|
-
setup do
|
6
|
-
@metadata_supported = {
|
7
|
-
:charge => {
|
8
|
-
:new => Stripe::Charge.method(:new),
|
9
|
-
:test => method(:make_charge),
|
10
|
-
:url => "/v1/charges/#{make_charge()[:id]}"
|
11
|
-
},
|
12
|
-
:customer => {
|
13
|
-
:new => Stripe::Customer.method(:new),
|
14
|
-
:test => method(:make_customer),
|
15
|
-
:url => "/v1/customers/#{make_customer()[:id]}"
|
16
|
-
},
|
17
|
-
:recipient => {
|
18
|
-
:new => Stripe::Recipient.method(:new),
|
19
|
-
:test => method(:make_recipient),
|
20
|
-
:url => "/v1/recipients/#{make_recipient()[:id]}"
|
21
|
-
},
|
22
|
-
:transfer => {
|
23
|
-
:new => Stripe::Transfer.method(:new),
|
24
|
-
:test => method(:make_transfer),
|
25
|
-
:url => "/v1/transfers/#{make_transfer()[:id]}"
|
26
|
-
},
|
27
|
-
:product => {
|
28
|
-
:new => Stripe::Product.method(:new),
|
29
|
-
:test => method(:make_product),
|
30
|
-
:url => "/v1/products/#{make_product()[:id]}"
|
31
|
-
},
|
32
|
-
:order => {
|
33
|
-
:new => Stripe::Order.method(:new),
|
34
|
-
:test => method(:make_order),
|
35
|
-
:url => "/v1/orders/#{make_order()[:id]}"
|
36
|
-
},
|
37
|
-
:sku => {
|
38
|
-
:new => Stripe::SKU.method(:new),
|
39
|
-
:test => method(:make_sku),
|
40
|
-
:url => "/v1/skus/#{make_sku()[:id]}"
|
41
|
-
},
|
42
|
-
}
|
43
|
-
|
44
|
-
@base_url = 'https://api.stripe.com'
|
45
|
-
end
|
46
|
-
|
47
|
-
should "not touch metadata" do
|
48
|
-
update_actions = lambda {|obj| obj.description = 'test'}
|
49
|
-
check_metadata({:metadata => {'initial' => 'true'}},
|
50
|
-
'description=test',
|
51
|
-
update_actions)
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
should "update metadata as a whole" do
|
56
|
-
update_actions = lambda {|obj| obj.metadata = {'uuid' => '6735'}}
|
57
|
-
check_metadata({:metadata => {}},
|
58
|
-
'metadata[uuid]=6735',
|
59
|
-
update_actions)
|
60
|
-
|
61
|
-
if is_greater_than_ruby_1_9?
|
62
|
-
check_metadata({:metadata => {:initial => 'true'}},
|
63
|
-
'metadata[initial]=&metadata[uuid]=6735',
|
64
|
-
update_actions)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
should "update metadata keys individually" do
|
69
|
-
update_actions = lambda {|obj| obj.metadata['txn_id'] = '134a13'}
|
70
|
-
check_metadata({:metadata => {'initial' => 'true'}},
|
71
|
-
'metadata[txn_id]=134a13',
|
72
|
-
update_actions)
|
73
|
-
end
|
74
|
-
|
75
|
-
should "clear metadata as a whole" do
|
76
|
-
update_actions = lambda {|obj| obj.metadata = nil}
|
77
|
-
check_metadata({:metadata => {'initial' => 'true'}},
|
78
|
-
'metadata=',
|
79
|
-
update_actions)
|
80
|
-
end
|
81
|
-
|
82
|
-
should "clear metadata keys individually" do
|
83
|
-
update_actions = lambda {|obj| obj.metadata['initial'] = nil}
|
84
|
-
check_metadata({:metadata => {'initial' => 'true'}},
|
85
|
-
'metadata[initial]=',
|
86
|
-
update_actions)
|
87
|
-
end
|
88
|
-
|
89
|
-
should "handle combinations of whole and partial metadata updates" do
|
90
|
-
if is_greater_than_ruby_1_9?
|
91
|
-
update_actions = lambda do |obj|
|
92
|
-
obj.metadata = {'type' => 'summer'}
|
93
|
-
obj.metadata['uuid'] = '6735'
|
94
|
-
end
|
95
|
-
params = {:metadata => {'type' => 'summer', 'uuid' => '6735'}}
|
96
|
-
curl_args = Stripe::Util.encode_parameters(params)
|
97
|
-
check_metadata({:metadata => {'type' => 'christmas'}},
|
98
|
-
curl_args,
|
99
|
-
update_actions)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def check_metadata (initial_params, curl_args, metadata_update)
|
104
|
-
@metadata_supported.each do |name, methods|
|
105
|
-
neu = methods[:new]
|
106
|
-
test = methods[:test]
|
107
|
-
url = @base_url + methods[:url]
|
108
|
-
|
109
|
-
initial_test_obj = test.call(initial_params)
|
110
|
-
@mock.expects(:get).once.returns(make_response(initial_test_obj))
|
111
|
-
|
112
|
-
final_test_obj = test.call()
|
113
|
-
@mock.expects(:post).once.
|
114
|
-
returns(make_response(final_test_obj)).
|
115
|
-
with(url, nil, curl_args)
|
116
|
-
|
117
|
-
obj = neu.call("test")
|
118
|
-
obj.refresh()
|
119
|
-
metadata_update.call(obj)
|
120
|
-
obj.save
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def is_greater_than_ruby_1_9?
|
125
|
-
version = RUBY_VERSION.dup # clone preserves frozen state
|
126
|
-
Gem::Version.new(version) >= Gem::Version.new('1.9')
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|