mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-09 00:03:05 -04:00
commit
b2d74b09ff
@ -32,6 +32,7 @@ require 'stripe/customer'
|
|||||||
require 'stripe/invoice'
|
require 'stripe/invoice'
|
||||||
require 'stripe/invoice_item'
|
require 'stripe/invoice_item'
|
||||||
require 'stripe/charge'
|
require 'stripe/charge'
|
||||||
|
require 'stripe/country_spec'
|
||||||
require 'stripe/plan'
|
require 'stripe/plan'
|
||||||
require 'stripe/file_upload'
|
require 'stripe/file_upload'
|
||||||
require 'stripe/coupon'
|
require 'stripe/coupon'
|
||||||
|
10
lib/stripe/country_spec.rb
Normal file
10
lib/stripe/country_spec.rb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module Stripe
|
||||||
|
class CountrySpec < APIResource
|
||||||
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
|
def self.url
|
||||||
|
'/v1/country_specs'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -30,6 +30,7 @@ module Stripe
|
|||||||
'bank_account' => BankAccount,
|
'bank_account' => BankAccount,
|
||||||
'card' => Card,
|
'card' => Card,
|
||||||
'charge' => Charge,
|
'charge' => Charge,
|
||||||
|
'country_spec' => CountrySpec,
|
||||||
'coupon' => Coupon,
|
'coupon' => Coupon,
|
||||||
'customer' => Customer,
|
'customer' => Customer,
|
||||||
'event' => Event,
|
'event' => Event,
|
||||||
|
43
test/stripe/country_spec_test.rb
Normal file
43
test/stripe/country_spec_test.rb
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
require File.expand_path('../../test_helper', __FILE__)
|
||||||
|
|
||||||
|
module Stripe
|
||||||
|
class CountrySpecTest < Test::Unit::TestCase
|
||||||
|
should "be listable" do
|
||||||
|
@mock.expects(:get).once.
|
||||||
|
returns(make_response(country_spec_array))
|
||||||
|
c = Stripe::CountrySpec.list
|
||||||
|
|
||||||
|
assert_equal('/v1/country_specs', c.url)
|
||||||
|
assert_equal('list', c.object)
|
||||||
|
assert(c.data.kind_of?(Array))
|
||||||
|
assert_equal('US', c.data[0].id)
|
||||||
|
assert(c.data[0].kind_of?(Stripe::CountrySpec))
|
||||||
|
end
|
||||||
|
|
||||||
|
should "be retrievable" do
|
||||||
|
resp = make_country_spec
|
||||||
|
@mock.expects(:get).once.
|
||||||
|
with('https://api.stripe.com/v1/country_specs/US', nil, nil).
|
||||||
|
returns(make_response(resp))
|
||||||
|
s = Stripe::CountrySpec.retrieve('US')
|
||||||
|
|
||||||
|
assert_equal('/v1/country_specs/US', s.url)
|
||||||
|
assert_equal('country_spec', s.object)
|
||||||
|
assert(s.kind_of?(Stripe::CountrySpec))
|
||||||
|
|
||||||
|
s.supported_bank_account_currencies.map{ |k,v| assert v.kind_of?(Array) }
|
||||||
|
assert_equal(['US'], s.supported_bank_account_currencies['usd'])
|
||||||
|
assert(s.supported_payment_currencies.include?('usd'))
|
||||||
|
assert s.supported_payment_currencies.kind_of?(Array)
|
||||||
|
assert s.supported_payment_methods.kind_of?(Array)
|
||||||
|
|
||||||
|
['individual', 'company'].map{ |type|
|
||||||
|
item = s.verification_fields[type]
|
||||||
|
assert item.minimum.include?('external_account')
|
||||||
|
assert item.additional.include?('legal_entity.verification.document')
|
||||||
|
assert item.additional.kind_of?(Array)
|
||||||
|
assert item.minimum.kind_of?(Array)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -164,7 +164,6 @@ module Stripe
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def make_dispute(params={})
|
def make_dispute(params={})
|
||||||
id = params[:id] || 'dp_test_dispute'
|
id = params[:id] || 'dp_test_dispute'
|
||||||
{
|
{
|
||||||
@ -672,5 +671,68 @@ module Stripe
|
|||||||
:charge => make_charge,
|
:charge => make_charge,
|
||||||
}).merge(params)
|
}).merge(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def country_spec_array
|
||||||
|
{
|
||||||
|
:object => "list",
|
||||||
|
:url => "/v1/country_specs",
|
||||||
|
:data => [
|
||||||
|
make_country_spec,
|
||||||
|
make_country_spec,
|
||||||
|
make_country_spec,
|
||||||
|
]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def make_country_spec(params={})
|
||||||
|
{
|
||||||
|
:id=> "US",
|
||||||
|
:object=> "country_spec",
|
||||||
|
:supported_bank_account_currencies=> {
|
||||||
|
:usd => ["US"]
|
||||||
|
},
|
||||||
|
:supported_payment_currencies=>
|
||||||
|
[
|
||||||
|
"usd", "aed", "afn", "all"
|
||||||
|
],
|
||||||
|
:supported_payment_methods=>
|
||||||
|
[
|
||||||
|
"alipay", "card", "stripe"
|
||||||
|
],
|
||||||
|
:verification_fields=>
|
||||||
|
{
|
||||||
|
:individual=>
|
||||||
|
{
|
||||||
|
:minimum=>
|
||||||
|
[
|
||||||
|
"external_account",
|
||||||
|
"legal_entity.address.city",
|
||||||
|
"tos_acceptance.date",
|
||||||
|
"tos_acceptance.ip"
|
||||||
|
],
|
||||||
|
:additional=>
|
||||||
|
[
|
||||||
|
"legal_entity.personal_id_number",
|
||||||
|
"legal_entity.verification.document"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
:company=>
|
||||||
|
{
|
||||||
|
:minimum=>
|
||||||
|
[
|
||||||
|
"external_account",
|
||||||
|
"legal_entity.address.city",
|
||||||
|
"legal_entity.address.line1",
|
||||||
|
"tos_acceptance.ip"
|
||||||
|
],
|
||||||
|
:additional=>
|
||||||
|
[
|
||||||
|
"legal_entity.personal_id_number",
|
||||||
|
"legal_entity.verification.document"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.merge(params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user