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
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class ApplePayDomainTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:apple_pay_domain)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
domains = Stripe::ApplePayDomain.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains"
|
10
|
+
assert domains.data.kind_of?(Array)
|
11
|
+
assert domains.data[0].kind_of?(Stripe::ApplePayDomain)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
domain = Stripe::ApplePayDomain.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/apple_pay/domains/#{FIXTURE[:id]}"
|
17
|
+
assert domain.kind_of?(Stripe::ApplePayDomain)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
domain = Stripe::ApplePayDomain.create(:domain_name => "example.com")
|
22
|
+
assert_requested :post, "#{Stripe.api_base}/v1/apple_pay/domains"
|
23
|
+
assert domain.kind_of?(Stripe::ApplePayDomain)
|
24
|
+
end
|
25
|
+
|
26
|
+
should "be deletable" do
|
27
|
+
domain = Stripe::ApplePayDomain.retrieve(FIXTURE[:id])
|
28
|
+
domain = domain.delete
|
29
|
+
assert_requested :delete, "#{Stripe.api_base}/v1/apple_pay/domains/#{FIXTURE[:id]}"
|
30
|
+
assert domain.kind_of?(Stripe::ApplePayDomain)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,46 +2,37 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeRefundTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_application_fee))
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:fee_refund)
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
setup do
|
8
|
+
application_fee_fixture = API_FIXTURES.fetch(:platform_earning)
|
9
|
+
@fee = Stripe::ApplicationFee.retrieve(application_fee_fixture[:id])
|
11
10
|
end
|
12
11
|
|
13
|
-
should "
|
14
|
-
@
|
12
|
+
should "be listable" do
|
13
|
+
refunds = @fee.refunds
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
# notably this *doesn't* make an API call
|
16
|
+
assert_not_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
19
18
|
|
20
|
-
|
19
|
+
assert refunds.data.kind_of?(Array)
|
20
|
+
assert refunds.first.kind_of?(Stripe::ApplicationFeeRefund)
|
21
21
|
end
|
22
22
|
|
23
|
-
should "
|
24
|
-
@
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
refund = application_fee.refunds.first
|
29
|
-
|
30
|
-
assert_equal nil, refund.metadata['key']
|
31
|
-
|
32
|
-
refund.metadata['key'] = 'valu'
|
33
|
-
refund.save
|
34
|
-
|
35
|
-
assert_equal 'value', refund.metadata['key']
|
23
|
+
should "be creatable" do
|
24
|
+
refund = @fee.refunds.create
|
25
|
+
assert_requested :post,
|
26
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds"
|
27
|
+
assert refund.kind_of?(Stripe::ApplicationFeeRefund)
|
36
28
|
end
|
37
29
|
|
38
|
-
should "
|
39
|
-
@
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
assert_equal 'test_new_refund', refund.id
|
30
|
+
should "be saveable" do
|
31
|
+
refund = @fee.refunds.first
|
32
|
+
refund.metadata['key'] = 'value'
|
33
|
+
refund.save
|
34
|
+
assert_requested :post,
|
35
|
+
"#{Stripe.api_base}/v1/application_fees/#{@fee.id}/refunds/#{FIXTURE[:id]}"
|
45
36
|
end
|
46
37
|
end
|
47
38
|
end
|
@@ -2,21 +2,13 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ApplicationFeeTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_application_fee_array))
|
7
|
-
fees = Stripe::ApplicationFee.list
|
8
|
-
assert fees.data.kind_of? Array
|
9
|
-
fees.each do |fee|
|
10
|
-
assert fee.kind_of?(Stripe::ApplicationFee)
|
11
|
-
end
|
12
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:platform_earning)
|
13
6
|
|
14
|
-
should "
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
assert fee.refunded
|
7
|
+
should "be listable" do
|
8
|
+
fees = Stripe::ApplicationFee.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/application_fees"
|
10
|
+
assert fees.data.kind_of?(Array)
|
11
|
+
assert fees.data[0].kind_of?(Stripe::ApplicationFee)
|
20
12
|
end
|
21
13
|
end
|
22
14
|
end
|
data/test/stripe/balance_test.rb
CHANGED
@@ -2,10 +2,10 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BalanceTest < Test::Unit::TestCase
|
5
|
-
should "
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_balance))
|
5
|
+
should "be retrievable" do
|
7
6
|
balance = Stripe::Balance.retrieve
|
8
|
-
|
7
|
+
assert_requested :get, "#{Stripe.api_base}/v1/balance"
|
8
|
+
assert balance.kind_of?(Stripe::Balance)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class BankAccountTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:external_account_source)
|
6
|
+
|
7
|
+
context "#resource_url" do
|
8
|
+
should "return an external account URL" do
|
9
|
+
account_id = API_FIXTURES.fetch(:account)[:id]
|
10
|
+
bank_account = Stripe::BankAccount.construct_from(
|
11
|
+
account: account_id,
|
12
|
+
id: FIXTURE[:id]
|
13
|
+
)
|
14
|
+
assert_equal "/v1/accounts/#{account_id}/external_accounts/#{FIXTURE[:id]}",
|
15
|
+
bank_account.resource_url
|
16
|
+
end
|
17
|
+
|
18
|
+
should "return a customer URL" do
|
19
|
+
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
20
|
+
bank_account = Stripe::BankAccount.construct_from(
|
21
|
+
customer: customer_id,
|
22
|
+
id: FIXTURE[:id]
|
23
|
+
)
|
24
|
+
assert_equal "/v1/customers/#{customer_id}/sources/#{FIXTURE[:id]}",
|
25
|
+
bank_account.resource_url
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#verify" do
|
30
|
+
should 'verify the account' do
|
31
|
+
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
32
|
+
bank_account = Stripe::BankAccount.construct_from({
|
33
|
+
customer: customer_id,
|
34
|
+
id: FIXTURE[:id]
|
35
|
+
})
|
36
|
+
bank_account = bank_account.verify(amounts: [1,2])
|
37
|
+
assert bank_account.kind_of?(Stripe::BankAccount)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -2,60 +2,69 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BitcoinReceiverTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_bitcoin_receiver))
|
7
|
-
receiver = Stripe::BitcoinReceiver.retrieve('btcrcv_test_receiver')
|
8
|
-
assert_equal 'btcrcv_test_receiver', receiver.id
|
9
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:bitcoin_receiver)
|
10
6
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
should "be listable" do
|
8
|
+
receivers = Stripe::BitcoinReceiver.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/receivers"
|
10
|
+
assert receivers.data.kind_of?(Array)
|
11
|
+
assert receivers.first.kind_of?(Stripe::BitcoinReceiver)
|
15
12
|
end
|
16
13
|
|
17
|
-
should "
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
assert
|
22
|
-
receivers.each do |receiver|
|
23
|
-
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
24
|
-
receiver.transactions.data.each do |transaction|
|
25
|
-
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
26
|
-
end
|
27
|
-
end
|
14
|
+
should "be retrievable" do
|
15
|
+
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
18
|
+
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
28
19
|
end
|
29
20
|
|
30
|
-
should "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
transactions = receiver.transactions.list
|
35
|
-
assert_equal(3, transactions.data.length)
|
21
|
+
should "be creatable" do
|
22
|
+
receiver = Stripe::BitcoinReceiver.create(amount: 100, currency: "USD")
|
23
|
+
assert_requested :post, "#{Stripe.api_base}/v1/bitcoin/receivers"
|
24
|
+
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
36
25
|
end
|
37
26
|
|
38
|
-
should "
|
39
|
-
|
40
|
-
|
41
|
-
receiver = Stripe::BitcoinReceiver.construct_from(make_bitcoin_receiver)
|
42
|
-
receiver.refresh
|
43
|
-
receiver.description = "details"
|
27
|
+
should "be saveable" do
|
28
|
+
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
29
|
+
receiver.metadata['key'] = 'value'
|
44
30
|
receiver.save
|
31
|
+
assert_requested :post,
|
32
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
45
33
|
end
|
46
34
|
|
47
|
-
should "
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
assert
|
35
|
+
should "be updateable" do
|
36
|
+
receiver = Stripe::BitcoinReceiver.update(FIXTURE[:id], metadata: { key: 'value' })
|
37
|
+
assert_requested :post,
|
38
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
39
|
+
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
52
40
|
end
|
53
41
|
|
54
|
-
should "
|
55
|
-
|
56
|
-
receiver =
|
57
|
-
|
58
|
-
|
42
|
+
should "be deletable" do
|
43
|
+
receiver = Stripe::BitcoinReceiver.retrieve(FIXTURE[:id])
|
44
|
+
receiver = receiver.delete
|
45
|
+
assert_requested :delete,
|
46
|
+
"#{Stripe.api_base}/v1/bitcoin/receivers/#{FIXTURE[:id]}"
|
47
|
+
assert receiver.kind_of?(Stripe::BitcoinReceiver)
|
48
|
+
end
|
49
|
+
|
50
|
+
context "#resource_url" do
|
51
|
+
should "return a customer URL" do
|
52
|
+
customer_id = API_FIXTURES.fetch(:customer)[:id]
|
53
|
+
receiver = Stripe::BitcoinReceiver.construct_from(
|
54
|
+
customer: customer_id,
|
55
|
+
id: FIXTURE[:id]
|
56
|
+
)
|
57
|
+
assert_equal "/v1/customers/#{customer_id}/sources/#{FIXTURE[:id]}",
|
58
|
+
receiver.resource_url
|
59
|
+
end
|
60
|
+
|
61
|
+
should "return an absolute URL" do
|
62
|
+
receiver = Stripe::BitcoinReceiver.construct_from(
|
63
|
+
id: FIXTURE[:id]
|
64
|
+
)
|
65
|
+
assert_equal "/v1/bitcoin/receivers/#{FIXTURE[:id]}",
|
66
|
+
receiver.resource_url
|
67
|
+
end
|
59
68
|
end
|
60
69
|
end
|
61
70
|
end
|
@@ -2,28 +2,20 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class BitcoinTransactionTest < Test::Unit::TestCase
|
5
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:bitcoin_transaction)
|
6
6
|
|
7
|
-
should "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
receiver = Stripe::BitcoinTransaction.retrieve(TEST_ID)
|
13
|
-
assert_equal TEST_ID, receiver.id
|
7
|
+
should "be listable" do
|
8
|
+
transactions = Stripe::BitcoinTransaction.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/bitcoin/transactions"
|
10
|
+
assert transactions.data.kind_of?(Array)
|
11
|
+
assert transactions.first.kind_of?(Stripe::BitcoinTransaction)
|
14
12
|
end
|
15
13
|
|
16
|
-
should "
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
transactions = Stripe::BitcoinTransaction.list
|
22
|
-
assert_equal 3, transactions.data.length
|
23
|
-
assert transactions.data.kind_of? Array
|
24
|
-
transactions.each do |transaction|
|
25
|
-
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
26
|
-
end
|
14
|
+
should "be retrievable" do
|
15
|
+
transaction = Stripe::BitcoinTransaction.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get,
|
17
|
+
"#{Stripe.api_base}/v1/bitcoin/transactions/#{FIXTURE[:id]}"
|
18
|
+
assert transaction.kind_of?(Stripe::BitcoinTransaction)
|
27
19
|
end
|
28
20
|
end
|
29
21
|
end
|
data/test/stripe/charge_test.rb
CHANGED
@@ -2,117 +2,58 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class ChargeTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
@mock.expects(:get).once.returns(make_response(make_charge_array))
|
7
|
-
c = Stripe::Charge.list
|
8
|
-
assert c.data.kind_of? Array
|
9
|
-
c.each do |charge|
|
10
|
-
assert charge.kind_of?(Stripe::Charge)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
should "charges should be refundable" do
|
15
|
-
@mock.expects(:get).never
|
16
|
-
@mock.expects(:post).once.returns(make_response({:id => "ch_test_charge", :refunded => true}))
|
17
|
-
c = Stripe::Charge.new("test_charge")
|
18
|
-
c.refund
|
19
|
-
assert c.refunded
|
20
|
-
end
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:charge)
|
21
6
|
|
22
|
-
should "
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
7
|
+
should "be listable" do
|
8
|
+
charges = Stripe::Charge.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/charges"
|
10
|
+
assert charges.data.kind_of?(Array)
|
11
|
+
assert charges.data[0].kind_of?(Stripe::Charge)
|
28
12
|
end
|
29
13
|
|
30
|
-
should "
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
c.refresh
|
35
|
-
c.mnemonic = "New charge description"
|
36
|
-
c.save
|
14
|
+
should "be retrievable" do
|
15
|
+
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
17
|
+
assert charge.kind_of?(Stripe::Charge)
|
37
18
|
end
|
38
19
|
|
39
|
-
should "
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
20
|
+
should "be creatable" do
|
21
|
+
charge = Stripe::Charge.create(
|
22
|
+
amount: 100,
|
23
|
+
currency: "USD",
|
24
|
+
source: API_FIXTURES.fetch(:source)[:id]
|
25
|
+
)
|
26
|
+
assert_requested :post, "#{Stripe.api_base}/v1/charges"
|
27
|
+
assert charge.kind_of?(Stripe::Charge)
|
45
28
|
end
|
46
29
|
|
47
|
-
should "
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
c.mark_as_safe
|
30
|
+
should "be saveable" do
|
31
|
+
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
32
|
+
charge.metadata['key'] = 'value'
|
33
|
+
charge.save
|
34
|
+
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
53
35
|
end
|
54
36
|
|
55
|
-
should "
|
56
|
-
|
57
|
-
|
58
|
-
assert
|
37
|
+
should "be updateable" do
|
38
|
+
charge = Stripe::Charge.update(FIXTURE[:id], metadata: {foo: 'bar'})
|
39
|
+
assert_requested :post, "#{Stripe.api_base}/v1/charges/#{FIXTURE[:id]}"
|
40
|
+
assert charge.kind_of?(Stripe::Charge)
|
59
41
|
end
|
60
42
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
'card[exp_month]' => ['11']
|
68
|
-
}
|
69
|
-
end.once.returns(make_response(make_charge))
|
70
|
-
|
71
|
-
c = Stripe::Charge.create({
|
72
|
-
:amount => 100,
|
73
|
-
:card => {
|
74
|
-
:number => "4242424242424242",
|
75
|
-
:exp_month => 11,
|
76
|
-
:exp_year => 2012,
|
77
|
-
},
|
78
|
-
:currency => "usd"
|
79
|
-
})
|
80
|
-
assert c.paid
|
81
|
-
end
|
82
|
-
|
83
|
-
should "execute should return a new, fully executed charge when passed correct `source` parameters" do
|
84
|
-
@mock.expects(:post).with do |url, api_key, params|
|
85
|
-
url == "#{Stripe.api_base}/v1/charges" && api_key.nil? && CGI.parse(params) == {
|
86
|
-
'currency' => ['usd'], 'amount' => ['100'],
|
87
|
-
'source' => ['btcrcv_test_receiver']
|
88
|
-
}
|
89
|
-
end.once.returns(make_response(make_charge))
|
90
|
-
|
91
|
-
c = Stripe::Charge.create({
|
92
|
-
:amount => 100,
|
93
|
-
:source => 'btcrcv_test_receiver',
|
94
|
-
:currency => "usd"
|
95
|
-
})
|
96
|
-
assert c.paid
|
43
|
+
context "#mark_as_fraudulent" do
|
44
|
+
should "charges should be able to be marked as fraudulent" do
|
45
|
+
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
46
|
+
charge = charge.mark_as_fraudulent
|
47
|
+
assert charge.kind_of?(Stripe::Charge)
|
48
|
+
end
|
97
49
|
end
|
98
50
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
'level3[][one]' => ['fish'],
|
106
|
-
}
|
107
|
-
end.once.returns(make_response(make_charge))
|
108
|
-
|
109
|
-
c = Stripe::Charge.create({
|
110
|
-
:amount => 100,
|
111
|
-
:source => 'btcrcv_test_receiver',
|
112
|
-
:currency => "usd",
|
113
|
-
:level3 => [{:red => 'firstred'}, {:one => 'fish', :red => 'another'}]
|
114
|
-
})
|
115
|
-
assert c.paid
|
51
|
+
context "#mark_as_safe" do
|
52
|
+
should "charges should be able to be marked as safe" do
|
53
|
+
charge = Stripe::Charge.retrieve(FIXTURE[:id])
|
54
|
+
charge = charge.mark_as_safe
|
55
|
+
assert charge.kind_of?(Stripe::Charge)
|
56
|
+
end
|
116
57
|
end
|
117
58
|
end
|
118
59
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path('../../test_helper', __FILE__)
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
class CountrySpecTest < Test::Unit::TestCase
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:country_spec)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
c = Stripe::CountrySpec.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/country_specs"
|
10
|
+
assert c.data.kind_of?(Array)
|
11
|
+
assert c.data[0].kind_of?(Stripe::CountrySpec)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
s = Stripe::CountrySpec.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/country_specs/#{FIXTURE[:id]}"
|
17
|
+
assert(s.kind_of?(Stripe::CountrySpec))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/test/stripe/coupon_test.rb
CHANGED
@@ -2,19 +2,43 @@ require File.expand_path('../../test_helper', __FILE__)
|
|
2
2
|
|
3
3
|
module Stripe
|
4
4
|
class CouponTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
FIXTURE = API_FIXTURES.fetch(:coupon)
|
6
|
+
|
7
|
+
should "be listable" do
|
8
|
+
coupons = Stripe::Coupon.list
|
9
|
+
assert_requested :get, "#{Stripe.api_base}/v1/coupons"
|
10
|
+
assert coupons.data.kind_of?(Array)
|
11
|
+
assert coupons.first.kind_of?(Stripe::Coupon)
|
12
|
+
end
|
13
|
+
|
14
|
+
should "be retrievable" do
|
15
|
+
coupon = Stripe::Coupon.retrieve(FIXTURE[:id])
|
16
|
+
assert_requested :get, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
17
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "be creatable" do
|
21
|
+
coupon = Stripe::Coupon.create(
|
22
|
+
percent_off: 25,
|
23
|
+
duration: 'repeating',
|
24
|
+
duration_in_months: 3,
|
25
|
+
id: '25OFF'
|
26
|
+
)
|
27
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons"
|
28
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
29
|
+
end
|
30
|
+
|
31
|
+
should "be saveable" do
|
32
|
+
coupon = Stripe::Coupon.retrieve(FIXTURE[:id])
|
33
|
+
coupon.metadata['key'] = 'value'
|
34
|
+
coupon.save
|
35
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
9
36
|
end
|
10
37
|
|
11
|
-
should "
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
c.refresh
|
16
|
-
c.metadata['foo'] = 'bar'
|
17
|
-
c.save
|
38
|
+
should "be updateable" do
|
39
|
+
coupon = Stripe::Coupon.update(FIXTURE[:id], metadata: { key: 'value' })
|
40
|
+
assert_requested :post, "#{Stripe.api_base}/v1/coupons/#{FIXTURE[:id]}"
|
41
|
+
assert coupon.kind_of?(Stripe::Coupon)
|
18
42
|
end
|
19
43
|
end
|
20
44
|
end
|