From 1f112156ce72e40dca6a5d093aedf18c994d5f4b Mon Sep 17 00:00:00 2001 From: Andy Palmer Date: Fri, 23 Mar 2018 13:03:21 +1100 Subject: [PATCH 1/3] SecurePayAU: Fix remote tests test/remote/gateways/remote_secure_pay_au_test.rb 18 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- test/remote/gateways/remote_secure_pay_au_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/remote/gateways/remote_secure_pay_au_test.rb b/test/remote/gateways/remote_secure_pay_au_test.rb index 13323f9572b..202b5f44e0c 100644 --- a/test/remote/gateways/remote_secure_pay_au_test.rb +++ b/test/remote/gateways/remote_secure_pay_au_test.rb @@ -5,6 +5,10 @@ class MyCreditCard include ActiveMerchant::Billing::CreditCardMethods attr_accessor :number, :month, :year, :first_name, :last_name, :verification_value, :brand + def initialize(params) + params.each { |k,v| instance_variable_set("@#{k.to_s}".to_sym,v) } + end + def verification_value? !@verification_value.blank? end @@ -94,10 +98,11 @@ def test_failed_refund assert response = @gateway.refund(@amount + 1, authorization) assert_failure response - assert_equal 'Only $1.0 available for refund', response.message + assert_equal 'Only 1.00 AUD available for refund', response.message end def test_successful_void + omit("It appears that SecurePayAU no longer supports void") assert response = @gateway.authorize(@amount, @credit_card, @options) assert_success response @@ -110,6 +115,7 @@ def test_successful_void end def test_failed_void + omit("It appears that SecurePayAU no longer supports void") assert response = @gateway.purchase(@amount, @credit_card, @options) assert_success response authorization = response.authorization From 27c058490a9db33885e5198b3f8b5358ab1673f6 Mon Sep 17 00:00:00 2001 From: Andy Palmer Date: Fri, 23 Mar 2018 13:03:21 +1100 Subject: [PATCH 2/3] SecurePayAU: Send Content-Type headers test/unit/gateways/secure_pay_au_test.rb 24 tests, 106 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed test/remote/gateways/remote_secure_pay_au_test.rb 18 tests, 56 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed --- lib/active_merchant/billing/gateways/secure_pay_au.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb index 13f37c96254..a23c6f65967 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_au.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb @@ -181,7 +181,7 @@ def build_request(action, body) end def commit(action, request) - response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request))) + response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request), {"Content-Type" => "text/xml; charset=utf-8"})) Response.new( success?(response), @@ -241,7 +241,7 @@ def build_periodic_request(body) def commit_periodic(request) my_request = build_periodic_request(request) - response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, my_request)) + response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, my_request, {"Content-Type" => "text/xml; charset=utf-8"})) Response.new( success?(response), From 1b6481a80104b18ffd598ff83efa72a34a968bfc Mon Sep 17 00:00:00 2001 From: Andy Palmer Date: Fri, 23 Mar 2018 13:03:21 +1100 Subject: [PATCH 3/3] SecurePayAU: Send order ID for payments with stored cards As per XML spec (https://auspost.com.au/payments/docs/securepay/resources/API_Card_Storage_and_Scheduled_Payments.pdf ) test/unit/gateways/secure_pay_au_test.rb 24 tests, 106 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed test/remote/gateways/remote_secure_pay_au_test.rb 18 tests, 57 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications 100% passed Co-authored-by: David Cook --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/secure_pay_au.rb | 1 + test/remote/gateways/remote_secure_pay_au_test.rb | 3 ++- test/unit/gateways/secure_pay_au_test.rb | 10 +++++++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0634a804b2a..d2582ceef7d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Decidir: Pass CVV for NT [almalee24] #5205 * NMI: Add customer vault fields [yunnydang] #5215 * CheckoutV2: Add inquire method [almalee24] #5209 +* SecurePayAU: Send order ID for payments with stored card [dacook] #3979 == Version 1.137.0 (August 2, 2024) * Unlock dependency on `rexml` to allow fixing a CVE (#5181). diff --git a/lib/active_merchant/billing/gateways/secure_pay_au.rb b/lib/active_merchant/billing/gateways/secure_pay_au.rb index a23c6f65967..0e7de2a701f 100644 --- a/lib/active_merchant/billing/gateways/secure_pay_au.rb +++ b/lib/active_merchant/billing/gateways/secure_pay_au.rb @@ -207,6 +207,7 @@ def build_periodic_item(action, money, credit_card, options) end xml.tag! 'amount', amount(money) xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action] + xml.tag! 'transactionReference', options[:order_id] if options[:order_id] xml.target! end diff --git a/test/remote/gateways/remote_secure_pay_au_test.rb b/test/remote/gateways/remote_secure_pay_au_test.rb index 202b5f44e0c..41fefc26397 100644 --- a/test/remote/gateways/remote_secure_pay_au_test.rb +++ b/test/remote/gateways/remote_secure_pay_au_test.rb @@ -21,7 +21,7 @@ def setup @credit_card = credit_card('4242424242424242', { month: 9, year: 15 }) @options = { - order_id: '2', + order_id: 'order123', billing_address: address, description: 'Store Purchase' } @@ -166,6 +166,7 @@ def test_successful_triggered_payment assert response = @gateway.purchase(12300, 'test1234', @options) assert_success response assert_equal response.params['amount'], '12300' + assert_equal response.params['ponum'], 'order123' assert_equal 'Approved', response.message end diff --git a/test/unit/gateways/secure_pay_au_test.rb b/test/unit/gateways/secure_pay_au_test.rb index 4bbd0213712..88f9a83f32c 100644 --- a/test/unit/gateways/secure_pay_au_test.rb +++ b/test/unit/gateways/secure_pay_au_test.rb @@ -13,7 +13,7 @@ def setup @amount = 100 @options = { - order_id: '1', + order_id: 'order123', billing_address: address, description: 'Store Purchase' } @@ -79,6 +79,14 @@ def test_purchase_with_stored_id_calls_commit_periodic @gateway.purchase(@amount, '123', @options) end + def test_periodic_payment_submits_order_id + stub_comms(@gateway, :ssl_request) do + @gateway.purchase(@amount, '123', @options) + end.check_request do |method, endpoint, data, headers| + assert_match(/order123<\/transactionReference>/, data) + end.respond_with(successful_purchase_response) + end + def test_purchase_with_creditcard_calls_commit_with_purchase @gateway.expects(:commit).with(:purchase, anything)