Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Airwallex: Support metadata for payment_intents #5309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/active_merchant/billing/gateways/airwallex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def create_payment_intent(money, options = {})
post[:merchant_order_id] = merchant_order_id(options)
add_referrer_data(post)
add_descriptor(post, options)
add_metadata(post, options)
post['payment_method_options'] = { 'card' => { 'risk_control' => { 'three_ds_action' => 'SKIP_3DS' } } } if options[:skip_3ds]

response = commit(:setup, post)
Expand All @@ -176,6 +177,10 @@ def create_payment_intent(money, options = {})
response.params['id']
end

def add_metadata(post, options)
post[:metadata] = options[:metadata] if options[:metadata]
end

def add_billing(post, card, options = {})
return unless has_name_info?(card)

Expand Down
9 changes: 9 additions & 0 deletions test/unit/gateways/airwallex_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@ def test_purchase_passes_referrer_data
end.respond_with(successful_purchase_response)
end

def test_purchase_passes_metadata
stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(metadata: { some: 'value' }))
end.check_request do |_endpoint, data, _headers|
# only look for referrer data on the create_payment_intent request
assert_match(/\"metadata\":{\"some\":\"value\"}/, data) if data.include?('_setup')
end.respond_with(successful_purchase_response)
end

def test_purchase_passes_descriptor
stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(description: 'a simple test'))
Expand Down