diff --git a/lib/stripe/payment_intent.rb b/lib/stripe/payment_intent.rb index b9c8b30a6..ed0d1c54c 100644 --- a/lib/stripe/payment_intent.rb +++ b/lib/stripe/payment_intent.rb @@ -3,25 +3,24 @@ module Stripe class PaymentIntent < APIResource extend Stripe::APIOperations::Create - include Stripe::APIOperations::Delete extend Stripe::APIOperations::List include Stripe::APIOperations::Save OBJECT_NAME = "payment_intent".freeze - def cancel - resp, api_key = request(:post, resource_url + "/cancel") - initialize_from(resp.data, api_key) + def cancel(params = {}, opts = {}) + resp, opts = request(:post, resource_url + "/cancel", params, opts) + initialize_from(resp.data, opts) end - def capture - resp, api_key = request(:post, resource_url + "/capture") - initialize_from(resp.data, api_key) + def capture(params = {}, opts = {}) + resp, opts = request(:post, resource_url + "/capture", params, opts) + initialize_from(resp.data, opts) end - def confirm - resp, api_key = request(:post, resource_url + "/confirm") - initialize_from(resp.data, api_key) + def confirm(params = {}, opts = {}) + resp, opts = request(:post, resource_url + "/confirm", params, opts) + initialize_from(resp.data, opts) end end end diff --git a/test/stripe/payment_intent_test.rb b/test/stripe/payment_intent_test.rb index a591a2088..70b7e02e9 100644 --- a/test/stripe/payment_intent_test.rb +++ b/test/stripe/payment_intent_test.rb @@ -56,7 +56,9 @@ class PaymentIntentTest < Test::Unit::TestCase context "#capture" do should "capture a payment_intent" do payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent") - payment_intent = payment_intent.capture + payment_intent = payment_intent.capture( + amount_to_capture: 1234 + ) assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/capture" assert payment_intent.is_a?(Stripe::PaymentIntent) @@ -66,7 +68,9 @@ class PaymentIntentTest < Test::Unit::TestCase context "#confirm" do should "confirm a payment_intent" do payment_intent = Stripe::PaymentIntent.construct_from(id: "pi_123", object: "payment_intent") - payment_intent = payment_intent.confirm + payment_intent = payment_intent.confirm( + source: "src_123" + ) assert_requested :post, "#{Stripe.api_base}/v1/payment_intents/pi_123/confirm" assert payment_intent.is_a?(Stripe::PaymentIntent)