fixed paypal_confirm order state
This commit is contained in:
parent
4b8dbdbfeb
commit
bf00623328
|
@ -90,10 +90,11 @@ module Spree
|
||||||
@order.ship_address = order_ship_address
|
@order.ship_address = order_ship_address
|
||||||
@order.bill_address ||= order_ship_address
|
@order.bill_address ||= order_ship_address
|
||||||
end
|
end
|
||||||
|
@order.state = "payment"
|
||||||
@order.save
|
@order.save
|
||||||
|
|
||||||
if payment_method.preferred_review
|
if payment_method.preferred_review
|
||||||
|
@order.next
|
||||||
render 'spree/shared/paypal_express_confirm'
|
render 'spree/shared/paypal_express_confirm'
|
||||||
else
|
else
|
||||||
paypal_finish
|
paypal_finish
|
||||||
|
|
|
@ -12,4 +12,8 @@ class Spree::BillingIntegration::PaypalExpress < Spree::BillingIntegration
|
||||||
def provider_class
|
def provider_class
|
||||||
ActiveMerchant::Billing::PaypalExpressGateway
|
ActiveMerchant::Billing::PaypalExpressGateway
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def payment_profiles_supported?
|
||||||
|
!!preferred_review
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,4 +13,7 @@ class Spree::BillingIntegration::PaypalExpressUk < Spree::BillingIntegration
|
||||||
ActiveMerchant::Billing::PaypalExpressGateway
|
ActiveMerchant::Billing::PaypalExpressGateway
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def payment_profiles_supported?
|
||||||
|
!!preferred_review
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,7 +75,10 @@ module Spree
|
||||||
end
|
end
|
||||||
|
|
||||||
context "paypal_confirm" do
|
context "paypal_confirm" do
|
||||||
before { PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway) }
|
before do
|
||||||
|
PaymentMethod.should_receive(:find).at_least(1).with("123").and_return(paypal_gateway)
|
||||||
|
order.stub!(:payment_method).and_return paypal_gateway
|
||||||
|
end
|
||||||
|
|
||||||
context "with auto_capture and no review" do
|
context "with auto_capture and no review" do
|
||||||
before do
|
before do
|
||||||
|
@ -100,7 +103,10 @@ module Spree
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with review" do
|
context "with review" do
|
||||||
before { paypal_gateway.stub(:preferred_review => true) }
|
before do
|
||||||
|
paypal_gateway.stub(:preferred_review => true, :payment_profiles_supported? => true)
|
||||||
|
order.stub_chain(:payment, :payment_method, :payment_profiles_supported? => true)
|
||||||
|
end
|
||||||
|
|
||||||
it "should render review" do
|
it "should render review" do
|
||||||
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
paypal_gateway.provider.should_receive(:details_for).with(token).and_return(details_for_response)
|
||||||
|
@ -108,7 +114,15 @@ module Spree
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
response.should render_template("shared/paypal_express_confirm")
|
response.should render_template("shared/paypal_express_confirm")
|
||||||
order.state.should == "payment"
|
order.state.should == "confirm"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "order state should not change on multiple call" do
|
||||||
|
paypal_gateway.provider.should_receive(:details_for).twice.with(token).and_return(details_for_response)
|
||||||
|
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
order.state.should == "confirm"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +130,8 @@ module Spree
|
||||||
before do
|
before do
|
||||||
paypal_gateway.stub(:preferred_review => true)
|
paypal_gateway.stub(:preferred_review => true)
|
||||||
paypal_gateway.stub(:preferred_no_shipping => false)
|
paypal_gateway.stub(:preferred_no_shipping => false)
|
||||||
|
paypal_gateway.stub(:payment_profiles_supported? => true)
|
||||||
|
order.stub_chain(:payment, :payment_method, :payment_profiles_supported? => true)
|
||||||
details_for_response.stub(:params => details_for_response.params.merge({'first_name' => 'Dr.', 'last_name' => 'Evil'}),
|
details_for_response.stub(:params => details_for_response.params.merge({'first_name' => 'Dr.', 'last_name' => 'Evil'}),
|
||||||
:address => {'address1' => 'Apt. 187', 'address2'=> 'Some Str.', 'city' => 'Chevy Chase', 'country' => 'US', 'zip' => '20815', 'state' => 'MD' })
|
:address => {'address1' => 'Apt. 187', 'address2'=> 'Some Str.', 'city' => 'Chevy Chase', 'country' => 'US', 'zip' => '20815', 'state' => 'MD' })
|
||||||
|
|
||||||
|
@ -128,6 +143,7 @@ module Spree
|
||||||
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
get :paypal_confirm, {:order_id => order.number, :payment_method_id => "123", :token => token, :PayerID => "FWRVKNRRZ3WUC" }
|
||||||
|
|
||||||
order.ship_address.address1.should == "Apt. 187"
|
order.ship_address.address1.should == "Apt. 187"
|
||||||
|
order.state.should == "confirm"
|
||||||
response.should render_template("shared/paypal_express_confirm")
|
response.should render_template("shared/paypal_express_confirm")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,15 +26,13 @@ feature "paypal express" do
|
||||||
['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field|
|
['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field|
|
||||||
fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}"
|
fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}"
|
||||||
end
|
end
|
||||||
save_and_open_page
|
|
||||||
|
|
||||||
|
|
||||||
select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id"
|
select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id"
|
||||||
check "order_use_billing"
|
check "order_use_billing"
|
||||||
click_button "Save and Continue"
|
click_button "Save and Continue"
|
||||||
|
|
||||||
choose "Paypal"
|
|
||||||
pending
|
pending
|
||||||
|
choose "Paypal"
|
||||||
click_button "Save and Continue"
|
click_button "Save and Continue"
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue