Skip to content

Commit

Permalink
Rapyd: Add merchant_reference_id
Browse files Browse the repository at this point in the history
This maps order_id to the merchant_reference_id field at Rapyd

CER-831
  • Loading branch information
jcreiff committed Aug 18, 2023
1 parent a0538f5 commit d39ccdd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Deepstack: Add Deepstack Gateway [khoinguyendeepstack] #4830
* Braintree: Additional tests for credit transactions [jcreiff] #4848
* Rapyd: Change nesting of description, statement_descriptor, complete_payment_url, and error_payment_url [jcreiff] #4849
* Rapyd: Add merchant_reference_id [jcreiff] #4858


== Version 1.134.0 (July 25, 2023)
Expand Down
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/rapyd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def add_address(post, creditcard, options)
def add_invoice(post, money, options)
post[:amount] = money.zero? ? 0 : amount(money).to_f.to_s
post[:currency] = (options[:currency] || currency(money))
post[:merchant_reference_id] = options[:merchant_reference_id] || options[:order_id]
end

def add_payment(post, payment, options)
Expand Down
3 changes: 2 additions & 1 deletion test/remote/gateways/remote_rapyd_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def setup
description: 'Describe this transaction',
statement_descriptor: 'Statement Descriptor',
email: 'test@example.com',
billing_address: address(name: 'Jim Reynolds')
billing_address: address(name: 'Jim Reynolds'),
order_id: '987654321'
}
@ach_options = {
pm_type: 'us_ach_bank',
Expand Down
18 changes: 17 additions & 1 deletion test/unit/gateways/rapyd_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def setup
description: 'Describe this transaction',
statement_descriptor: 'Statement Descriptor',
email: 'test@example.com',
billing_address: address(name: 'Jim Reynolds')
billing_address: address(name: 'Jim Reynolds'),
order_id: '987654321'
}

@metadata = {
Expand Down Expand Up @@ -87,6 +88,21 @@ def test_successful_purchase_with_payment_options
assert_match(/"error_payment_url":"www.google.com"/, data)
assert_match(/"description":"Describe this transaction"/, data)
assert_match(/"statement_descriptor":"Statement Descriptor"/, data)
assert_match(/"merchant_reference_id":"987654321"/, data)
end.respond_with(successful_authorize_response)

assert_success response
end

def test_successful_purchase_with_explicit_merchant_reference_id
response = stub_comms(@gateway, :ssl_request) do
@gateway.purchase(@amount, @credit_card, @options.merge({ merchant_reference_id: '99988877776' }))
end.check_request do |_method, _endpoint, data, _headers|
assert_match(/"complete_payment_url":"www.google.com"/, data)
assert_match(/"error_payment_url":"www.google.com"/, data)
assert_match(/"description":"Describe this transaction"/, data)
assert_match(/"statement_descriptor":"Statement Descriptor"/, data)
assert_match(/"merchant_reference_id":"99988877776"/, data)
end.respond_with(successful_authorize_response)

assert_success response
Expand Down

0 comments on commit d39ccdd

Please sign in to comment.