Class: Braspag::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/braspag/api/payment.rb

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.



47
48
49
50
# File 'lib/braspag/api/payment.rb', line 47

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

Instance Attribute Details

#addressObject

Returns the value of attribute address.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def address
  @address
end

#amountObject

Returns the value of attribute amount.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def amount
  @amount
end

#authenticateObject

Returns the value of attribute authenticate.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def authenticate
  @authenticate
end

#authorization_codeObject

Returns the value of attribute authorization_code.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def authorization_code
  @authorization_code
end

#bar_code_numberObject

Returns the value of attribute bar_code_number.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def bar_code_number
  @bar_code_number
end

#captureObject

Returns the value of attribute capture.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def capture
  @capture
end

#captured_amountObject

Returns the value of attribute captured_amount.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def captured_amount
  @captured_amount
end

#captured_dateObject

Returns the value of attribute captured_date.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def captured_date
  @captured_date
end

#countryObject

Returns the value of attribute country.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def country
  @country
end

#credit_cardObject

Returns the value of attribute credit_card.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def credit_card
  @credit_card
end

#currencyObject

Returns the value of attribute currency.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def currency
  @currency
end

#digitable_lineObject

Returns the value of attribute digitable_line.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def digitable_line
  @digitable_line
end

#expiration_dateObject

Returns the value of attribute expiration_date.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def expiration_date
  @expiration_date
end

#extra_data_collectionObject

Returns the value of attribute extra_data_collection.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def extra_data_collection
  @extra_data_collection
end

#installmentsObject

Returns the value of attribute installments.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def installments
  @installments
end

#interestObject

Returns the value of attribute interest.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def interest
  @interest
end

Returns the value of attribute links.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def links
  @links
end

#numberObject

Returns the value of attribute number.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def number
  @number
end

#payment_idObject

Returns the value of attribute payment_id.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def payment_id
  @payment_id
end

#proof_of_saleObject

Returns the value of attribute proof_of_sale.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def proof_of_sale
  @proof_of_sale
end

#providerObject

Returns the value of attribute provider.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def provider
  @provider
end

#provider_return_codeObject

Returns the value of attribute provider_return_code.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def provider_return_code
  @provider_return_code
end

#provider_return_messageObject

Returns the value of attribute provider_return_message.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def provider_return_message
  @provider_return_message
end

#reason_codeObject

Returns the value of attribute reason_code.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def reason_code
  @reason_code
end

#reason_messageObject

Returns the value of attribute reason_message.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def reason_message
  @reason_message
end

#received_dateObject

Returns the value of attribute received_date.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def received_date
  @received_date
end

#recurrentObject

Returns the value of attribute recurrent.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def recurrent
  @recurrent
end

#recurrent_paymentObject

Returns the value of attribute recurrent_payment.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def recurrent_payment
  @recurrent_payment
end

#return_urlObject

Returns the value of attribute return_url.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def return_url
  @return_url
end

#service_tax_amountObject

Returns the value of attribute service_tax_amount.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def service_tax_amount
  @service_tax_amount
end

#soft_descriptorObject

Returns the value of attribute soft_descriptor.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def soft_descriptor
  @soft_descriptor
end

#statusObject

Returns the value of attribute status.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def status
  @status
end

#typeObject

Returns the value of attribute type.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def type
  @type
end

#urlObject

Returns the value of attribute url.



12
13
14
# File 'lib/braspag/api/payment.rb', line 12

def url
  @url
end

Class Method Details

.from_json(data) ⇒ Object



58
59
60
61
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
# File 'lib/braspag/api/payment.rb', line 58

def self.from_json(data)
    if (data != nil)
        payment = Payment.new(data["Amount"] || nil)

        payment.service_tax_amount = data["ServiceTaxAmount"] || nil
        payment.installments = data["Installments"] || nil
        payment.interest = data["Interest"] || nil
        payment.capture = data["Capture"] || nil
        payment.authenticate = data["Authenticate"] || nil
        payment.recurrent = data["Recurrent"] || nil
        payment.recurrent_payment = Braspag::RecurrentPayment.from_json(data["RecurrentPayment"] || nil)
        payment.credit_card = Braspag::CreditCard.from_json(data["CreditCard"] || nil)
        payment.proof_of_sale = data["ProofOfSale"] || nil
        payment.authorization_code = data["AuthorizationCode"] || nil
        payment.soft_descriptor = data["SoftDescriptor"] || nil
        payment.return_url = data["ReturnUrl"] || nil
        payment.provider = data["Provider"] || nil
        payment.payment_id = data["PaymentId"] || nil
        payment.type = data["Type"] || nil
        payment.received_date = data["ReceivedDate"] || nil
        payment.captured_amount = data["CapturedAmount"] || nil
        payment.captured_date = data["CapturedDate"] || nil
        payment.currency = data["Currency"] || nil
        payment.country = data["Country"] || nil
        payment.reason_code = data["ReasonCode"] || nil
        payment.reason_message = data["ReasonMessage"] || nil
        payment.provider_return_code = data["ProviderReturnCode"] || nil
        payment.provider_return_message = data["ProviderReturnMessage"] || nil
        payment.status = data["Status"] || nil

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

        payment.expiration_date = data["ExpirationDate"] || nil
        payment.url = data["Url"] || nil
        payment.number = data["Number"] || nil
        payment.bar_code_number = data["BarCodeNumber"] || nil
        payment.digitable_line = data["DigitableLine"] || nil
        payment.address = data["Address"] || nil

        return payment
    end
end

Instance Method Details

#to_json(*options) ⇒ Object



52
53
54
55
56
# File 'lib/braspag/api/payment.rb', line 52

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