Move payment_intent to Helper

This commit is contained in:
Neal Chambers
2023-11-07 11:17:36 +09:00
parent 31fda7169d
commit af764bd38e
4 changed files with 17 additions and 24 deletions

View File

@@ -184,6 +184,7 @@ RSpec.configure do |config|
config.include Rails.application.routes.url_helpers
config.include Spree::UrlHelpers
config.include Spree::MoneyHelper
config.include Spree::PaymentHelper
config.include PreferencesHelper
config.include OpenFoodNetwork::FiltersHelper
config.include OpenFoodNetwork::EnterpriseGroupsHelper

View File

@@ -95,15 +95,4 @@ describe Spree::Gateway::StripeSCA, type: :model do
expect(subject.external_payment_url(order:)).to eq "http://stripe-test.org"
end
end
private
def payment_intent(amount, status)
JSON.generate(
object: "payment_intent",
amount:,
status:,
charges: { data: [{ id: "ch_1234", amount: }] }
)
end
end

View File

@@ -1128,17 +1128,4 @@ describe Spree::Payment do
expect(payment.captured_at).to be_present
end
end
private
def payment_intent(amount, status)
JSON.generate(
object: "payment_intent",
amount:,
status:,
charges: { data: [{ id: "ch_1234", amount: }] },
id: "12345",
livemode: false
)
end
end

View File

@@ -0,0 +1,16 @@
# frozen_string_literal: true
module Spree
module PaymentHelper
def payment_intent(amount, status)
JSON.generate(
object: "payment_intent",
amount:,
status:,
charges: { data: [{ id: "ch_1234", amount: }] },
id: "12345",
livemode: false
)
end
end
end