ruby-on-railsrubyruby-on-rails-5rails-activerecordcybersource

ActiveMerchant Cybersource Authorization Error Reason 102


I'm work on debugging an application that is currently running on Ruby 2.5.8 with ActiveMerchant 1.117.0.

I am able to create and save the subscription successfully. However, when I try to authorize the saved card I keep getting reasonCode 102. The error from the Cybersource gateway side is the subscription () could not be found.

I'm attempting to authorize with the function:

  def authorize(token, amount, order_id, line_items)
    response = gateway.authorize(amount, token, order_id: order_id, line_items: line_items)
    if !response.success?
      raise Exceptions::ChargeFailed.new(response.message, response: response)
    end
    response
  end

The error would lead me to believe that the formatting here is not correct. Can anyone point me to some working ActiveMerchant CyberSource examples for authorizing a subscription or point out what might be wrong here?


Solution

  • After some digging, it appears that the logic for token assignment changed inside of the ActiveMerchant CyberSource gem

    The original logic was:

    if reference
        _, subscription_id, _ = reference.split(";")
        xml.tag! 'subscriptionID',  subscription_id
    end
    

    The latest versions this shifted towards:

    if reference
        subscription_id = reference.split(";")[6]
        xml.tag! 'subscriptionID',  subscription_id
    end
    

    The application that I am working with previously had been formatting the CyberSource profile / subscription id as ;#{token};. In order to work with these latest updates the token needs to be formatted as ;;;;;;#{token}.