def process_response(payment_transaction, response)
      if response.processing? || response.approved?
        validate = :validate_response_on_success
        update   = :update_payment_transaction_on_success
      else
        validate = :validate_response_on_error
        update   = :update_payment_transaction_on_error
      end

      begin
        send validate, payment_transaction, response
      rescue Exception => error
        payment_transaction.add_error error
        payment_transaction.status = PaymentTransaction::STATUS_ERROR

        raise error
      end

      send update, payment_transaction, response

      if response.error?
        raise response.error
      end

      response
    end
def process_response(payment_transaction, response)
      if response.processing? || response.approved?
        validate = :validate_response_on_success
        update   = :update_payment_transaction_on_success
      else
        validate = :validate_response_on_error
        update   = :update_payment_transaction_on_error
      end

      begin
        send validate, payment_transaction, response
      rescue Exception => error
        payment_transaction.add_error error
        payment_transaction.status = PaymentTransaction::STATUS_ERROR

        raise error
      end

      send update, payment_transaction, response

      if response.error?
        raise response.error
      end

      response
    end
Process API gateway response and update payment transaction

 @param    payment_transaction   [PaymentTransaction]    Payment transaction for update
 @param    response              [Response]              API gateway response

 @return                         [Response]              API gateway response