Class: Braspag::Billet
- Inherits:
-
Object
- Object
- Braspag::Billet
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/cbraspag/payment/billet.rb
Defined Under Namespace
Classes: DueDateValidator
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#agency ⇒ Object
Returns the value of attribute agency.
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#amount_paid ⇒ Object
Returns the value of attribute amount_paid.
-
#bank ⇒ Object
Returns the value of attribute bank.
-
#code ⇒ Object
Returns the value of attribute code.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#due_date_on ⇒ Object
Returns the value of attribute due_date_on.
-
#id ⇒ Object
Returns the value of attribute id.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#paid_at ⇒ Object
Returns the value of attribute paid_at.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
-
#url ⇒ Object
Returns the value of attribute url.
-
#wallet ⇒ Object
Returns the value of attribute wallet.
Class Method Summary collapse
- .from_generate_billet(connection, order, billet, params) ⇒ Object
- .to_generate_billet(connection, order, billet) ⇒ Object
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def account @account end |
#agency ⇒ Object
Returns the value of attribute agency.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def agency @agency end |
#amount ⇒ Object
Returns the value of attribute amount.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def amount @amount end |
#amount_paid ⇒ Object
Returns the value of attribute amount_paid.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def amount_paid @amount_paid end |
#bank ⇒ Object
Returns the value of attribute bank.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def bank @bank end |
#code ⇒ Object
Returns the value of attribute code.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def code @code end |
#created_at ⇒ Object
Returns the value of attribute created_at.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def created_at @created_at end |
#due_date_on ⇒ Object
Returns the value of attribute due_date_on.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def due_date_on @due_date_on end |
#id ⇒ Object
Returns the value of attribute id.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def id @id end |
#instructions ⇒ Object
Returns the value of attribute instructions.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def instructions @instructions end |
#paid_at ⇒ Object
Returns the value of attribute paid_at.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def paid_at @paid_at end |
#receiver ⇒ Object
Returns the value of attribute receiver.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def receiver @receiver end |
#url ⇒ Object
Returns the value of attribute url.
31 32 33 |
# File 'lib/cbraspag/payment/billet.rb', line 31 def url @url end |
#wallet ⇒ Object
Returns the value of attribute wallet.
32 33 34 |
# File 'lib/cbraspag/payment/billet.rb', line 32 def wallet @wallet end |
Class Method Details
.from_generate_billet(connection, order, billet, params) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cbraspag/payment/billet.rb', line 54 def self.from_generate_billet(connection, order, billet, params) response = Braspag::Converter::hash_from_xml(params.body, { :url => nil, :amount => nil, :number => "boletoNumber", :expiration_date => Proc.new { |document| begin Date.parse(document.search("expirationDate").first.to_s) rescue nil end }, :return_code => "returnCode", :status => nil, :message => nil }) order.gateway_return_code = response[:return_code] order.gateway_status = response[:status] order.gateway_amount = BigDecimal.new(response[:amount].to_s) if response[:amount] billet.url = response[:url] response end |
.to_generate_billet(connection, order, billet) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cbraspag/payment/billet.rb', line 39 def self.to_generate_billet(connection, order, billet) { "merchantId" => connection.merchant_id, "boletoNumber" => billet.id.to_s, "instructions" => billet.instructions.to_s, "expirationDate" => billet.due_date_on.strftime("%d/%m/%y"), "customerName" => order.customer.name.to_s, "customerIdNumber" => order.customer.document.to_s, "emails" => order.customer.email.to_s, "orderId" => order.id.to_s, "amount" => Braspag::Converter::decimal_to_string(order.amount), "paymentMethod" => order.payment_method } end |