defra_ruby_mocks 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fcd5775c21149e97c7c65f92b1f469adf065565
4
- data.tar.gz: b056b6419ada5eb1bf86dcabaee805cf6eae155a
3
+ metadata.gz: 11c12df8f46d57ee398b846e7b940eabb3ef666f
4
+ data.tar.gz: d11d804834f28614a23c4fd6bc486885a9f9bdd9
5
5
  SHA512:
6
- metadata.gz: b6239c9c0d4ea46e2cb47b89dc44c67df263fcddf2704f85b46536529f6db67427f3f830d4842c0943f2eb9eb61558e92d08ac0d2bfd0bd81ec3b010f66f5de7
7
- data.tar.gz: 494e1b4a8ef9bf6645be512e915faf5c41dfbc0927da4eb2dcda28f52bef8389adc7bd944437c01aca8ba8e40f10565fd6a0f02ad5a5377e773a22b7011cc141
6
+ metadata.gz: 6ecc755e31cf7a746265c1a4f3292b4e037ca7976040cc2350bf5c0ee89e0c630ce7fc3b416319418de7537a8a229b3f6cae80bbadaa700bb951923923087104
7
+ data.tar.gz: 8afc6250125e523384ccb27c0e543cd9cdeb0b678a9cf818b63a5bb7c34b458daeaabdd759b8babfd91ac6bd834281968362e34af104f4de3c4145e930483322
data/README.md CHANGED
@@ -108,6 +108,8 @@ The list of possible statuses was taken from
108
108
 
109
109
  When mounted into an app you can simulate interacting with the Worldpay hosted pages service.
110
110
 
111
+ #### Payments
112
+
111
113
  Making a payment with Worldpay essentially comes in 2 stages
112
114
 
113
115
  1. The app sends an XML request to Worldpay asking it to prepare for a new payment. Worldpay responds with a reference and a URL to redirect the user to
@@ -120,6 +122,14 @@ This Worldpay mock replicates those 2 interactions with the following urls
120
122
  - `../worldpay/payments-service`
121
123
  - `../worldpay/dispatcher`
122
124
 
125
+ #### Refunds
126
+
127
+ Requesting a refund from Worldpay is a single step process.
128
+
129
+ 1. The app sends an XML request to Worldpay with details of the order to be refunded and the amount. Worldpay returns an XML response confirming the request has been received
130
+
131
+ Like payments, refund requests are also sent to the same url `../worldpay/payments-service`. The mock handles determining what request is being made and returns the appropriate response.
132
+
123
133
  #### Configuration
124
134
 
125
135
  In order to use the Worldpay mock you'll need to provide additional configuration details
@@ -6,14 +6,10 @@ module DefraRubyMocks
6
6
  before_action :set_default_response_format
7
7
 
8
8
  def payments_service
9
- response_values = WorldpayRequestService.run(request.body.read)
9
+ @values = WorldpayRequestHandlerService.run(convert_request_body_to_xml)
10
10
 
11
- @merchant_code = response_values[:merchant_code]
12
- @order_code = response_values[:order_code]
13
- @worldpay_id = response_values[:id]
14
- @worldpay_url = response_values[:url]
15
-
16
- respond_to :xml
11
+ render_payment_response if @values[:request_type] == :payment
12
+ render_refund_response if @values[:request_type] == :refund
17
13
  rescue StandardError
18
14
  head 500
19
15
  end
@@ -31,5 +27,17 @@ module DefraRubyMocks
31
27
  request.format = :xml
32
28
  end
33
29
 
30
+ def convert_request_body_to_xml
31
+ Nokogiri::XML(request.body.read)
32
+ end
33
+
34
+ def render_payment_response
35
+ render "defra_ruby_mocks/worldpay/payment_request"
36
+ end
37
+
38
+ def render_refund_response
39
+ render "defra_ruby_mocks/worldpay/refund_request"
40
+ end
41
+
34
42
  end
35
43
  end
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DefraRubyMocks
4
- class WorldpayRequestService < BaseService
5
- def run(data)
4
+ class WorldpayPaymentService < BaseService
5
+ def run(merchant_code:, xml:)
6
6
  check_config
7
7
 
8
- xml = Nokogiri::XML(data)
9
- @merchant_code = extract_merchant_code(xml)
8
+ @merchant_code = merchant_code
10
9
  @order_code = extract_order_code(xml)
