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

CyberSource: include paymentSolution for ApplePay and GooglePay #4835

Merged
merged 1 commit into from
Jul 20, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Adyen: Add additional data for airline and lodging [javierpedrozaing] #4815
* MIT: Changed how the payload was sent to the gateway [alejandrofloresm] #4655
* SafeCharge: Add unreferenced_refund field [yunnydang] #4831
* CyberSource: include `paymentSolution` for ApplePay and GooglePay [bbraschi] #4835

== Version 1.131.0 (June 21, 2023)
* Redsys: Add supported countries [jcreiff] #4811
Expand Down
13 changes: 13 additions & 0 deletions lib/active_merchant/billing/gateways/cyber_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ class CyberSourceGateway < Gateway
r703: 'Export hostname_country/ip_country match'
}

@@payment_solution = {
apple_pay: '001',
google_pay: '012'
}

# These are the options that can be used when creating a new CyberSource
# Gateway object.
#
Expand Down Expand Up @@ -322,6 +327,7 @@ def build_auth_request(money, creditcard_or_reference, options)
add_airline_data(xml, options)
add_sales_slip_number(xml, options)
add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
add_payment_solution(xml, creditcard_or_reference.source) if network_tokenization?(creditcard_or_reference)
add_tax_management_indicator(xml, options)
add_stored_credential_subsequent_auth(xml, options)
add_issuer_additional_data(xml, options)
Expand Down Expand Up @@ -393,6 +399,7 @@ def build_purchase_request(money, payment_method_or_reference, options)
add_airline_data(xml, options)
add_sales_slip_number(xml, options)
add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
add_payment_solution(xml, payment_method_or_reference.source) if network_tokenization?(payment_method_or_reference)
add_tax_management_indicator(xml, options)
add_stored_credential_subsequent_auth(xml, options)
add_issuer_additional_data(xml, options)
Expand Down Expand Up @@ -670,6 +677,12 @@ def add_decision_manager_fields(xml, options)
end
end

def add_payment_solution(xml, source)
return unless (payment_solution = @@payment_solution[source])

xml.tag! 'paymentSolution', payment_solution
end

def add_issuer_additional_data(xml, options)
return unless options[:issuer_additional_data]

Expand Down
32 changes: 32 additions & 0 deletions test/unit/gateways/cyber_source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,22 @@ def test_purchase_includes_invoice_header
end.respond_with(successful_purchase_response)
end

def test_purchase_with_apple_pay_includes_payment_solution_001
stub_comms do
@gateway.purchase(100, network_tokenization_credit_card('4242424242424242', source: :apple_pay))
end.check_request do |_endpoint, data, _headers|
assert_match(/<paymentSolution>001<\/paymentSolution>/, data)
end.respond_with(successful_purchase_response)
end

def test_purchase_with_google_pay_includes_payment_solution_012
stub_comms do
@gateway.purchase(100, network_tokenization_credit_card('4242424242424242', source: :google_pay))
end.check_request do |_endpoint, data, _headers|
assert_match(/<paymentSolution>012<\/paymentSolution>/, data)
end.respond_with(successful_purchase_response)
end

def test_purchase_includes_tax_management_indicator
stub_comms do
@gateway.purchase(100, @credit_card, tax_management_indicator: 3)
Expand Down Expand Up @@ -280,6 +296,22 @@ def test_authorize_includes_customer_id
end.respond_with(successful_authorization_response)
end

def test_authorize_with_apple_pay_includes_payment_solution_001
stub_comms do
@gateway.authorize(100, network_tokenization_credit_card('4242424242424242', source: :apple_pay))
end.check_request do |_endpoint, data, _headers|
assert_match(/<paymentSolution>001<\/paymentSolution>/, data)
end.respond_with(successful_authorization_response)
end

def test_authorize_with_google_pay_includes_payment_solution_012
stub_comms do
@gateway.authorize(100, network_tokenization_credit_card('4242424242424242', source: :google_pay))
end.check_request do |_endpoint, data, _headers|
assert_match(/<paymentSolution>012<\/paymentSolution>/, data)
end.respond_with(successful_authorization_response)
end

def test_authorize_includes_merchant_tax_id_in_billing_address_but_not_shipping_address
stub_comms do
@gateway.authorize(100, @credit_card, order_id: '1', merchant_tax_id: '123')
Expand Down
Loading