diff --git a/.travis.yml b/.travis.yml index d594cd483..0d23b5dec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ sudo: false env: global: # If changing this number, please also change it in `test/test_helper.rb`. - - STRIPE_MOCK_VERSION=0.72.0 + - STRIPE_MOCK_VERSION=0.76.0 cache: directories: diff --git a/lib/stripe/resources/credit_note.rb b/lib/stripe/resources/credit_note.rb index 91c3b1f70..6b82db693 100644 --- a/lib/stripe/resources/credit_note.rb +++ b/lib/stripe/resources/credit_note.rb @@ -18,5 +18,10 @@ def void_credit_note(params = {}, opts = {}) opts: opts ) end + + def self.preview(params, opts = {}) + resp, opts = request(:get, resource_url + "/preview", params, opts) + Util.convert_to_stripe_object(resp.data, opts) + end end end diff --git a/test/stripe/credit_note_test.rb b/test/stripe/credit_note_test.rb index b79d17e4b..69c1db311 100644 --- a/test/stripe/credit_note_test.rb +++ b/test/stripe/credit_note_test.rb @@ -40,6 +40,21 @@ class CreditNoteTest < Test::Unit::TestCase assert credit_note.is_a?(Stripe::CreditNote) end + context ".preview" do + should "preview a credit note" do + invoice = Stripe::CreditNote.preview( + invoice: "in_123", + amount: 500 + ) + assert_requested :get, "#{Stripe.api_base}/v1/credit_notes/preview", + query: { + invoice: "in_123", + amount: 500, + } + assert invoice.is_a?(Stripe::CreditNote) + end + end + context "#void_credit_note" do should "void credit_note" do credit_note = Stripe::CreditNote.retrieve("cn_123") diff --git a/test/test_helper.rb b/test/test_helper.rb index 5a625a19d..04ab52eef 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -16,7 +16,7 @@ require ::File.expand_path("stripe_mock", __dir__) # If changing this number, please also change it in `.travis.yml`. -MOCK_MINIMUM_VERSION = "0.72.0" +MOCK_MINIMUM_VERSION = "0.76.0" MOCK_PORT = Stripe::StripeMock.start # Disable all real network connections except those that are outgoing to