fixed credit when no payment_profiles_supported
This commit is contained in:
parent
b11a9dd9f2
commit
e11a8e4d5f
|
@ -26,11 +26,12 @@ class Spree::BillingIntegration::PaypalExpressBase < Spree::BillingIntegration
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def credit(amount, account, response_code, gateway_options)
|
def credit(*args)
|
||||||
|
amount = args.shift
|
||||||
|
response_code = args.first.is_a?(String) ? args.first : args[1]
|
||||||
provider.credit(amount, response_code, :currency => preferred_currency)
|
provider.credit(amount, response_code, :currency => preferred_currency)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def find_authorization(payment)
|
def find_authorization(payment)
|
||||||
logs = payment.log_entries.all(:order => 'created_at DESC')
|
logs = payment.log_entries.all(:order => 'created_at DESC')
|
||||||
logs.each do |log|
|
logs.each do |log|
|
||||||
|
|
|
@ -105,4 +105,31 @@ describe Spree::BillingIntegration::PaypalExpressBase do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#credit" do
|
||||||
|
before { payment.stub :response_code => '123' }
|
||||||
|
context "when payment_profiles_supported = true" do
|
||||||
|
before { gateway.stub :payment_profiles_supported? => true }
|
||||||
|
|
||||||
|
|
||||||
|
it "should receive correct params" do
|
||||||
|
provider.should_receive(:credit).with(1000, '123', :currency => 'EUR').and_return(success_response)
|
||||||
|
payment.credit!(10.0)
|
||||||
|
payment.response_code.should == '123'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when payment_profiles_supported = false" do
|
||||||
|
before do
|
||||||
|
payment.stub :response_code => '123'
|
||||||
|
gateway.stub :payment_profiles_supported? => false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should receive correct params" do
|
||||||
|
provider.should_receive(:credit).with(amount_in_cents, '123', :currency => 'EUR').and_return(success_response)
|
||||||
|
payment.credit!(10.0)
|
||||||
|
payment.response_code.should == '123'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue