Class: Cielo::API30::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/cielo/api30/payment.rb,
lib/cielo/api30/payment/status.rb

Defined Under Namespace

Modules: Status

Constant Summary collapse

PAYMENTTYPE_CREDITCARD =
"CreditCard"
PAYMENTTYPE_DEBITCARD =
"DebitCard"
PAYMENTTYPE_ELECTRONIC_TRANSFER =
"ElectronicTransfer"
PAYMENTTYPE_BOLETO =
"Boleto"
PROVIDER_BRADESCO =
"Bradesco"
PROVIDER_BANCO_DO_BRASIL =
"BancoDoBrasil"
PROVIDER_SIMULADO =
"Simulado"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount, installments: 1) ⇒ Payment

Returns a new instance of Payment.



51
52
53
54
# File 'lib/cielo/api30/payment.rb', line 51

def initialize(amount, installments: 1)
  @amount = amount
  @installments = installments
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def address
  @address
end

#amountObject

Returns the value of attribute amount.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def amount
  @amount
end

#authenticateObject

Returns the value of attribute authenticate.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def authenticate
  @authenticate
end

#authorization_codeObject

Returns the value of attribute authorization_code.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def authorization_code
  @authorization_code
end

#bar_code_numberObject

Returns the value of attribute bar_code_number.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def bar_code_number
  @bar_code_number
end

#captureObject

Returns the value of attribute capture.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def capture
  @capture
end

#captured_amountObject

Returns the value of attribute captured_amount.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def captured_amount
  @captured_amount
end

#captured_dateObject

Returns the value of attribute captured_date.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def captured_date
  @captured_date
end

#countryObject

Returns the value of attribute country.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def country
  @country
end

#credit_cardObject

Returns the value of attribute credit_card.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def credit_card
  @credit_card
end

#currencyObject

Returns the value of attribute currency.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def currency
  @currency
end

#digitable_lineObject

Returns the value of attribute digitable_line.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def digitable_line
  @digitable_line
end

#expiration_dateObject

Returns the value of attribute expiration_date.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def expiration_date
  @expiration_date
end

#extra_data_collectionObject

Returns the value of attribute extra_data_collection.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def extra_data_collection
  @extra_data_collection
end

#installmentsObject

Returns the value of attribute installments.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def installments
  @installments
end

#interestObject

Returns the value of attribute interest.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def interest
  @interest
end

Returns the value of attribute links.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def links
  @links
end

#numberObject

Returns the value of attribute number.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def number
  @number
end

#payment_idObject

Returns the value of attribute payment_id.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def payment_id
  @payment_id
end

#proof_of_saleObject

Returns the value of attribute proof_of_sale.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def proof_of_sale
  @proof_of_sale
end

#providerObject

Returns the value of attribute provider.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def provider
  @provider
end

#received_dateObject

Returns the value of attribute received_date.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def received_date
  @received_date
end

#recurrentObject

Returns the value of attribute recurrent.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def recurrent
  @recurrent
end

#recurrent_paymentObject

Returns the value of attribute recurrent_payment.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def recurrent_payment
  @recurrent_payment
end

#return_codeObject

Returns the value of attribute return_code.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def return_code
  @return_code
end

#return_infoObject

Returns the value of attribute return_info.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def return_info
  @return_info
end

#return_messageObject

Returns the value of attribute return_message.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def return_message
  @return_message
end

#return_urlObject

Returns the value of attribute return_url.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def return_url
  @return_url
end

#service_tax_amountObject

Returns the value of attribute service_tax_amount.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def service_tax_amount
  @service_tax_amount
end

#soft_descriptorObject

Returns the value of attribute soft_descriptor.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def soft_descriptor
  @soft_descriptor
end

#statusObject

Returns the value of attribute status.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def status
  @status
end

#tidObject

Returns the value of attribute tid.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def tid
  @tid
end

#typeObject

Returns the value of attribute type.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def type
  @type
end

#urlObject

Returns the value of attribute url.



16
17
18
# File 'lib/cielo/api30/payment.rb', line 16

def url
  @url
end

Class Method Details

.from_json(data) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cielo/api30/payment.rb', line 62

def self.from_json(data)
  return if data.nil?

  payment = new(data["Amount"])

  payment.service_tax_amount = data["ServiceTaxAmount"]
  payment.installments = data["Installments"]
  payment.interest = data["Interest"]
  payment.capture = data["Capture"]
  payment.authenticate = data["Authenticate"]
  payment.recurrent = data["Recurrent"]
  payment.recurrent_payment = RecurrentPayment.from_json(data["RecurrentPayment"])
  payment.credit_card = CreditCard.from_json(data["CreditCard"])
  payment.proof_of_sale = data["ProofOfSale"]
  payment.authorization_code = data["AuthorizationCode"]
  payment.soft_descriptor = data["SoftDescriptor"]
  payment.return_url = data["ReturnUrl"]
  payment.provider = data["Provider"]
  payment.payment_id = data["PaymentId"]
  payment.tid = data["Tid"]
  payment.type = data["Type"]
  payment.received_date = data["ReceivedDate"]
  payment.captured_amount = data["CapturedAmount"]
  payment.captured_date = data["CapturedDate"]
  payment.currency = data["Currency"]
  payment.country = data["Country"]
  payment.return_code = data["ReturnCode"]
  payment.return_message = data["ReturnMessage"]
  payment.status = data["Status"]

  payment.links = data["Links"]
  payment.extra_data_collection = data["ExtraDataCollection"]

  payment.expiration_date = data["ExpirationDate"]
  payment.url = data["Url"]
  payment.number = data["Number"]
  payment.bar_code_number = data["BarCodeNumber"]
  payment.digitable_line = data["DigitableLine"]
  payment.address = data["Address"]
  payment.return_info = ReturnInfo.new(payment.return_code)

  payment
end

Instance Method Details

#as_json(options = {}) ⇒ Object



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cielo/api30/payment.rb', line 110

def as_json(options={})
  {
    ServiceTaxAmount: @service_tax_amount,
    Installments: @installments,
    Interest: @interest,
    Capture: @capture,
    Authenticate: @authenticate,
    Recurrent: @recurrent,
    RecurrentPayment: @recurrent_payment,
    CreditCard: @credit_card,
    SoftDescriptor: @soft_descriptor,
    ReturnUrl: @return_url,
    Provider: @provider,
    Type: @type,
    Amount: @amount,
    Currency: @currency,
    Country: @country,
    Number: @number,
    BarCodeNumber: @bar_code_number,
    DigitableLine: @digitable_line,
    Address: @address,
    ReturnInfo: @return_info
  }
end

#success?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/cielo/api30/payment.rb', line 106

def success?
  Status.success?(status)
end

#to_json(*options) ⇒ Object



56
57
58
59
60
# File 'lib/cielo/api30/payment.rb', line 56

def to_json(*options)
  hash = as_json(*options)
  hash.reject! {|k,v| v.nil?}
  hash.to_json(*options)
end