Add parameters when calling pay on an invoice

This commit is contained in:
Olivier Bellone 2017-06-27 14:01:08 +02:00
parent 94f6f4c809
commit 78cd1d4f3d
2 changed files with 15 additions and 2 deletions

View File

@ -11,8 +11,8 @@ module Stripe
Util.convert_to_stripe_object(resp.data, opts) Util.convert_to_stripe_object(resp.data, opts)
end end
def pay(opts={}) def pay(params={}, opts={})
resp, opts = request(:post, pay_url, {}, opts) resp, opts = request(:post, pay_url, params, opts)
initialize_from(resp.data, opts) initialize_from(resp.data, opts)
end end

View File

@ -46,6 +46,19 @@ module Stripe
"#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}/pay" "#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}/pay"
assert invoice.kind_of?(Stripe::Invoice) assert invoice.kind_of?(Stripe::Invoice)
end end
should "pay invoice with a specific source" do
invoice = Stripe::Invoice.retrieve(FIXTURE[:id])
invoice = invoice.pay(
source: API_FIXTURES[:customer][:sources][:data][0][:id]
)
assert_requested :post,
"#{Stripe.api_base}/v1/invoices/#{FIXTURE[:id]}/pay",
body: {
source: API_FIXTURES[:customer][:sources][:data][0][:id]
}
assert invoice.kind_of?(Stripe::Invoice)
end
end end
context "#upcoming" do context "#upcoming" do