active_merchant icon indicating copy to clipboard operation
active_merchant copied to clipboard

Support Quickbooks Payments OAuth2 by Dec 17, 2019

Open vanboom opened this issue 6 years ago • 3 comments

Quickbooks Online API Access will require OAuth2 by Dec 17, 2019.

vanboom avatar Sep 25 '19 15:09 vanboom

This seems to be completed with release 1.101.0, however, the documentation has not been updated to reflect the appropriate usage of OAuth2 implementation.

I tried to parse the test cases to identify the appropriate use of the implementation, but I'm confused on the requirement to provide access_token and refresh_token on constructing the gateway. In the intuit documentation, you only need to provide the client_id and secret, so should these just be placeholders?

If there is any example code of this functionality being used, please let me know. Thanks in advance!

daniela-genebygene avatar Jan 06 '20 17:01 daniela-genebygene

I have been using this version of the Quickbooks gateway on my fork... https://github.com/vanboom/active_merchant/blob/4e6e43bef685c7c0c454824d1e325551412cc0e5/lib/active_merchant/billing/gateways/quickbooks_oauth2.rb

It initializes with the access token (and no refresh token). Notice that my my fork does not have any of the refresh token logic in it. I do not think it is the job of ActiveMerchant to refresh the access token. Honestly I am not sure where my version came from - maybe it was posted here at some point in time. Imho the master version here needs some work to remove the backward compatibility logic and access token refresh logic. I would be happy to issue a PR if some folks could use this. I have been using my fork because it seems like this gateway is not heavily used or maintained here so I don't want to add a PR to the big PR pile.


  gateway = ActiveMerchant::Billing::QuickbooksOauth2Gateway.new(
        :consumer_key=>client_id,
        :consumer_secret=>client_secret,
        :access_token=>oauth_access_token.token || "",
        :token_secret=>refresh_token || "",
        :realm=>company_id || "",
        :test=>true
      )

vanboom avatar Sep 06 '21 18:09 vanboom

Another note about refreshing the access token...

The gateway calls will fail if the access_token is not accepted by Quickbooks. I think it is the job of the application level error handling to refresh the access token (i.e. manage the authentication with Quickbooks), and the job of ActiveMerchant to use the access_token to process transactions. Suggested in #4104

vanboom avatar Sep 06 '21 18:09 vanboom