Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Issuing Dispute Submit API #944

Merged
merged 2 commits into from Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,7 @@ sudo: false
env:
global:
# If changing this number, please also change it in `test/test_helper.rb`.
- STRIPE_MOCK_VERSION=0.95.0
- STRIPE_MOCK_VERSION=0.98.0

cache:
directories:
Expand Down
11 changes: 11 additions & 0 deletions lib/stripe/resources/issuing/dispute.rb
Expand Up @@ -9,6 +9,17 @@ class Dispute < APIResource
include Stripe::APIOperations::Save

OBJECT_NAME = "issuing.dispute"

custom_method :submit, http_verb: :post

def submit(params = {}, opts = {})
request_stripe_object(
method: :post,
path: resource_url + "/submit",
params: params,
opts: opts
)
end
end
end
end
14 changes: 7 additions & 7 deletions test/stripe/api_resource_test.rb
Expand Up @@ -111,15 +111,15 @@ class NestedTestAPIResource < APIResource
end

should "send expand when fetching through ListObject" do
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
.to_return(body: JSON.generate(customer_fixture))
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123")
.to_return(body: JSON.generate(charge_fixture))

stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123/sources/cc_test_card")
.with(query: { "expand" => ["customer"] })
.to_return(body: JSON.generate(customer_fixture))
stub_request(:get, "#{Stripe.api_base}/v1/charges/ch_123/refunds/re_123")
.with(query: { "expand" => ["balance_transaction"] })
.to_return(body: JSON.generate(charge_fixture))

customer = Stripe::Customer.retrieve("cus_123")
customer.sources.retrieve(id: "cc_test_card", expand: [:customer])
charge = Stripe::Charge.retrieve("ch_123")
charge.refunds.retrieve(id: "re_123", expand: [:balance_transaction])
end

context "when specifying per-object credentials" do
Expand Down
6 changes: 6 additions & 0 deletions test/stripe/customer_card_test.rb
Expand Up @@ -5,6 +5,12 @@
module Stripe
class CustomerCardTest < Test::Unit::TestCase
setup do
# Unfortunately, the OpenAPI spec has an issue where the sources list has the wrong
# url so we need to mock this call instead.
customer_json = { id: "cus_123", object: "customer", sources: { object: "list", data: [], has_more: true, url: "/v1/customers/cus_123/sources" } }
stub_request(:get, "#{Stripe.api_base}/v1/customers/cus_123")
.to_return(body: JSON.generate(customer_json))

@customer = Stripe::Customer.retrieve("cus_123")
end

Expand Down
21 changes: 20 additions & 1 deletion test/stripe/issuing/dispute_test.rb
Expand Up @@ -6,7 +6,7 @@ module Stripe
module Issuing
class DisputeTest < Test::Unit::TestCase
should "be creatable" do
dispute = Stripe::Issuing::Dispute.create
dispute = Stripe::Issuing::Dispute.create(transaction: "ipi_123")

assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes"
assert dispute.is_a?(Stripe::Issuing::Dispute)
Expand All @@ -30,6 +30,25 @@ class DisputeTest < Test::Unit::TestCase
assert_requested :post, "#{Stripe.api_base}/v1/issuing/disputes/ich_123"
assert dispute.is_a?(Stripe::Issuing::Dispute)
end

context "#submit" do
should "submit the dispute" do
dispute = Stripe::Issuing::Dispute.retrieve("idp_123")
dispute = dispute.submit
assert_requested :post,
"#{Stripe.api_base}/v1/issuing/disputes/idp_123/submit"
assert dispute.is_a?(Stripe::Issuing::Dispute)
end
end

context ".submit" do
should "submit the dispute" do
dispute = Stripe::Issuing::Dispute.submit("idp_123")
assert_requested :post,
"#{Stripe.api_base}/v1/issuing/disputes/idp_123/submit"
assert dispute.is_a?(Stripe::Issuing::Dispute)
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/test_helper.rb
Expand Up @@ -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.95.0"
MOCK_MINIMUM_VERSION = "0.98.0"
MOCK_PORT = Stripe::StripeMock.start

# Disable all real network connections except those that are outgoing to
Expand Down