class QiwiPay::Api::PaymentOperation

General QiwiPay API payment operation request

Public Instance Methods

perform() click to toggle source

@return [Response]

# File lib/qiwi-pay/api/payment_operation.rb, line 9
def perform
  res = RestClient::Resource.new(
    url,
    ssl_client_cert: credentials.certificate,
    ssl_client_key:  credentials.key,
    verify_ssl:      OpenSSL::SSL::VERIFY_PEER
  ).post(request_params.to_json)

  Response.new res.code, res.body
rescue RestClient::Unauthorized, RestClient::Forbidden
  Response.new 403, 'Access denied'
rescue RestClient::ExceptionWithResponse => e
  Response.new e.response && e.response.code,
               e.response ? e.response.body : e.to_s
end

Private Instance Methods

url() click to toggle source
# File lib/qiwi-pay/api/payment_operation.rb, line 27
def url
  URI::HTTPS.build(
    host: ENDPOINT_HOST,
    path: ENDPOINT_PATH
  ).to_s
end