cache payment_method and can now set paypal's landing page by setting allow_guest_checkout
This commit is contained in:
parent
98f99ab3d2
commit
c1f8854e15
|
@ -226,7 +226,7 @@ module Spree
|
|||
|
||||
# hook to override paypal site options
|
||||
def paypal_site_opts
|
||||
{:currency => payment_method.preferred_currency}
|
||||
{:currency => payment_method.preferred_currency, :allow_guest_checkout => payment_method.preferred_allow_guest_checkout }
|
||||
end
|
||||
|
||||
def order_opts(order, payment_method, stage)
|
||||
|
@ -362,7 +362,7 @@ module Spree
|
|||
|
||||
# create the gateway from the supplied options
|
||||
def payment_method
|
||||
Spree::PaymentMethod.find(params[:payment_method_id])
|
||||
@payment_method ||= Spree::PaymentMethod.find(params[:payment_method_id])
|
||||
end
|
||||
|
||||
def paypal_gateway
|
||||
|
|
|
@ -5,9 +5,9 @@ class Spree::BillingIntegration::PaypalExpress < Spree::BillingIntegration
|
|||
preference :review, :boolean, :default => false
|
||||
preference :no_shipping, :boolean, :default => false
|
||||
preference :currency, :string, :default => 'USD'
|
||||
preference :allow_guest_checkout, :boolean, :default => false
|
||||
|
||||
def provider_class
|
||||
ActiveMerchant::Billing::PaypalExpressGateway
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ module Spree
|
|||
let(:order) { Factory(:ppx_order_with_totals, :state => "payment") }
|
||||
let(:order_total) { (order.total * 100).to_i }
|
||||
let(:gateway_provider) { mock(ActiveMerchant::Billing::PaypalExpressGateway) }
|
||||
let(:paypal_gateway) { mock(BillingIntegration::PaypalExpress, :id => 123, :preferred_review => false, :preferred_no_shipping => true, :provider => gateway_provider, :preferred_currency => "US"
|
||||
let(:paypal_gateway) { mock(BillingIntegration::PaypalExpress, :id => 123, :preferred_review => false, :preferred_no_shipping => true, :provider => gateway_provider, :preferred_currency => "US", :preferred_allow_guest_checkout => true
|
||||
) }
|
||||
|
||||
let(:details_for_response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, :success? => true,
|
||||
|
@ -289,5 +289,14 @@ module Spree
|
|||
|
||||
|
||||
end
|
||||
|
||||
describe "#paypal_site_opts" do
|
||||
it "returns opts to allow guest checkout" do
|
||||
controller.should_receive(:payment_method).at_least(1).and_return(paypal_gateway)
|
||||
|
||||
opts = controller.send(:paypal_site_opts)
|
||||
opts[:allow_guest_checkout].should be_true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue