Skip to content

Commit

Permalink
Fix payment intent methods to take extra parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 28, 2018
1 parent 3a8f1d7 commit 44704e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
18 changes: 9 additions & 9 deletions lib/stripe/payment_intent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ class PaymentIntent < APIResource

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
8 changes: 6 additions & 2 deletions test/stripe/payment_intent_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 44704e9

Please sign in to comment.