Skip to content

Commit ff7d771

Browse files
andypalmerdacook
andcommitted
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 <david@redcliffs.net>
1 parent 1797115 commit ff7d771

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/active_merchant/billing/gateways/secure_pay_au.rb

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def build_periodic_item(action, money, credit_card, options)
204204
end
205205
xml.tag! 'amount', amount(money)
206206
xml.tag! 'periodicType', PERIODIC_TYPES[action] if PERIODIC_TYPES[action]
207+
xml.tag! 'transactionReference', options[:order_id] if options[:order_id]
207208

208209
xml.target!
209210
end

test/remote/gateways/remote_secure_pay_au_test.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def setup
2121
@credit_card = credit_card('4242424242424242', {month: 9, year: 15})
2222

2323
@options = {
24-
order_id: '2',
24+
order_id: 'order123',
2525
billing_address: address,
2626
description: 'Store Purchase'
2727
}
@@ -166,6 +166,7 @@ def test_successful_triggered_payment
166166
assert response = @gateway.purchase(12300, 'test1234', @options)
167167
assert_success response
168168
assert_equal response.params['amount'], '12300'
169+
assert_equal response.params['ponum'], 'order123'
169170

170171
assert_equal 'Approved', response.message
171172
end

test/unit/gateways/secure_pay_au_test.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def setup
1313
@amount = 100
1414

1515
@options = {
16-
order_id: '1',
16+
order_id: 'order123',
1717
billing_address: address,
1818
description: 'Store Purchase'
1919
}
@@ -79,6 +79,14 @@ def test_purchase_with_stored_id_calls_commit_periodic
7979
@gateway.purchase(@amount, '123', @options)
8080
end
8181

82+
def test_periodic_payment_submits_order_id
83+
stub_comms(@gateway, :ssl_request) do
84+
@gateway.purchase(@amount, '123', @options)
85+
end.check_request do |method, endpoint, data, headers|
86+
assert_match(/<transactionReference>order123<\/transactionReference>/, data)
87+
end.respond_with(successful_purchase_response)
88+
end
89+
8290
def test_purchase_with_creditcard_calls_commit_with_purchase
8391
@gateway.expects(:commit).with(:purchase, anything)
8492

0 commit comments

Comments
 (0)