Class: TBK::Webpay::Confirmation
- Inherits:
-
Object
- Object
- TBK::Webpay::Confirmation
- Defined in:
- lib/tbk/webpay/confirmation.rb
Constant Summary collapse
- RESPONSE_CODES =
{ '0' => 'Transacción aprobada.', '-1' => 'Rechazo de tx. en B24, No autorizada', '-2' => 'Transacción debe reintentarse.', '-3' => 'Error en tx.', '-4' => 'Rechazo de tx. En B24, No autorizada', '-5' => 'Rechazo por error de tasa.', '-6' => 'Excede cupo máximo mensual.', '-7' => 'Excede límite diario por transacción.', '-8' => 'Rubro no autorizado.' }
Instance Attribute Summary collapse
-
#commerce ⇒ Object
Returns the value of attribute commerce.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#request_ip ⇒ Object
Returns the value of attribute request_ip.
Instance Method Summary collapse
- #acknowledge ⇒ Object
- #amount ⇒ Object
- #authorization ⇒ Object
- #card_display_number ⇒ Object
- #card_last_numbers ⇒ Object
-
#initialize(options) ⇒ Confirmation
constructor
A new instance of Confirmation.
- #message ⇒ Object
- #order_id ⇒ Object
- #paid_at ⇒ Object
- #reject ⇒ Object
- #session_id ⇒ Object
- #signature ⇒ Object
- #success? ⇒ Boolean
- #transaction_id ⇒ Object
Constructor Details
#initialize(options) ⇒ Confirmation
Returns a new instance of Confirmation.
22 23 24 25 26 27 28 |
# File 'lib/tbk/webpay/confirmation.rb', line 22 def initialize() = { :body => } if .is_a?(String) self.commerce = [:commerce] || TBK::Commerce.default_commerce self.request_ip = [:request_ip] self.parse([:body]) end |
Instance Attribute Details
#commerce ⇒ Object
Returns the value of attribute commerce.
17 18 19 |
# File 'lib/tbk/webpay/confirmation.rb', line 17 def commerce @commerce end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
20 21 22 |
# File 'lib/tbk/webpay/confirmation.rb', line 20 def params @params end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
19 20 21 |
# File 'lib/tbk/webpay/confirmation.rb', line 19 def raw @raw end |
#request_ip ⇒ Object
Returns the value of attribute request_ip.
18 19 20 |
# File 'lib/tbk/webpay/confirmation.rb', line 18 def request_ip @request_ip end |
Instance Method Details
#acknowledge ⇒ Object
30 31 32 |
# File 'lib/tbk/webpay/confirmation.rb', line 30 def acknowledge self.commerce.webpay_encrypt('ACK') end |
#amount ⇒ Object
54 55 56 |
# File 'lib/tbk/webpay/confirmation.rb', line 54 def amount self.params[:TBK_MONTO].to_f/100 end |
#authorization ⇒ Object
58 59 60 |
# File 'lib/tbk/webpay/confirmation.rb', line 58 def self.params[:TBK_CODIGO_AUTORIZACION] end |
#card_display_number ⇒ Object
66 67 68 |
# File 'lib/tbk/webpay/confirmation.rb', line 66 def card_display_number "XXXX-XXXX-XXXX-#{ card_last_numbers }" end |
#card_last_numbers ⇒ Object
70 71 72 |
# File 'lib/tbk/webpay/confirmation.rb', line 70 def card_last_numbers self.params[:TBK_FINAL_NUMERO_TARJETA] end |
#message ⇒ Object
74 75 76 |
# File 'lib/tbk/webpay/confirmation.rb', line 74 def RESPONSE_CODES[self.params[:TBK_RESPUESTA]] end |
#order_id ⇒ Object
42 43 44 |
# File 'lib/tbk/webpay/confirmation.rb', line 42 def order_id self.params[:TBK_ORDEN_COMPRA] end |
#paid_at ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/tbk/webpay/confirmation.rb', line 78 def paid_at @paid_at ||= begin year = Time.now.year month = self.params[:TBK_FECHA_TRANSACCION][0...2].to_i day = self.params[:TBK_FECHA_TRANSACCION][2...4].to_i hour = self.params[:TBK_HORA_TRANSACCION][0...2].to_i minutes = self.params[:TBK_HORA_TRANSACCION][2...4].to_i seconds = self.params[:TBK_HORA_TRANSACCION][4...6].to_i offset = if defined? TZInfo::Timezone # Use tzinfo gem if available TZInfo::Timezone.get('America/Santiago').period_for_utc(DateTime.new(year,month,day,hour,minutes,0)).utc_offset else -14400 end Time.new(year, month, day, hour, minutes, seconds, offset) end end |
#reject ⇒ Object
34 35 36 |
# File 'lib/tbk/webpay/confirmation.rb', line 34 def reject self.commerce.webpay_encrypt('ERR') end |
#session_id ⇒ Object
46 47 48 |
# File 'lib/tbk/webpay/confirmation.rb', line 46 def session_id self.params[:TBK_ID_SESION] end |
#signature ⇒ Object
62 63 64 |
# File 'lib/tbk/webpay/confirmation.rb', line 62 def signature self.params[:TBK_MAC] end |
#success? ⇒ Boolean
38 39 40 |
# File 'lib/tbk/webpay/confirmation.rb', line 38 def success? self.params[:TBK_RESPUESTA] == "0" end |
#transaction_id ⇒ Object
50 51 52 |
# File 'lib/tbk/webpay/confirmation.rb', line 50 def transaction_id self.params[:TBK_ID_TRANSACCION] end |