11
10
 
12
11
  {
@@ -25,11 +24,6 @@ module DefraRubyMocks
25
24
  raise InvalidConfigError, :worldpay_domain if domain.blank?
26
25
  end
27
26
 
28
- def extract_merchant_code(xml)
29
- payment_service = xml.at_xpath("//paymentService")
30
- payment_service.attribute("merchantCode").text
31
- end
32
-
33
27
  def extract_order_code(xml)
34
28
  order = xml.at_xpath("//order")
35
29
  order.attribute("orderCode").text
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyMocks
4
+ class WorldpayRefundService < BaseService
5
+ def run(merchant_code:, xml:)
6
+ {
7
+ merchant_code: merchant_code,
8
+ order_code: extract_order_code(xml),
9
+ refund_value: extract_refund_value(xml),
10
+ currency_code: extract_currency_code(xml),
11
+ exponent: extract_exponent(xml)
12
+ }
13
+ end
14
+
15
+ private
16
+
17
+ def extract_order_code(xml)
18
+ order_modification = xml.at_xpath("//orderModification")
19
+ order_modification.attribute("orderCode").text
20
+ end
21
+
22
+ def extract_refund_value(xml)
23
+ amount = xml.at_xpath("//amount")
24
+ amount.attribute("value").text
25
+ end
26
+
27
+ def extract_currency_code(xml)
28
+ amount = xml.at_xpath("//amount")
29
+ amount.attribute("currencyCode").text
30
+ end
31
+
32
+ def extract_exponent(xml)
33
+ amount = xml.at_xpath("//amount")
34
+ amount.attribute("exponent").text
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyMocks
4
+ class WorldpayRequestHandlerService < BaseService
5
+ def run(xml)
6
+ arguments = {
7
+ merchant_code: extract_merchant_code(xml),
8
+ xml: xml
9
+ }
10
+
11
+ generate_response(arguments)
12
+ end
13
+
14
+ private
15
+
16
+ def extract_merchant_code(xml)
17
+ payment_service = xml.at_xpath("//paymentService")
18
+ payment_service.attribute("merchantCode").text
19
+ end
20
+
21
+ def generate_response(arguments)
22
+ return WorldpayPaymentService.run(arguments).merge(request_type: :payment) if payment_request?(arguments[:xml])
23
+ return WorldpayRefundService.run(arguments).merge(request_type: :refund) if refund_request?(arguments[:xml])
24
+
25
+ raise UnrecognisedWorldpayRequestError
26
+ end
27
+
28
+ def payment_request?(xml)
29
+ submit = xml.at_xpath("//submit")
30
+
31
+ !submit.nil?
32
+ end
33
+
34
+ def refund_request?(xml)
35
+ modify = xml.at_xpath("//modify")
36
+
37
+ !modify.nil?
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN"
3
+ "http://dtd.worldpay.com/paymentService_v1.dtd">
4
+ <paymentService version="1.4" merchantCode="<%= @values[:merchant_code] %>"><reply><orderStatus orderCode="<%= @values[:order_code] %>"><reference id="<%= @values[:id] %>"><%= @values[:url] %></reference></orderStatus></reply></paymentService>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN"
3
+ "http://dtd.worldpay.com/paymentService_v1.dtd">
4
+ <paymentService version="1.4" merchantCode="<%= @values[:merchant_code] %>"><reply><ok><refundReceived orderCode="<%= @values[:order_code] %>"><amount value="<%= @values[:refund_value] %>" currencyCode="<%= @values[:currency_code] %>" exponent="<%= @values[:exponent] %>" debitCreditIndicator="credit"/></refundReceived></ok></reply></paymentService>
@@ -3,6 +3,7 @@
3
3
  require_relative "configuration"
4
4
  require_relative "invalid_config_error"
5
5
  require_relative "missing_registration_error"
6
+ require_relative "unrecognised_worldpay_request_error"
6
7
 
7
8
  module DefraRubyMocks
8
9
  class Engine < ::Rails::Engine
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRubyMocks
4
+ class UnrecognisedWorldpayRequestError < StandardError; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DefraRubyMocks
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>
3
+ <paymentService version="1.4">
4
+ <modify>
5
+ </modify>
6
+ </paymentService>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>
3
+ <paymentService version="1.4" merchantCode="MERCHME">
4
+ <modify>
5
+ <orderModification orderCode="1579644835">
6
+ <refund>
7
+ <amount value="2500" currencyCode="GBP" exponent="2"/>
8
+ </refund>
9
+ </orderModification>
10
+ </modify>
11
+ </paymentService>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0"?>
2
+ <!DOCTYPE paymentService PUBLIC '-//WorldPay/DTD WorldPay PaymentService v1/EN' 'http://dtd.worldpay.com/paymentService_v1.dtd'>
3
+ <paymentService version="1.4" merchantCode="MERCHME">
4
+ <boom>
5
+ </boom>
6
+ </paymentService>
@@ -19,24 +19,41 @@ module DefraRubyMocks
19
19
  context "#payments_service" do
20
20
  let(:path) { "/defra_ruby_mocks/worldpay/payments-service" }
21
21
 
22
- context "and the request is valid" do
23
- let(:data) { File.read("spec/fixtures/worldpay_request_valid.xml") }
22
+ context "when a payment request is received" do
23
+ context "and the request is valid" do
24
+ let(:data) { File.read("spec/fixtures/payment_request_valid.xml") }
24
25
 
25
- it "returns an XML response with a 200 code" do
26
- get path, {}, "RAW_POST_DATA" => data
26
+ it "returns an XML response with a 200 code" do
27
+ get path, {}, "RAW_POST_DATA" => data
27
28
 
28
- expect(response.content_type).to eq("application/xml")
29
- expect(response.code).to eq("200")
29
+ expect(response.content_type).to eq("application/xml")
30
+ expect(response.code).to eq("200")
31
+ expect(response.body).to be_xml
32
+ end
33
+ end
34
+
35
+ context "and the request is invalid" do
36
+ let(:data) { File.read("spec/fixtures/payment_request_invalid.xml") }
37
+
38
+ it "returns a response with a 500 code" do
39
+ get path, {}, "RAW_POST_DATA" => data
40
+
41
+ expect(response.code).to eq("500")
42
+ end
30
43
  end
31
44
  end
32
45
 
33
- context "and the request is invalid" do
34
- let(:data) { File.read("spec/fixtures/worldpay_request_invalid.xml") }
46
+ context "when a refund request is received" do
47
+ context "and the request is valid" do
48
+ let(:data) { File.read("spec/fixtures/refund_request_valid.xml") }
35
49
 
36
- it "returns a response with a 500 code" do
37
- get path, {}, "RAW_POST_DATA" => data
50
+ it "returns an XML response with a 200 code" do
51
+ get path, {}, "RAW_POST_DATA" => data
38
52
 
39
- expect(response.code).to eq("500")
53
+ expect(response.content_type).to eq("application/xml")
54
+ expect(response.code).to eq("200")
55
+ expect(response.body).to be_xml
56
+ end
40
57
  end
41
58
  end
42
59
  end
@@ -3,58 +3,61 @@
3
3
  require "rails_helper"
4
4
 
5
5
  module DefraRubyMocks
6
- RSpec.describe WorldpayRequestService do
6
+ RSpec.describe WorldpayPaymentService do
7
7
  describe ".run" do
8
8
  after(:each) { Helpers::Configuration.reset_for_tests }
9
9
 
10
+ let(:merchant_code) { "MERCHME" }
11
+ let(:args) { { merchant_code: merchant_code, xml: xml } }
12
+
10
13
  context "when the mocks config is missing a worldpay domain" do
14
+ let(:xml) { nil }
15
+
11
16
  it "raises a 'InvalidConfigError'" do
12
- expect { described_class.run(nil) }.to raise_error InvalidConfigError
17
+ expect { described_class.run(args) }.to raise_error InvalidConfigError
13
18
  end
14
19
  end
15
20
 
16
- context "when the XML data is valid" do
21
+ context "when the XML is valid" do
17
22
  before(:each) do
18
23
  DefraRubyMocks.configure do |config|
19
24
  config.worldpay_domain = "http://localhost:3000/defra_ruby_mocks"
20
25
  end
21
26
  end
22
27
 
23
- let(:data) { File.read("spec/fixtures/worldpay_request_valid.xml") }
28
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/payment_request_valid.xml")) }
24
29
 
25
30
  context "the result it returns" do
26
31
  it "is a hash" do
27
- expect(described_class.run(data)).to be_an_instance_of(Hash)
32
+ expect(described_class.run(args)).to be_an_instance_of(Hash)
28
33
  end
29
34
 
30
35
  it "contains 4 values" do
31
- result = described_class.run(data).length
36
+ result = described_class.run(args).length
32
37
  expect(result).to eq(4)
33
38
  end
34
39
 
35
- context "has values extracted from the XML data" do
36
- it "a merchant code" do
37
- result = described_class.run(data)[:merchant_code]
40
+ it "has the merchant code passed in" do
41
+ result = described_class.run(args)[:merchant_code]
38
42
 
39
- expect(result).to eq("MERCHME")
40
- end
43
+ expect(result).to eq(merchant_code)
44
+ end
41
45
 
42
- it "an order code" do
43
- result = described_class.run(data)[:order_code]
46
+ it "has an order code extracted from the XML" do
47
+ result = described_class.run(args)[:order_code]
44
48
 
45
- expect(result).to eq("1577726052")
46
- end
49
+ expect(result).to eq("1577726052")
47
50
  end
48
51
 
49
52
  context "has a generated ID which is" do
50
53
  it "10 characters long" do
51
- result = described_class.run(data)[:id]
54
+ result = described_class.run(args)[:id]
52
55
 
53
56
  expect(result.length).to eq(10)
54
57
  end
55
58
 
56
59
  it "only made up of the digits 0 to 9" do
57
- result = described_class.run(data)[:id]
60
+ result = described_class.run(args)[:id]
58
61
 
59
62
  expect(result.scan(/\D/).empty?).to be_truthy
60
63
  end
@@ -62,7 +65,7 @@ module DefraRubyMocks
62
65
  it "different each time" do
63
66
  results = []
64
67
  3.times do
65
- results << described_class.run(data)[:id]
68
+ results << described_class.run(args)[:id]
66
69
  end
67
70
 
68
71
  expect(results.uniq.length).to eq(results.length)
@@ -71,7 +74,7 @@ module DefraRubyMocks
71
74
 
72
75
  context "has a url" do
73
76
  it "based on the configured domain, and extracted merchant and order codes" do
74
- result = described_class.run(data)[:url]
77
+ result = described_class.run(args)[:url]
75
78
 
76
79
  expect(result).to eq("http://localhost:3000/defra_ruby_mocks/worldpay/dispatcher?OrderKey=MERCHME%5E1577726052")
77
80
  end
@@ -80,11 +83,11 @@ module DefraRubyMocks
80
83
 
81
84
  end
82
85
 
83
- context "when the data is invalid" do
84
- let(:data) { File.read("spec/fixtures/worldpay_request_invalid.xml") }
86
+ context "when the XML is invalid" do
87
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/payment_request_invalid.xml")) }
85
88
 
86
89
  it "raises an error" do
87
- expect { described_class.run(data) }.to raise_error StandardError
90
+ expect { described_class.run(args) }.to raise_error StandardError
88
91
  end
89
92
  end
90
93
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ module DefraRubyMocks
6
+ RSpec.describe WorldpayRefundService do
7
+ describe ".run" do
8
+
9
+ let(:merchant_code) { "MERCHME" }
10
+ let(:args) { { merchant_code: merchant_code, xml: xml } }
11
+
12
+ context "when the XML is valid" do
13
+
14
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/refund_request_valid.xml")) }
15
+
16
+ context "the result it returns" do
17
+ it "is a hash" do
18
+ expect(described_class.run(args)).to be_an_instance_of(Hash)
19
+ end
20
+
21
+ it "contains 5 values" do
22
+ result = described_class.run(args).length
23
+ expect(result).to eq(5)
24
+ end
25
+
26
+ it "has the merchant code passed in" do
27
+ result = described_class.run(args)[:merchant_code]
28
+
29
+ expect(result).to eq(merchant_code)
30
+ end
31
+
32
+ it "has an order code extracted from the XML" do
33
+ result = described_class.run(args)[:order_code]
34
+
35
+ expect(result).to eq("1579644835")
36
+ end
37
+
38
+ it "has the refund value extracted from the XML" do
39
+ result = described_class.run(args)[:refund_value]
40
+
41
+ expect(result).to eq("2500")
42
+ end
43
+
44
+ it "has a currency code extracted from the XML" do
45
+ result = described_class.run(args)[:currency_code]
46
+
47
+ expect(result).to eq("GBP")
48
+ end
49
+
50
+ it "has the exponent extracted from the XML" do
51
+ result = described_class.run(args)[:exponent]
52
+
53
+ expect(result).to eq("2")
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ context "when the XML is invalid" do
60
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/refund_request_invalid.xml")) }
61
+
62
+ it "raises an error" do
63
+ expect { described_class.run(args) }.to raise_error StandardError
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_helper"
4
+
5
+ module DefraRubyMocks
6
+ RSpec.describe WorldpayRequestHandlerService do
7
+ describe ".run" do
8
+ context "when a request is made" do
9
+
10
+ let(:merchant_code) { "MERCHME" }
11
+ let(:args) { { merchant_code: merchant_code, xml: xml } }
12
+
13
+ context "and it's for a payment" do
14
+ before do
15
+ allow_any_instance_of(WorldpayPaymentService).to receive(:generate_id) { order_id }
16
+ end
17
+
18
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/payment_request_valid.xml")) }
19
+ let(:order_id) { "1234567890" }
20
+ let(:request_type) { { request_type: :payment } }
21
+ let(:response_values) do
22
+ {
23
+ merchant_code: merchant_code,
24
+ order_code: "1577726052",
25
+ id: order_id,
26
+ url: "http://example.com"
27
+ }
28
+ end
29
+
30
+ it "correctly determines the request service to use" do
31
+ expect(WorldpayPaymentService).to receive(:run).with(args) { response_values }
32
+
33
+ described_class.run(xml)
34
+ end
35
+
36
+ it "returns the values the controller needs to handle the request" do
37
+ expect(WorldpayPaymentService).to receive(:run).with(args) { response_values }
38
+
39
+ expect(described_class.run(xml)).to eq(request_type.merge(response_values))
40
+ end
41
+ end
42
+
43
+ context "and it's for a refund" do
44
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/refund_request_valid.xml")) }
45
+ let(:request_type) { { request_type: :refund } }
46
+ let(:response_values) do
47
+ {
48
+ merchant_code: merchant_code,
49
+ order_code: "1579644835",
50
+ refund_value: "2500",
51
+ currency_code: "GBP",
52
+ exponent: "2"
53
+ }
54
+ end
55
+
56
+ it "correctly determines the request service to use" do
57
+ expect(WorldpayRefundService).to receive(:run).with(args) { response_values }
58
+
59
+ described_class.run(xml)
60
+ end
61
+
62
+ it "returns the values the controller needs to handle the request" do
63
+ expect(WorldpayRefundService).to receive(:run).with(args) { response_values }
64
+
65
+ expect(described_class.run(xml)).to eq(request_type.merge(response_values))
66
+ end
67
+ end
68
+
69
+ context "but it's not recognised" do
70
+ let(:xml) { Nokogiri::XML(File.read("spec/fixtures/unrecognised_request.xml")) }
71
+
72
+ it "raises a 'UnrecognisedWorldpayRequestError'" do
73
+ expect { described_class.run(xml) }.to raise_error UnrecognisedWorldpayRequestError
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/expectations"
4
+
5
+ RSpec::Matchers.define :be_xml do
6
+ match do
7
+ begin
8
+ Nokogiri::XML(actual, &:strict)
9
+
10
+ true
11
+ rescue Nokogiri::XML::SyntaxError
12
+ false
13
+ end
14
+ end
15
+
16
+ failure_message do |actual|
17
+ "expected that \"#{actual}\" would be a valid XML document"
18
+ end
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defra_ruby_mocks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Defra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-20 00:00:00.000000000 Z
11
+ date: 2020-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -124,17 +124,21 @@ files:
124
124
  - app/controllers/defra_ruby_mocks/worldpay_controller.rb
125
125
  - app/services/defra_ruby_mocks/base_service.rb
126
126
  - app/services/defra_ruby_mocks/companies_house_service.rb
127
- - app/services/defra_ruby_mocks/worldpay_request_service.rb
127
+ - app/services/defra_ruby_mocks/worldpay_payment_service.rb
128
+ - app/services/defra_ruby_mocks/worldpay_refund_service.rb
129
+ - app/services/defra_ruby_mocks/worldpay_request_handler_service.rb
128
130
  - app/services/defra_ruby_mocks/worldpay_response_service.rb
129
131
  - app/views/defra_ruby_mocks/company/not_found.json.erb
130
132
  - app/views/defra_ruby_mocks/company/show.json.erb
131
- - app/views/defra_ruby_mocks/worldpay/payments_service.xml.erb
133
+ - app/views/defra_ruby_mocks/worldpay/payment_request.xml.erb
134
+ - app/views/defra_ruby_mocks/worldpay/refund_request.xml.erb
132
135
  - config/routes.rb
133
136
  - lib/defra_ruby_mocks.rb
134
137
  - lib/defra_ruby_mocks/configuration.rb
135
138
  - lib/defra_ruby_mocks/engine.rb
136
139
  - lib/defra_ruby_mocks/invalid_config_error.rb
137
140
  - lib/defra_ruby_mocks/missing_registration_error.rb
141
+ - lib/defra_ruby_mocks/unrecognised_worldpay_request_error.rb
138
142
  - lib/defra_ruby_mocks/version.rb
139
143
  - lib/tasks/changelog.rake
140
144
  - lib/tasks/defra_ruby_mocks_tasks.rake
@@ -176,19 +180,25 @@ files:
176
180
  - spec/dummy/public/500.html
177
181
  - spec/dummy/public/favicon.ico
178
182
  - spec/examples.txt
179
- - spec/fixtures/worldpay_request_invalid.xml
180
- - spec/fixtures/worldpay_request_valid.xml
183
+ - spec/fixtures/payment_request_invalid.xml
184
+ - spec/fixtures/payment_request_valid.xml
185
+ - spec/fixtures/refund_request_invalid.xml
186
+ - spec/fixtures/refund_request_valid.xml
187
+ - spec/fixtures/unrecognised_request.xml
181
188
  - spec/lib/configuration_spec.rb
182
189
  - spec/rails_helper.rb
183
190
  - spec/requests/company_spec.rb
184
191
  - spec/requests/worldpay_spec.rb
185
192
  - spec/services/companies_house_service_spec.rb
186
- - spec/services/worldpay_request_service_spec.rb
193
+ - spec/services/worldpay_payment_service_spec.rb
194
+ - spec/services/worldpay_refund_service_spec.rb
195
+ - spec/services/worldpay_request_handler_service_spec.rb
187
196
  - spec/services/worldpay_response_service_spec.rb
188
197
  - spec/spec_helper.rb
189
198
  - spec/support/helpers/configuration.rb
190
199
  - spec/support/helpers/helpers.rb
191
200
  - spec/support/helpers/waste_carriers_engine.rb
201
+ - spec/support/helpers/xml_matchers.rb
192
202
  - spec/support/pry.rb
193
203
  - spec/support/simplecov.rb
194
204
  homepage: https://github.com/DEFRA/defra-ruby-mocks
@@ -260,12 +270,18 @@ test_files:
260
270
  - spec/support/simplecov.rb
261
271
  - spec/support/pry.rb
262
272
  - spec/support/helpers/helpers.rb
273
+ - spec/support/helpers/xml_matchers.rb
263
274
  - spec/support/helpers/configuration.rb
264
275
  - spec/support/helpers/waste_carriers_engine.rb
265
276
  - spec/lib/configuration_spec.rb
266
- - spec/fixtures/worldpay_request_valid.xml
267
- - spec/fixtures/worldpay_request_invalid.xml
277
+ - spec/fixtures/unrecognised_request.xml
278
+ - spec/fixtures/payment_request_invalid.xml
279
+ - spec/fixtures/refund_request_valid.xml
280
+ - spec/fixtures/payment_request_valid.xml
281
+ - spec/fixtures/refund_request_invalid.xml
268
282
  - spec/rails_helper.rb
269
283
  - spec/services/worldpay_response_service_spec.rb
270
284
  - spec/services/companies_house_service_spec.rb
271
- - spec/services/worldpay_request_service_spec.rb
285
+ - spec/services/worldpay_payment_service_spec.rb
286
+ - spec/services/worldpay_refund_service_spec.rb
287
+ - spec/services/worldpay_request_handler_service_spec.rb
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE paymentService PUBLIC "-//WorldPay//DTD WorldPay PaymentService v1//EN"
3
- "http://dtd.worldpay.com/paymentService_v1.dtd">
4
- <paymentService version="1.4" merchantCode="<%= @merchant_code %>"><reply><orderStatus orderCode="<%= @order_code %>"><reference id="<%= @worldpay_id %>"><%= @worldpay_url %></reference></orderStatus></reply></paymentService>