Support AlipayAccount retrieval and deletion

This commit is contained in:
Remi Jannel 2016-05-17 17:52:00 -04:00
parent 49382f7ac2
commit 2a6673a8e5
4 changed files with 29 additions and 0 deletions

View File

@ -53,6 +53,7 @@ require 'stripe/dispute'
require 'stripe/product'
require 'stripe/sku'
require 'stripe/order'
require 'stripe/alipay_account'
# Errors
require 'stripe/errors/stripe_error'

View File

@ -0,0 +1,16 @@
module Stripe
class AlipayAccount < APIResource
include Stripe::APIOperations::Update
include Stripe::APIOperations::Delete
def resource_url
if respond_to?(:customer) && !self.customer.nil?
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
end
end
def self.retrieve(id, opts=nil)
raise NotImplementedError.new("Alipay accounts cannot be retrieved without a customer ID. Retrieve an Alipay account using customer.sources.retrieve('alipay_account_id')")
end
end
end

View File

@ -24,6 +24,7 @@ module Stripe
# business objects
'account' => Account,
'alipay_account' => AlipayAccount,
'application_fee' => ApplicationFee,
'balance' => Balance,
'balance_transaction' => BalanceTransaction,

View File

@ -0,0 +1,11 @@
require File.expand_path('../../test_helper', __FILE__)
module Stripe
class AlipayAccountTest < Test::Unit::TestCase
should "raise if accessing Stripe::Alipay.account directly" do
assert_raises NotImplementedError do
Stripe::AlipayAccount.retrieve "card_12345"
end
end
end
end