-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #334 from solidusio/nebulab/rainerd+elia/add-payme…
…nt-info-partial-handling Add partial handling of payment information for payment provider custom integrations.
- Loading branch information
Showing
6 changed files
with
44 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckoutHelper | ||
def partial_name_with_fallback(prefix, partial_name, fallback_name = 'default') | ||
if lookup_context.find_all("#{prefix}/_#{partial_name}").any? | ||
"#{prefix}/#{partial_name}" | ||
else | ||
"#{prefix}/#{fallback_name}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= t('spree.check') %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= payment.payment_method.name %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% source = payment.source %> | ||
|
||
<% if source.last_digits %> | ||
<%= t('spree.ending_in') %> <%= source.last_digits %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'solidus_starter_frontend_spec_helper' | ||
|
||
RSpec.describe CheckoutHelper, type: :helper do | ||
describe '#partial_name_with_fallback' do | ||
it "uses the partial_name if it exists" do | ||
expect( | ||
partial_name_with_fallback('orders/payment_info', 'gateway', 'default') | ||
).to eq('orders/payment_info/gateway') | ||
end | ||
|
||
it "uses the fallback_name if it's missing" do | ||
expect( | ||
partial_name_with_fallback('orders/payment_info', 'foo', 'default') | ||
).to eq('orders/payment_info/default') | ||
end | ||
end | ||
end |