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

Barclaycard Smartpay: Add support for shopper_statement gateway-specific field #3319

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 @@ -11,6 +11,7 @@
* Fat Zebra: Send metadata for purchase and authorize [montdidier] #3101
* TrustCommerce: Add support for custom fields [jasonxp] #3313
* Stripe Payment Intents: Support option fields `transfer_destination` and `transfer_amount` and remove `transfer_data` hash [britth] #3317
* Barclaycard Smartpay: Add support for `shopperStatement` gateway-specific field [jasonxp] #3319

== Version 1.97.0 (Aug 15, 2019)
* CyberSource: Add issuer `additionalData` gateway-specific field [jasonxp] #3296
Expand Down
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def authorize(money, creditcard, options = {})
post[:card] = credit_card_hash(creditcard)
post[:billingAddress] = billing_address_hash(options) if options[:billing_address]
post[:deliveryAddress] = shipping_address_hash(options) if options[:shipping_address]
post[:shopperStatement] = options[:shopper_statement] if options[:shopper_statement]

add_3ds(post, options)
commit('authorise', post)
end
Expand Down
11 changes: 11 additions & 0 deletions test/remote/gateways/remote_barclaycard_smartpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@ def test_successful_purchase_with_device_fingerprint
assert_equal '[capture-received]', response.message
end

def test_successful_purchase_with_shopper_statement
response = @gateway.purchase(
@amount,
@credit_card,
@options.merge(shopper_statement: 'One-year premium subscription')
)

assert_success response
assert_equal '[capture-received]', response.message
end

def test_successful_authorize_with_3ds
assert response = @gateway.authorize(@amount, @three_ds_enrolled_card, @options.merge(execute_threed: true))
assert_equal 'RedirectShopper', response.message
Expand Down
19 changes: 16 additions & 3 deletions test/unit/gateways/barclaycard_smartpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,24 @@ def test_successful_authorize_with_shipping_house_number_and_street
end

def test_successful_authorize_with_extra_options
shopper_interaction = 'ContAuth'
shopper_statement = 'One-year premium subscription'
device_fingerprint = 'abcde123'

response = stub_comms do
@gateway.authorize(@amount, @credit_card, @options.merge(shopper_interaction: 'ContAuth', device_fingerprint: 'abcde123'))
@gateway.authorize(
@amount,
@credit_card,
@options.merge(
shopper_interaction: shopper_interaction,
device_fingerprint: device_fingerprint,
shopper_statement: shopper_statement
)
)
end.check_request do |endpoint, data, headers|
assert_match(/shopperInteraction=ContAuth/, data)
assert_match(/deviceFingerprint=abcde123/, data)
assert_match(/shopperInteraction=#{shopper_interaction}/, data)
assert_match(/shopperStatement=#{Regexp.quote(CGI.escape(shopper_statement))}/, data)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_match(/deviceFingerprint=#{device_fingerprint}/, data)
end.respond_with(successful_authorize_response)

assert_success response
Expand Down