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

SafeCharge: add card holder verification fields #5252

Merged
merged 1 commit into from
Sep 10, 2024
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 @@ -33,6 +33,7 @@
* StripePI: Add metadata for GooglePay FPAN [almalee24] #5242
* Paypal: Add inquire method [almalee24] #5231
* Adyen: Enable multiple legs within airline data [jcreiff] #5249
* SafeCharge: Add card holder verification fields [yunnydang] #5252

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/gateways/safe_charge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ def add_customer_details(post, payment, options)
post[:sg_Zip] = address[:zip] if address[:zip]
post[:sg_Country] = address[:country] if address[:country]
post[:sg_Phone] = address[:phone] if address[:phone]
post[:sg_middleName] = options[:middle_name] if options[:middle_name]
post[:sg_doCardHolderNameVerification] = options[:card_holder_verification] if options[:card_holder_verification]
end

post[:sg_Email] = options[:email]
Expand Down
7 changes: 7 additions & 0 deletions test/remote/gateways/remote_safe_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ def test_successful_purchase
assert_equal 'Success', response.message
end

def test_successful_purchase_with_card_holder_verification
response = @gateway.purchase(@amount, @credit_card, @options.merge(middle_name: 'middle', card_holder_verification: 1))
assert_success response
assert_equal 'Success', response.message
assert_equal '', response.params['cardholdernameverification']
end

def test_successful_purchase_with_token
response = @gateway.purchase(@amount, @credit_card, @options)
assert_success response
Expand Down
15 changes: 15 additions & 0 deletions test/unit/gateways/safe_charge_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ def test_successful_purchase_with_truthy_stored_credential_mode
assert purchase.test?
end

def test_successful_purchase_with_card_holder_verification
purchase = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(middle_name: 'middle', card_holder_verification: 1))
end.check_request do |_endpoint, data, _headers|
assert_match(/sg_middleName=middle/, data)
assert_match(/sg_doCardHolderNameVerification=1/, data)
end.respond_with(successful_purchase_response)

assert_success purchase
assert_equal '111951|101508189567|ZQBpAFAASABGAHAAVgBPAFUAMABiADMAewBtAGsAd' \
'AAvAFIAQQBrAGoAYwBxACoAXABHAEEAOgA3ACsAMgA4AD0AOABDAG4AbQAzAF' \
'UAbQBYAFIAMwA=|%02d|%d|1.00|USD' % [@credit_card.month, @credit_card.year.to_s[-2..-1]], purchase.authorization
assert purchase.test?
end

def test_successful_purchase_with_falsey_stored_credential_mode
purchase = stub_comms do
@gateway.purchase(@amount, @credit_card, @options.merge(stored_credential_mode: false))
Expand Down
Loading