Class: Cielo::API30::Client
- Inherits:
-
Object
- Object
- Cielo::API30::Client
- Defined in:
- lib/cielo/api30/client.rb
Overview
The Cielo API SDK front-end
Instance Attribute Summary collapse
-
#environment ⇒ Object
writeonly
Sets the attribute environment.
-
#merchant ⇒ Object
writeonly
Sets the attribute merchant.
Instance Method Summary collapse
-
#cancel_payment(payment_id, amount = nil) ⇒ Payment
Cancel a Payment on Cielo by paymentId and speficying the amount.
-
#capture_sale(payment_id, amount = nil, service_tax_amount = nil) ⇒ Payment
Capture a Sale on Cielo by paymentId and specifying the amount and the serviceTaxAmount.
-
#create_sale(sale) ⇒ Sale
Send the Sale to be created and return the Sale with tid and the status returned by Cielo.
-
#get_sale(payment_id) ⇒ Sale
Query a Sale on Cielo by paymentId.
-
#initialize(merchant, environment = nil) ⇒ Client
constructor
Create an instance of API client by choosing the environment where the requests will be send.
Constructor Details
#initialize(merchant, environment = nil) ⇒ Client
Create an instance of API client by choosing the environment where the requests will be send
13 14 15 16 17 18 |
# File 'lib/cielo/api30/client.rb', line 13 def initialize(merchant, environment = nil) environment ||= Environment.production @merchant = merchant @environment = environment end |
Instance Attribute Details
#environment=(value) ⇒ Object
Sets the attribute environment
5 6 7 |
# File 'lib/cielo/api30/client.rb', line 5 def environment=(value) @environment = value end |
#merchant=(value) ⇒ Object
Sets the attribute merchant
5 6 7 |
# File 'lib/cielo/api30/client.rb', line 5 def merchant=(value) @merchant = value end |
Instance Method Details
#cancel_payment(payment_id, amount = nil) ⇒ Payment
Cancel a Payment on Cielo by paymentId and speficying the amount
42 43 44 45 46 47 48 |
# 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) ⇒ Payment
Capture a Sale on Cielo by paymentId and specifying the amount and the serviceTaxAmount
57 58 59 60 61 62 63 64 |
# 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 |