Class: Braspag::Order
- Inherits:
-
Object
- Object
- Braspag::Order
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/cbraspag/core/order.rb
Defined Under Namespace
Classes: AssociationValidator, InstallmentsTypeValidator, PaymentMethodValidator
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#gateway_amount ⇒ Object
Returns the value of attribute gateway_amount.
-
#gateway_authorization ⇒ Object
Returns the value of attribute gateway_authorization.
-
#gateway_capture_amount ⇒ Object
Returns the value of attribute gateway_capture_amount.
-
#gateway_capture_message ⇒ Object
Returns the value of attribute gateway_capture_message.
-
#gateway_capture_return_code ⇒ Object
Returns the value of attribute gateway_capture_return_code.
-
#gateway_capture_status ⇒ Object
Returns the value of attribute gateway_capture_status.
-
#gateway_id ⇒ Object
Returns the value of attribute gateway_id.
-
#gateway_message ⇒ Object
Returns the value of attribute gateway_message.
-
#gateway_return_code ⇒ Object
Returns the value of attribute gateway_return_code.
-
#gateway_status ⇒ Object
Returns the value of attribute gateway_status.
-
#gateway_void_amount ⇒ Object
Returns the value of attribute gateway_void_amount.
-
#gateway_void_message ⇒ Object
Returns the value of attribute gateway_void_message.
-
#gateway_void_return_code ⇒ Object
Returns the value of attribute gateway_void_return_code.
-
#gateway_void_status ⇒ Object
Returns the value of attribute gateway_void_status.
-
#id ⇒ Object
Returns the value of attribute id.
-
#installments ⇒ Object
Returns the value of attribute installments.
-
#installments_type ⇒ Object
Returns the value of attribute installments_type.
-
#payment_method ⇒ Object
Returns the value of attribute payment_method.
Instance Method Summary collapse
- #convert_to(method) ⇒ Object
- #no_interest? ⇒ Boolean
- #populate!(method, response) ⇒ Object
- #populate_authorize!(response) ⇒ Object
- #populate_capture!(response) ⇒ Object
- #populate_generate_billet!(response) ⇒ Object
- #populate_void!(response) ⇒ Object
- #to_authorize ⇒ Object
- #to_capture ⇒ Object
- #to_generate_billet ⇒ Object
- #to_void ⇒ Object
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def amount @amount end |
#customer ⇒ Object
Returns the value of attribute customer.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def customer @customer end |
#gateway_amount ⇒ Object
Returns the value of attribute gateway_amount.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def gateway_amount @gateway_amount end |
#gateway_authorization ⇒ Object
Returns the value of attribute gateway_authorization.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def @gateway_authorization end |
#gateway_capture_amount ⇒ Object
Returns the value of attribute gateway_capture_amount.
113 114 115 |
# File 'lib/cbraspag/core/order.rb', line 113 def gateway_capture_amount @gateway_capture_amount end |
#gateway_capture_message ⇒ Object
Returns the value of attribute gateway_capture_message.
113 114 115 |
# File 'lib/cbraspag/core/order.rb', line 113 def @gateway_capture_message end |
#gateway_capture_return_code ⇒ Object
Returns the value of attribute gateway_capture_return_code.
113 114 115 |
# File 'lib/cbraspag/core/order.rb', line 113 def gateway_capture_return_code @gateway_capture_return_code end |
#gateway_capture_status ⇒ Object
Returns the value of attribute gateway_capture_status.
113 114 115 |
# File 'lib/cbraspag/core/order.rb', line 113 def gateway_capture_status @gateway_capture_status end |
#gateway_id ⇒ Object
Returns the value of attribute gateway_id.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def gateway_id @gateway_id end |
#gateway_message ⇒ Object
Returns the value of attribute gateway_message.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def @gateway_message end |
#gateway_return_code ⇒ Object
Returns the value of attribute gateway_return_code.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def gateway_return_code @gateway_return_code end |
#gateway_status ⇒ Object
Returns the value of attribute gateway_status.
112 113 114 |
# File 'lib/cbraspag/core/order.rb', line 112 def gateway_status @gateway_status end |
#gateway_void_amount ⇒ Object
Returns the value of attribute gateway_void_amount.
114 115 116 |
# File 'lib/cbraspag/core/order.rb', line 114 def gateway_void_amount @gateway_void_amount end |
#gateway_void_message ⇒ Object
Returns the value of attribute gateway_void_message.
114 115 116 |
# File 'lib/cbraspag/core/order.rb', line 114 def @gateway_void_message end |
#gateway_void_return_code ⇒ Object
Returns the value of attribute gateway_void_return_code.
114 115 116 |
# File 'lib/cbraspag/core/order.rb', line 114 def gateway_void_return_code @gateway_void_return_code end |
#gateway_void_status ⇒ Object
Returns the value of attribute gateway_void_status.
114 115 116 |
# File 'lib/cbraspag/core/order.rb', line 114 def gateway_void_status @gateway_void_status end |
#id ⇒ Object
Returns the value of attribute id.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def id @id end |
#installments ⇒ Object
Returns the value of attribute installments.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def installments @installments end |
#installments_type ⇒ Object
Returns the value of attribute installments_type.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def installments_type @installments_type end |
#payment_method ⇒ Object
Returns the value of attribute payment_method.
111 112 113 |
# File 'lib/cbraspag/core/order.rb', line 111 def payment_method @payment_method end |
Instance Method Details
#convert_to(method) ⇒ Object
149 150 151 152 153 154 |
# File 'lib/cbraspag/core/order.rb', line 149 def convert_to(method) data = {} data = self.send("to_#{method}") if self.respond_to?("to_#{method}") data.merge!(self.customer.convert_to(method)) if self.customer data end |
#no_interest? ⇒ Boolean
141 142 143 144 145 146 147 |
# File 'lib/cbraspag/core/order.rb', line 141 def no_interest? case installments_type when Braspag::INTEREST[:no], Braspag::INTEREST[:no_iata] true end end |
#populate!(method, response) ⇒ Object
186 187 188 |
# File 'lib/cbraspag/core/order.rb', line 186 def populate!(method, response) self.send("populate_#{method}!", response) end |
#populate_authorize!(response) ⇒ Object
190 191 192 193 194 195 196 197 |
# File 'lib/cbraspag/core/order.rb', line 190 def (response) self. = response[:number] self.gateway_id = response[:transaction_id] self.gateway_return_code = response[:return_code] self.gateway_status = response[:status] self. = response[:message] self.gateway_amount = Converter::string_to_decimal(response[:amount]) end |
#populate_capture!(response) ⇒ Object
199 200 201 202 203 204 205 206 |
# File 'lib/cbraspag/core/order.rb', line 199 def populate_capture!(response) #TODO: CHECK IF IS NECESSARY # self.gateway_capture_id = response[:transaction_id] self.gateway_capture_return_code = response[:return_code] self.gateway_capture_status = response[:status] self. = response[:message] self.gateway_capture_amount = Converter::string_to_decimal(response[:amount]) end |
#populate_generate_billet!(response) ⇒ Object
217 218 219 220 221 |
# File 'lib/cbraspag/core/order.rb', line 217 def populate_generate_billet!(response) self.gateway_return_code = response[:return_code] self.gateway_status = response[:status] self.gateway_amount = BigDecimal.new(response[:amount].to_s) if response[:amount] end |
#populate_void!(response) ⇒ Object
208 209 210 211 212 213 214 215 |
# File 'lib/cbraspag/core/order.rb', line 208 def populate_void!(response) #TODO: CHECK IF IS NECESSARY # self.gateway_void_id = response[:transaction_id] self.gateway_void_return_code = response[:return_code] self.gateway_void_status = response[:status] self. = response[:message] self.gateway_void_amount = Converter::string_to_decimal(response[:amount]) end |
#to_authorize ⇒ Object
156 157 158 159 160 161 162 163 164 |
# File 'lib/cbraspag/core/order.rb', line 156 def { :order_id => self.id.to_s, :amount => self.amount, :payment_method => self.payment_method, :number_payments => self.installments, :type => self.installments_type, } end |
#to_capture ⇒ Object
166 167 168 169 170 |
# File 'lib/cbraspag/core/order.rb', line 166 def to_capture { :order_id => self.id.to_s } end |
#to_generate_billet ⇒ Object
178 179 180 181 182 183 184 |
# File 'lib/cbraspag/core/order.rb', line 178 def to_generate_billet { :order_id => self.id.to_s, :amount => self.amount, :payment_method => self.payment_method } end |
#to_void ⇒ Object
172 173 174 175 176 |
# File 'lib/cbraspag/core/order.rb', line 172 def to_void { :order_id => self.id.to_s } end |