Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Some gateways want the gateway order_id to be consistent for transactions on the same order #4221

Closed
RyanofWoods opened this issue Dec 10, 2021 · 1 comment

Comments

@RyanofWoods
Copy link
Contributor

RyanofWoods commented Dec 10, 2021

Issue
When a payment gets processed it provides an order-id in the gateway_options to go to the gateway. Because of issue, spree/spree#1998 the sent order-id was changed to be unique for each transaction. For some gateways this is important so multiple transactions against the order do not get rejected as a duplicate. (see issue.)

# The unique identifier to be passed in to the payment gateway
def gateway_order_id
"#{order.number}-#{number}"
end

However, for solidus_paypal_braintree this is a problem. Because they offer velocity checks, where for example you can set up a rule to reject the transaction if so many have been made with the same order-id.

We had a problem with credit card attacks and couldn't use this rule because the order-id was different even though the transactions belonged to the same order.


Would it be best for gateways/payment methods just to override this param themselves or have a configuration method?

module Spree
  class Payment < Spree::Base
    module Processing
        # The unique identifier to be passed in to the payment gateway
        def gateway_order_id
           if payment_method&.consistent_gateway_order_id?
             order.number
           else
             "#{order.number}-#{number}"
           end
        end
    end
  end
end

module SolidusPaypalBraintree
  class Gateway < ::Spree::PaymentMethod
    def consistent_gateway_order_id?
      true
    end
  end
end

Additional context
I am writing this as part of the bigger issue on solidus_paypal_braintree:
solidusio/solidus_paypal_braintree#309

@RyanofWoods RyanofWoods changed the title Not all gateways want a payment gateways_order_id to change per order transactions Some gateways want the gateway order_id to be consistent for transactions on the same order Dec 10, 2021
@jarednorman
Copy link
Member

We could make the gateway order ID logic configurable, or perhaps a more sensible thing could be to delegate to the gateway for it.

@solidusio solidusio locked and limited conversation to collaborators Sep 2, 2022
@kennyadsl kennyadsl converted this issue into discussion #4540 Sep 2, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants