Class: Braspag::CreditCard
- Inherits:
-
Object
- Object
- Braspag::CreditCard
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/cbraspag/payment/credit_card.rb
Defined Under Namespace
Classes: ExpiratorValidator
Instance Attribute Summary collapse
-
#alias ⇒ Object
Returns the value of attribute alias.
-
#authenticated_number ⇒ Object
Returns the value of attribute authenticated_number.
-
#autorization_number ⇒ Object
Returns the value of attribute autorization_number.
-
#avs ⇒ Object
Returns the value of attribute avs.
-
#avs_response ⇒ Object
Returns the value of attribute avs_response.
-
#checking_number ⇒ Object
Returns the value of attribute checking_number.
-
#holder_name ⇒ Object
Returns the value of attribute holder_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#issuing ⇒ Object
Returns the value of attribute issuing.
-
#month ⇒ Object
Returns the value of attribute month.
-
#number ⇒ Object
Returns the value of attribute number.
-
#transaction_number ⇒ Object
Returns the value of attribute transaction_number.
-
#verification_value ⇒ Object
Returns the value of attribute verification_value.
-
#year ⇒ Object
Returns the value of attribute year.
Class Method Summary collapse
- .from_authorize(connection, order, credit_card, params) ⇒ Object
- .from_capture(connection, order, params) ⇒ Object
- .from_void(connection, order, params) ⇒ Object
- .to_authorize(connection, order, credit_card) ⇒ Object
- .to_capture(connection, order) ⇒ Object
- .to_void(connection, order) ⇒ Object
Instance Attribute Details
#alias ⇒ Object
Returns the value of attribute alias.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def alias @alias end |
#authenticated_number ⇒ Object
Returns the value of attribute authenticated_number.
50 51 52 |
# File 'lib/cbraspag/payment/credit_card.rb', line 50 def authenticated_number @authenticated_number end |
#autorization_number ⇒ Object
Returns the value of attribute autorization_number.
49 50 51 |
# File 'lib/cbraspag/payment/credit_card.rb', line 49 def autorization_number @autorization_number end |
#avs ⇒ Object
Returns the value of attribute avs.
49 50 51 |
# File 'lib/cbraspag/payment/credit_card.rb', line 49 def avs @avs end |
#avs_response ⇒ Object
Returns the value of attribute avs_response.
50 51 52 |
# File 'lib/cbraspag/payment/credit_card.rb', line 50 def avs_response @avs_response end |
#checking_number ⇒ Object
Returns the value of attribute checking_number.
49 50 51 |
# File 'lib/cbraspag/payment/credit_card.rb', line 49 def checking_number @checking_number end |
#holder_name ⇒ Object
Returns the value of attribute holder_name.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def holder_name @holder_name end |
#id ⇒ Object
Returns the value of attribute id.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def id @id end |
#issuing ⇒ Object
Returns the value of attribute issuing.
50 51 52 |
# File 'lib/cbraspag/payment/credit_card.rb', line 50 def issuing @issuing end |
#month ⇒ Object
Returns the value of attribute month.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def month @month end |
#number ⇒ Object
Returns the value of attribute number.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def number @number end |
#transaction_number ⇒ Object
Returns the value of attribute transaction_number.
49 50 51 |
# File 'lib/cbraspag/payment/credit_card.rb', line 49 def transaction_number @transaction_number end |
#verification_value ⇒ Object
Returns the value of attribute verification_value.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def verification_value @verification_value end |
#year ⇒ Object
Returns the value of attribute year.
48 49 50 |
# File 'lib/cbraspag/payment/credit_card.rb', line 48 def year @year end |
Class Method Details
.from_authorize(connection, order, credit_card, params) ⇒ Object
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/cbraspag/payment/credit_card.rb', line 104 def self.(connection, order, credit_card, params) response = Braspag::Converter::hash_from_xml(params.body, { :amount => nil, :number => "authorisationNumber", :message => nil, :return_code => 'returnCode', :status => nil, :transaction_id => "transactionId" }) order. = response[:number] order.gateway_id = response[:transaction_id] order.gateway_return_code = response[:return_code] order.gateway_status = response[:status] order. = response[:message] order.gateway_amount = Braspag::Converter::string_to_decimal(response[:amount]) response end |
.from_capture(connection, order, params) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/cbraspag/payment/credit_card.rb', line 131 def self.from_capture(connection, order, params) response = Braspag::Converter::hash_from_xml(params.body, { :amount => nil, :message => 'message', :return_code => 'returnCode', :status => 'status', :transaction_id => "transactionId" }) #TODO: CHECK IF IS NECESSARY # order.gateway_capture_id = response[:transaction_id] order.gateway_capture_return_code = response[:return_code] order.gateway_capture_status = response[:status] order. = response[:message] order.gateway_capture_amount = Braspag::Converter::string_to_decimal(response[:amount]) response end |
.from_void(connection, order, params) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/cbraspag/payment/credit_card.rb', line 157 def self.from_void(connection, order, params) response = Braspag::Converter::hash_from_xml(params.body, { :order_id => "orderId", :amount => nil, :message => 'message', :return_code => 'returnCode', :status => 'status', :transaction_id => "transactionId" }) #TODO: CHECK IF IS NECESSARY # order.gateway_void_id = response[:transaction_id] order.gateway_void_return_code = response[:return_code] order.gateway_void_status = response[:status] order. = response[:message] order.gateway_void_amount = Braspag::Converter::string_to_decimal(response[:amount]) response end |
.to_authorize(connection, order, credit_card) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cbraspag/payment/credit_card.rb', line 87 def self.(connection, order, credit_card) year_normalize = credit_card.year.to_s[-2, 2] { "merchantId" => connection.merchant_id, "holder" => credit_card.holder_name.to_s, "cardNumber" => credit_card.number.to_s, "expiration" => "#{credit_card.month}/#{year_normalize}", "securityCode" => credit_card.verification_value.to_s, "customerName" => order.customer.name.to_s, "orderId" => order.id.to_s, "amount" => Braspag::Converter::decimal_to_string(order.amount), "paymentMethod" => order.payment_method, "numberPayments" => order.installments, "typePayment" => order.installments_type } end |
.to_capture(connection, order) ⇒ Object
124 125 126 127 128 129 |
# File 'lib/cbraspag/payment/credit_card.rb', line 124 def self.to_capture(connection, order) { "merchantId" => connection.merchant_id, "orderId" => order.id.to_s } end |
.to_void(connection, order) ⇒ Object
150 151 152 153 154 155 |
# File 'lib/cbraspag/payment/credit_card.rb', line 150 def self.to_void(connection, order) { "merchantId" => connection.merchant_id, "order" => order.id.to_s } end |