Support for Stripe::CountrySpec

This commit is contained in:
Ioannis Kolovos 2016-02-06 16:55:29 +02:00
parent 3a258806a2
commit f8532d225e
5 changed files with 118 additions and 1 deletions

View File

@ -32,6 +32,7 @@ require 'stripe/customer'
require 'stripe/invoice'
require 'stripe/invoice_item'
require 'stripe/charge'
require 'stripe/country_spec'
require 'stripe/plan'
require 'stripe/file_upload'
require 'stripe/coupon'

View File

@ -0,0 +1,10 @@
module Stripe
class CountrySpec < APIResource
extend Stripe::APIOperations::List
def self.url
'/v1/country_specs'
end
end
end

View File

@ -30,6 +30,7 @@ module Stripe
'bank_account' => BankAccount,
'card' => Card,
'charge' => Charge,
'country_spec' => CountrySpec,
'coupon' => Coupon,
'customer' => Customer,
'event' => Event,

View 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

View File

@ -164,7 +164,6 @@ module Stripe
}
end
def make_dispute(params={})
id = params[:id] || 'dp_test_dispute'
{
@ -672,5 +671,68 @@ module Stripe
:charge => make_charge,
}).merge(params)
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