Class: Braspag::API
- Inherits:
-
Object
- Object
- Braspag::API
- Defined in:
- lib/braspag/api.rb,
lib/braspag/api/version.rb
Overview
The Braspag API SDK front-end
Constant Summary collapse
- VERSION =
Versão da gem
"1.0.0"
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 Braspag by paymentId and speficying the amount.
-
#capture_sale(payment_id, amount = nil, service_tax_amount = nil) ⇒ Payment
Capture a Sale on Braspag 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 Braspag.
-
#get_sale(payment_id) ⇒ Sale
Query a Sale on Braspag by paymentId.
-
#initialize(merchant, environment = nil) ⇒ API
constructor
Create an instance of API by choosing the environment where the requests will be send.
Constructor Details
#initialize(merchant, environment = nil) ⇒ API
Create an instance of API by choosing the environment where the requests will be send
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/braspag/api.rb', line 26 def initialize( merchant, environment = nil) if (environment == nil) environment = Environment.production() end @merchant = merchant @environment = environment end |
Instance Attribute Details
#environment=(value) ⇒ Object
Sets the attribute environment
18 19 20 |
# File 'lib/braspag/api.rb', line 18 def environment=(value) @environment = value end |
#merchant=(value) ⇒ Object
Sets the attribute merchant
18 19 20 |
# File 'lib/braspag/api.rb', line 18 def merchant=(value) @merchant = value end |
Instance Method Details
#cancel_payment(payment_id, amount = nil) ⇒ Payment
Cancel a Payment on Braspag by paymentId and speficying the amount
64 65 66 67 68 69 70 |
# File 'lib/braspag/api.rb', line 64 def cancel_payment(payment_id, amount=nil) request = Braspag::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 Braspag by paymentId and specifying the amount and the serviceTaxAmount
79 80 81 82 83 84 85 86 |
# File 'lib/braspag/api.rb', line 79 def capture_sale(payment_id, amount=nil, service_tax_amount=nil) request = Braspag::Request::UpdateSaleRequest.new("capture", merchant, environment) request.amount = amount request.service_tax_amount = service_tax_amount request.execute(payment_id) end |
#create_sale(sale) ⇒ Sale
Send the Sale to be created and return the Sale with tid and the status returned by Braspag.
43 44 45 46 47 |
# File 'lib/braspag/api.rb', line 43 def create_sale(sale) request = Braspag::Request::CreateSaleRequest.new(merchant, environment) request.execute(sale) end |
#get_sale(payment_id) ⇒ Sale
Query a Sale on Braspag by paymentId
53 54 55 56 57 |
# File 'lib/braspag/api.rb', line 53 def get_sale(payment_id) request = Braspag::Request::QuerySaleRequest.new(merchant, environment) request.execute(payment_id) end |