mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
DRY StripeHelper methods
This commit is contained in:
@@ -34,17 +34,18 @@ module StripeHelper
|
||||
end
|
||||
|
||||
def stub_successful_capture_request(order:, response: {})
|
||||
stub_request(:post, "https://api.stripe.com/v1/payment_intents/pi_123/capture")
|
||||
.with(body: { amount_to_capture: Spree::Money.new(order.total).cents },
|
||||
headers: { 'Stripe-Account' => 'abc123' })
|
||||
.to_return(payment_successful_capture_mock(response))
|
||||
stub_capture_request(order, payment_successful_capture_mock(response))
|
||||
end
|
||||
|
||||
def stub_failed_capture_request(order:, response: {})
|
||||
stub_capture_request(order, payment_failed_capture_mock(response))
|
||||
end
|
||||
|
||||
def stub_capture_request(order, response_mock)
|
||||
stub_request(:post, "https://api.stripe.com/v1/payment_intents/pi_123/capture")
|
||||
.with(body: { amount_to_capture: Spree::Money.new(order.total).cents },
|
||||
headers: { 'Stripe-Account' => 'abc123' })
|
||||
.to_return(payment_failed_capture_mock(response))
|
||||
.to_return(response_mock)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user