活跃的商家gem:无法建立与远程服务器的SSL连接

时间:2019-06-18 15:25:32

标签: activemerchant

*这是专门针对active_merchant gem

我正在尝试创建一个新的支付网关。但是,在为我的付款网关运行远程测试时,遇到错误:The SSL connection to the remote server could not be established

如果能帮助我们找出原因,将不胜感激。

我的付款网关代码:

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    class JReserveGateway < Gateway
      self.test_url = 'https://test.j-reserve.com:10443/ros/settlement.php'

      self.supported_countries = ['JPY']
      self.default_currency = 'JPY'
      self.supported_cardtypes = [:visa, :master, :american_express]

      self.homepage_url = 'http://www.example.net/'
      self.money_format = :cents

      STANDARD_ERROR_CODE_MAPPING = {
        # '101' => STANDARD_ERROR_CODE[:incorrect_number],
      }

      def initialize(options={})
        requires!(options, :member_code)
        super
      end

      def purchase(money, payment, options={})
        post = {
          "job" => "AUTH",
          "member_code" => 9999999999,
          "proposal_code" => "testCode1",
          "card_brand" => "VISA",
          "card_number" => 4111111111111111,
          "expire_year" => 2019,
          "expire_month" => 9,
          "amount" => 1000,
          "cancel_base_fee" => 100,
          "sales_start" => "2020-07-01",
          "sales_end" => "2020-07-02",
          "customer_email" => "test@gmail.com",
          "customer_name" => "kiong"
        }

        commit('COMMMIT', post)
      end

      private

        def commit(action, parameters)
          url = (test? ? test_url : live_url)
          params = parameters.to_json
          raw_response = ssl_post(url, params, request_headers)
          response = parse(raw_response)

          Response.new(
            success_from(response),
            message_from(response),
            response,
            authorization: authorization_from(response),
            avs_result: AVSResult.new(code: response["some_avs_response_key"]),
            cvv_result: CVVResult.new(response["some_cvv_response_key"]),
            test: test?,
            error_code: error_code_from(response)
          )
        end

        def request_headers()
          {
            'Content-Type' => 'application/json',
          }
        end
    end
  end
end

0 个答案:

没有答案