Skip to content

Commit

Permalink
Always send account_email to WorldPay
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/WC-536

This PR essentially reverts the change made in #278 - when AD users were locked out of their account, we wanted to avoid using an email address they may no longer have access to. However, our registration transfer feature solves that problem, so we can now be consistent about what address we use again.
  • Loading branch information
irisfaraway committed Dec 7, 2018
1 parent 1a03190 commit a75f807
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 60 deletions.
10 changes: 1 addition & 9 deletions app/services/waste_carriers_engine/worldpay_xml_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def build_payment_methods(xml)
end

def build_shopper(xml)
email = get_email
email = @transient_registration.account_email

xml.shopper do
xml.shopperEmailAddress email
Expand Down Expand Up @@ -100,13 +100,5 @@ def get_country_code(country)
return "GB" if country.nil?
country.alpha2
end

def get_email
if @current_user.email == @transient_registration.account_email
@transient_registration.account_email
else
@transient_registration.contact_email
end
end
end
end
30 changes: 0 additions & 30 deletions spec/fixtures/files/request_to_worldpay_ad.xml

This file was deleted.

25 changes: 4 additions & 21 deletions spec/services/waste_carriers_engine/worldpay_xml_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,10 @@ module WasteCarriersEngine
allow_any_instance_of(Order).to receive(:total_amount).and_return(10_000)
end

describe "build_xml" do
context "when it's a digital registration" do
before do
current_user.email = transient_registration.account_email
end

it "returns correctly-formatted XML" do
xml = File.read("./spec/fixtures/files/request_to_worldpay.xml")
expect(worldpay_xml_service.build_xml).to eq(xml)
end
end

context "when it's an assisted digital registration" do
before do
current_user.email = "not-the-same-account@example.com"
end

it "returns correctly-formatted XML" do
xml = File.read("./spec/fixtures/files/request_to_worldpay_ad.xml")
expect(worldpay_xml_service.build_xml).to eq(xml)
end
describe "#build_xml" do
it "returns correctly-formatted XML" do
xml = File.read("./spec/fixtures/files/request_to_worldpay.xml")
expect(worldpay_xml_service.build_xml).to eq(xml)
end
end
end
Expand Down

0 comments on commit a75f807

Please sign in to comment.