From 977f0005a8b10a7490d63e6a43cd5041d624f371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Bonis=C5=82awski?= Date: Tue, 23 Jan 2018 13:46:27 +0100 Subject: [PATCH 01/11] add support for stripe elements --- .../spree/checkout/payment/_stripe.html.erb | 209 ++++++++++++------ 1 file changed, 143 insertions(+), 66 deletions(-) diff --git a/lib/views/frontend/spree/checkout/payment/_stripe.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe.html.erb index 245edf35..3ec73301 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe.html.erb @@ -1,81 +1,158 @@ <%= render "spree/checkout/payment/gateway", payment_method: payment_method %> +<% param_prefix = "payment_source[#{payment_method.id}]" %> - + <%- if @order.has_checkout_step?('address') -%> From bfbf53991d6963fe437b4d3960679ec8d04c91a3 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Wed, 11 Jul 2018 13:31:03 +0200 Subject: [PATCH 02/11] Extract Spree Elements to a seperate gateway --- .../spree/gateway/stripe_elements_gateway.rb | 7 + lib/spree_gateway/engine.rb | 1 + .../spree/checkout/payment/_stripe.html.erb | 223 ++++++------------ .../payment/_stripe_additional_info.html.erb | 13 + .../payment/_stripe_elements.html.erb | 104 ++++++++ 5 files changed, 192 insertions(+), 156 deletions(-) create mode 100644 app/models/spree/gateway/stripe_elements_gateway.rb create mode 100644 lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb create mode 100644 lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb diff --git a/app/models/spree/gateway/stripe_elements_gateway.rb b/app/models/spree/gateway/stripe_elements_gateway.rb new file mode 100644 index 00000000..f8f935be --- /dev/null +++ b/app/models/spree/gateway/stripe_elements_gateway.rb @@ -0,0 +1,7 @@ +module Spree + class Gateway::StripeElementsGateway < Gateway::StripeGateway + def method_type + 'stripe_elements' + end + end +end diff --git a/lib/spree_gateway/engine.rb b/lib/spree_gateway/engine.rb index 1b3f39b4..4b18e343 100644 --- a/lib/spree_gateway/engine.rb +++ b/lib/spree_gateway/engine.rb @@ -30,6 +30,7 @@ class Engine < Rails::Engine app.config.spree.payment_methods << Spree::Gateway::SecurePayAU app.config.spree.payment_methods << Spree::Gateway::SpreedlyCoreGateway app.config.spree.payment_methods << Spree::Gateway::StripeGateway + app.config.spree.payment_methods << Spree::Gateway::StripeElementsGateway app.config.spree.payment_methods << Spree::Gateway::UsaEpayTransaction app.config.spree.payment_methods << Spree::Gateway::Worldpay end diff --git a/lib/views/frontend/spree/checkout/payment/_stripe.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe.html.erb index 3ec73301..b1b82772 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe.html.erb @@ -1,170 +1,81 @@ <%= render "spree/checkout/payment/gateway", payment_method: payment_method %> -<% param_prefix = "payment_source[#{payment_method.id}]" %> - + -<%- if @order.has_checkout_step?('address') -%> - -<%- end -%> +<%= render 'spree/checkout/payment/stripe_additional_info' %> \ No newline at end of file diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb new file mode 100644 index 00000000..80d15dd6 --- /dev/null +++ b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb @@ -0,0 +1,13 @@ +<%- if @order.has_checkout_step?('address') -%> + +<%- end -%> \ No newline at end of file diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb new file mode 100644 index 00000000..b1c59466 --- /dev/null +++ b/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb @@ -0,0 +1,104 @@ +<% param_prefix = "payment_source[#{payment_method.id}]" %> +
+

+ <%= label_tag "name_on_card_#{payment_method.id}" do %> + <%= Spree.t(:name_on_card) %>* + <% end %> + <%= text_field_tag "#{param_prefix}[name]", "#{@order.bill_address_firstname} #{@order.bill_address_lastname}", { id: "name_on_card_#{payment_method.id}", class: 'form-control required'} %> +

+
+ <%= label_tag "card_number" do %> + <%= Spree.t(:card_number) %>* + <% end %> +
+
+ +
+
+ + +
+

+
+ + + + + +<%= render 'spree/checkout/payment/stripe_additional_info' %> From b67d336a3f34f882799731229a49a543601f16f0 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Fri, 13 Jul 2018 16:23:55 +0200 Subject: [PATCH 03/11] Add Apple Pay / Payment Request API support (WIP) --- .../spree/gateway/stripe_apple_pay_gateway.rb | 10 ++ config/routes.rb | 6 ++ ...pple_pay_domain_verification_controller.rb | 12 +++ lib/spree_gateway/engine.rb | 1 + .../payment/_stripe_apple_pay.html.erb | 92 +++++++++++++++++++ .../payment/_stripe_elements.html.erb | 28 +++--- 6 files changed, 135 insertions(+), 14 deletions(-) create mode 100644 app/models/spree/gateway/stripe_apple_pay_gateway.rb create mode 100644 config/routes.rb create mode 100644 lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb create mode 100644 lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb diff --git a/app/models/spree/gateway/stripe_apple_pay_gateway.rb b/app/models/spree/gateway/stripe_apple_pay_gateway.rb new file mode 100644 index 00000000..8670d990 --- /dev/null +++ b/app/models/spree/gateway/stripe_apple_pay_gateway.rb @@ -0,0 +1,10 @@ +module Spree + class Gateway::StripeApplePayGateway < Gateway::StripeGateway + preference :country_code, :string, default: 'US' + preference :domain_verification_certificate, :string + + def method_type + 'stripe_apple_pay' + end + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 00000000..abd5a0a7 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,6 @@ +# we need to add this route to the root Rails application because Spree can +# be mounted to some path eg. /shop and Apple Pay expects to access this file +# via https://example.com/.well-known/apple-developer-merchantid-domain-association +Rails.application.routes.draw do + get '/.well-known/apple-developer-merchantid-domain-association' => 'spree/apple_pay_domain_verification#show' +end \ No newline at end of file diff --git a/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb b/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb new file mode 100644 index 00000000..248eca5f --- /dev/null +++ b/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb @@ -0,0 +1,12 @@ +module Spree + class ApplePayDomainVerificationController < StoreController + skip_before_action :set_current_order, only: :show + include Spree::Core::ControllerHelpers + + def show + gateway = Gateway.active.find_by!(type: 'Spree::Gateway::StripeApplePayGateway') + + render plain: gateway.preferred_domain_verification_certificate + end + end +end \ No newline at end of file diff --git a/lib/spree_gateway/engine.rb b/lib/spree_gateway/engine.rb index 4b18e343..505bb59c 100644 --- a/lib/spree_gateway/engine.rb +++ b/lib/spree_gateway/engine.rb @@ -31,6 +31,7 @@ class Engine < Rails::Engine app.config.spree.payment_methods << Spree::Gateway::SpreedlyCoreGateway app.config.spree.payment_methods << Spree::Gateway::StripeGateway app.config.spree.payment_methods << Spree::Gateway::StripeElementsGateway + app.config.spree.payment_methods << Spree::Gateway::StripeApplePayGateway app.config.spree.payment_methods << Spree::Gateway::UsaEpayTransaction app.config.spree.payment_methods << Spree::Gateway::Worldpay end diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb new file mode 100644 index 00000000..06987106 --- /dev/null +++ b/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb @@ -0,0 +1,92 @@ +<% param_prefix = "payment_source[#{payment_method.id}]" %> + +
+ +
+ + + + + +<%= render 'spree/checkout/payment/stripe_additional_info' %> diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb index b1c59466..f0baf44f 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe_elements.html.erb @@ -25,8 +25,8 @@ -<%= render 'spree/checkout/payment/stripe_additional_info' %> \ No newline at end of file +<%= render 'spree/checkout/payment/stripe_additional_info', bill_address: @order.bill_address %> diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb index 80d15dd6..9f58a7da 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb @@ -1,13 +1,13 @@ <%- if @order.has_checkout_step?('address') -%> -<%- end -%> \ No newline at end of file +<%- end -%> diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb index 06987106..aa2e4485 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe_apple_pay.html.erb @@ -18,25 +18,25 @@ <% @order.line_items.each do |line_item| %> { label: '<%= line_item.name %> x <%= line_item.quantity %>', - amount: <%= line_item.total.to_d * 100 %> + amount: <%= Spree::Money.new(line_item.total, currency: line_item.currency).amount_in_cents %> }, <% end %> <% if @order.tax_total != 0 %> { label: '<%= Spree.t(:tax) %>', - amount: <%= @order.tax_total.to_d * 100 %> + amount: <%= Spree::Money.new(@order.tax_total, currency: @order.currency).amount_in_cents %> }, <% end %> <% if @order.shipment_total != 0 %> { label: '<%= Spree.t(:shipment) %>', - amount: <%= @order.shipment_total.to_d * 100 %> + amount: <%= Spree::Money.new(@order.shipment_total, currency: @order.currency).amount_in_cents %> } <% end %> ], total: { label: '<%= Spree.t(:total) %>', - amount: <%= @order.total.to_d * 100 %>, // FIXME: support yen and other currerncies + amount: <%= Spree::Money.new(@order.total, currency: @order.currency).amount_in_cents %> }, requestPayerName: true, requestPayerEmail: true, diff --git a/spec/controllers/spree/apple_pay_domain_verification_spec.rb b/spec/controllers/spree/apple_pay_domain_verification_spec.rb new file mode 100644 index 00000000..d2643b14 --- /dev/null +++ b/spec/controllers/spree/apple_pay_domain_verification_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe Spree::ApplePayDomainVerificationController do + let(:domain_verification_certificate) { FFaker::Lorem.characters(20) } + let!(:stripe_apple_pay_payment_method) do + Spree::Gateway::StripeApplePayGateway.create!( + name: 'ApplePay', + preferred_domain_verification_certificate: domain_verification_certificate + ) + end + + context '#show' do + it 'renders domain verification certificate' do + get :show + expect(response.body).to eq domain_verification_certificate + end + end +end diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb new file mode 100644 index 00000000..09258dd7 --- /dev/null +++ b/spec/models/spree/order_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' + +describe Spree::Order do + let(:order_one) { OrderWalkthrough.up_to(:payment) } + let(:order_two) { OrderWalkthrough.up_to(:payment) } + let(:stripe_apple_pay_payment_method) do + Spree::Gateway::StripeApplePayGateway.create!( + name: 'ApplePay', + preferred_domain_verification_certificate: FFaker::Lorem.characters(20) + ) + end + let(:stripe_credit_card_payment_method) do + Spree::Gateway::StripeGateway.create!( + name: 'CreditCard', + preferred_secret_key: FFaker::Lorem.characters(20), + preferred_publishable_key: FFaker::Lorem.characters(20) + ) + end + + before do + order_one.payments.create(payment_method_id: stripe_apple_pay_payment_method.id, + amount: 29.99, + state: 'completed') + order_two.payments.create(payment_method_id: stripe_credit_card_payment_method.id, + amount: 29.99, + state: 'completed') + order_one.update_totals + order_two.update_totals + end + + describe '#paid_with_apple_pay?' do + context 'when an order was paid with Apply Pay' do + it 'returns true' do + expect(order_one.paid_with_apple_pay?).to eq true + end + end + + context 'when an order was paid with Credit Card' do + it 'returns false' do + expect(order_two.paid_with_apple_pay?).to eq false + end + end + end + + describe '#confirmation_required?' do + context 'when an order was paid with Apply Pay' do + it 'returns false' do + expect(order_one.confirmation_required?).to eq false + end + end + + context 'when an order was paid with Credit Card' do + it 'returns true' do + expect(order_two.confirmation_required?).to eq true + end + end + end + + context 'when an order was paid with Apply Pay' do + it 'proceeds to Complete order state' do + order_one.next + + expect(order_one.state).to eq 'complete' + end + end + + context 'when an order was paid with Credit Card' do + it 'proceeds to Confirm order state' do + order_two.next + + expect(order_two.state).to eq 'confirm' + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ca2ed3fe..8ceead72 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -24,6 +24,9 @@ FactoryBot.find_definitions +require 'spree/order_decorator.rb' +require 'spree/payment_decorator.rb' + RSpec.configure do |config| config.infer_spec_type_from_file_location! config.mock_with :rspec do |mock| From 4c8d24647ab74f3628f4991176cd499195290466 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Sun, 9 Dec 2018 09:29:04 +0100 Subject: [PATCH 05/11] require pry in spec helper --- spec/spec_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8ceead72..30405f3f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,7 @@ require 'database_cleaner' require 'ffaker' require 'rspec/active_model/mocks' +require 'pry' Dir[File.join(File.dirname(__FILE__), "support", "**", "*.rb")].each { |f| require f } From 5535f853c6990ca527c50c9873c291ed8e9d71d7 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Sun, 9 Dec 2018 09:29:22 +0100 Subject: [PATCH 06/11] Fixed Order Spec for Spree 3.7/4.0 support --- spec/models/spree/order_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 09258dd7..f67ebfb5 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -18,6 +18,9 @@ end before do + Spree::Config[:always_include_confirm_step] = true + allow_any_instance_of(Spree::PaymentMethod).to receive(:source_required?).and_return(false) + order_one.payments.create(payment_method_id: stripe_apple_pay_payment_method.id, amount: 29.99, state: 'completed') From 618a9b6e6ecc08cf08152a79a1293fae647d2da1 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Sun, 9 Dec 2018 09:37:43 +0100 Subject: [PATCH 07/11] Moved ApplePayDomainVerification controller out of Frontend scope This change will allow to use this in applications not using the default Spree frontend. Also rewritten controller specs to request specs. --- ...pple_pay_domain_verification_controller.rb | 12 ----------- ...pple_pay_domain_verification_controller.rb | 9 ++++++++ lib/spree_gateway/engine.rb | 3 ++- .../apple_pay_domain_verification_spec.rb | 18 ---------------- spec/requests/apple_domain_verification.rb | 21 +++++++++++++++++++ 5 files changed, 32 insertions(+), 31 deletions(-) delete mode 100644 lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb create mode 100644 lib/controllers/spree/apple_pay_domain_verification_controller.rb delete mode 100644 spec/controllers/spree/apple_pay_domain_verification_spec.rb create mode 100644 spec/requests/apple_domain_verification.rb diff --git a/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb b/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb deleted file mode 100644 index fcf4c9a7..00000000 --- a/lib/controllers/frontend/spree/apple_pay_domain_verification_controller.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Spree - class ApplePayDomainVerificationController < StoreController - skip_before_action :set_current_order, only: :show - include Spree::Core::ControllerHelpers - - def show - gateway = Spree::Gateway::StripeApplePayGateway.active.first - - render plain: gateway.preferred_domain_verification_certificate - end - end -end diff --git a/lib/controllers/spree/apple_pay_domain_verification_controller.rb b/lib/controllers/spree/apple_pay_domain_verification_controller.rb new file mode 100644 index 00000000..eed64811 --- /dev/null +++ b/lib/controllers/spree/apple_pay_domain_verification_controller.rb @@ -0,0 +1,9 @@ +module Spree + class ApplePayDomainVerificationController < Spree::BaseController + def show + gateway = Spree::Gateway::StripeApplePayGateway.active.last + + render plain: gateway.preferred_domain_verification_certificate + end + end +end diff --git a/lib/spree_gateway/engine.rb b/lib/spree_gateway/engine.rb index 505bb59c..d75e160d 100644 --- a/lib/spree_gateway/engine.rb +++ b/lib/spree_gateway/engine.rb @@ -60,8 +60,9 @@ def self.frontend_available? paths["app/views"] << "lib/views/backend" end + paths['app/controllers'] << 'lib/controllers' + if self.frontend_available? - paths["app/controllers"] << "lib/controllers/frontend" paths["app/views"] << "lib/views/frontend" end diff --git a/spec/controllers/spree/apple_pay_domain_verification_spec.rb b/spec/controllers/spree/apple_pay_domain_verification_spec.rb deleted file mode 100644 index d2643b14..00000000 --- a/spec/controllers/spree/apple_pay_domain_verification_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'spec_helper' - -describe Spree::ApplePayDomainVerificationController do - let(:domain_verification_certificate) { FFaker::Lorem.characters(20) } - let!(:stripe_apple_pay_payment_method) do - Spree::Gateway::StripeApplePayGateway.create!( - name: 'ApplePay', - preferred_domain_verification_certificate: domain_verification_certificate - ) - end - - context '#show' do - it 'renders domain verification certificate' do - get :show - expect(response.body).to eq domain_verification_certificate - end - end -end diff --git a/spec/requests/apple_domain_verification.rb b/spec/requests/apple_domain_verification.rb new file mode 100644 index 00000000..1f63571d --- /dev/null +++ b/spec/requests/apple_domain_verification.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe 'Apple Domain Verification', type: :request do + let(:domain_verification_certificate) { FFaker::Lorem.characters(20) } + let!(:stripe_apple_pay_payment_method) do + Spree::Gateway::StripeApplePayGateway.create!( + name: 'ApplePay', + preferred_domain_verification_certificate: domain_verification_certificate + ) + end + + before { get '/.well-known/apple-developer-merchantid-domain-association' } + + it 'returns 200 HTTP status' do + expect(response.status).to eq(200) + end + + it 'renders domain verification certificate' do + expect(response.body).to eq domain_verification_certificate + end +end From 5c84d92d475586a6478c49011af2bdaf69df9ca8 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Mon, 10 Dec 2018 14:15:14 +0100 Subject: [PATCH 08/11] Better handling of non existing Apple Pay Payment Gateway in Apple Pay Domain Verification endpoint --- ...pple_pay_domain_verification_controller.rb | 2 + spec/requests/apple_domain_verification.rb | 21 --------- .../requests/apple_pay_domain_verification.rb | 45 +++++++++++++++++++ 3 files changed, 47 insertions(+), 21 deletions(-) delete mode 100644 spec/requests/apple_domain_verification.rb create mode 100644 spec/requests/apple_pay_domain_verification.rb diff --git a/lib/controllers/spree/apple_pay_domain_verification_controller.rb b/lib/controllers/spree/apple_pay_domain_verification_controller.rb index eed64811..2d09ac8e 100644 --- a/lib/controllers/spree/apple_pay_domain_verification_controller.rb +++ b/lib/controllers/spree/apple_pay_domain_verification_controller.rb @@ -3,6 +3,8 @@ class ApplePayDomainVerificationController < Spree::BaseController def show gateway = Spree::Gateway::StripeApplePayGateway.active.last + raise ActiveRecord::RecordNotFound unless gateway + render plain: gateway.preferred_domain_verification_certificate end end diff --git a/spec/requests/apple_domain_verification.rb b/spec/requests/apple_domain_verification.rb deleted file mode 100644 index 1f63571d..00000000 --- a/spec/requests/apple_domain_verification.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'spec_helper' - -describe 'Apple Domain Verification', type: :request do - let(:domain_verification_certificate) { FFaker::Lorem.characters(20) } - let!(:stripe_apple_pay_payment_method) do - Spree::Gateway::StripeApplePayGateway.create!( - name: 'ApplePay', - preferred_domain_verification_certificate: domain_verification_certificate - ) - end - - before { get '/.well-known/apple-developer-merchantid-domain-association' } - - it 'returns 200 HTTP status' do - expect(response.status).to eq(200) - end - - it 'renders domain verification certificate' do - expect(response.body).to eq domain_verification_certificate - end -end diff --git a/spec/requests/apple_pay_domain_verification.rb b/spec/requests/apple_pay_domain_verification.rb new file mode 100644 index 00000000..05f6f2f9 --- /dev/null +++ b/spec/requests/apple_pay_domain_verification.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe 'Apple Pay Domain Verification', type: :request do + let(:domain_verification_certificate) { FFaker::Lorem.characters(20) } + let(:stripe_apple_pay_payment_method) do + Spree::Gateway::StripeApplePayGateway.create!( + name: 'ApplePay', + preferred_domain_verification_certificate: domain_verification_certificate + ) + end + let(:execute) { get '/.well-known/apple-developer-merchantid-domain-association' } + + shared_examples 'returns 404' do + it 'returns RecordNotFound exception' do + expect { execute }.to raise_exception(ActiveRecord::RecordNotFound) + end + end + + context 'apple pay gateway exists' do + before do + stripe_apple_pay_payment_method + execute + end + + it 'returns 200 HTTP status' do + expect(response.status).to eq(200) + end + + it 'renders domain verification certificate' do + expect(response.body).to eq domain_verification_certificate + end + end + + context 'apple pay gateway doesnt exist' do + it_behaves_like 'returns 404' + end + + context 'apple pay gateway not active' do + before do + stripe_apple_pay_payment_method.update_column(:active, false) + end + + it_behaves_like 'returns 404' + end +end From c4afd9ba5e0964591c1af1f13b63f5a458570549 Mon Sep 17 00:00:00 2001 From: Damian Legawiec Date: Mon, 10 Dec 2018 16:58:54 +0100 Subject: [PATCH 09/11] Compatibility fix for older Spree versions --- .../spree/checkout/payment/_stripe_additional_info.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb index 9f58a7da..01bfb665 100644 --- a/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb +++ b/lib/views/frontend/spree/checkout/payment/_stripe_additional_info.html.erb @@ -1,3 +1,4 @@ +<% bill_address ||= @order.bill_address %> <%- if @order.has_checkout_step?('address') -%>