class Cielo::API30::Client

The Cielo API SDK front-end

Attributes

environment[RW]
merchant[RW]

Public Class Methods

new(merchant, environment = nil) click to toggle source

Create an instance of API client by choosing the environment where the requests will be send

@param merchant [Merchant] The merchant credentials @param environment [Environment] The environment

# File lib/cielo/api30/client.rb, line 13
def initialize(merchant, environment = nil)
  environment ||= Environment.production

  @merchant = merchant
  @environment = environment
end

Public Instance Methods

cancel_payment(payment_id, amount=nil) click to toggle source

Cancel a Payment on Cielo by paymentId and speficying the amount

@param payment_id [String] The payment_id to be queried @param amount [Integer] Order value in cents @return [Payment] The cancelled payment

# File lib/cielo/api30/client.rb, line 42
def cancel_payment(payment_id, amount=nil)
  request = Cielo::API30::Request::UpdateSaleRequest.new("void", merchant, environment)

  request.amount = amount

  request.execute(payment_id)
end
capture_sale(payment_id, amount=nil, service_tax_amount=nil) click to toggle source

Capture a Sale on Cielo by paymentId and specifying the amount and the serviceTaxAmount

@param payment_id [String] The payment_id to be captured @param amount [Integer] Amount of the authorization to be captured @param service_tax_amount [Integer] Amount of the authorization should be destined for the service charge @return [Payment] The captured payment

# File lib/cielo/api30/client.rb, line 57
def capture_sale(payment_id, amount=nil, service_tax_amount=nil)
  request = Cielo::API30::Request::UpdateSaleRequest.new("capture", merchant, environment)

  request.amount = amount
  request.service_tax_amount = service_tax_amount

  request.execute(payment_id)
end
create_sale(sale) click to toggle source

Send the Sale to be created and return the Sale with tid and the status returned by Cielo.

@param sale [Sale] The preconfigured Sale @return [Sale] The Sale with authorization, tid, etc. returned by Cielo.

# File lib/cielo/api30/client.rb, line 25
def create_sale(sale)
  Cielo::API30::Request::CreateSaleRequest.new(merchant, environment).execute(sale)
end
get_sale(payment_id) click to toggle source

Query a Sale on Cielo by paymentId

@param payment_id [String] The payment_id to be queried @return [Sale] The Sale with authorization, tid, etc. returned by Cielo.

# File lib/cielo/api30/client.rb, line 33
def get_sale(payment_id)
  Cielo::API30::Request::QuerySaleRequest.new(merchant, environment).execute(payment_id)
end