Class: TBK::Webpay::Payment
- Inherits:
-
Object
- Object
- TBK::Webpay::Payment
- Defined in:
- lib/tbk/webpay/payment.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#commerce ⇒ Object
Returns the value of attribute commerce.
-
#confirmation_url ⇒ Object
Returns the value of attribute confirmation_url.
-
#failure_url ⇒ Object
Returns the value of attribute failure_url.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#request_ip ⇒ Object
Returns the value of attribute request_ip.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#success_url ⇒ Object
Returns the value of attribute success_url.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Payment
constructor
A new instance of Payment.
- #redirect_url ⇒ Object
- #to_html_form(options = {}, &block) ⇒ Object
- #token ⇒ Object
- #transaction_id ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Payment
Returns a new instance of Payment.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tbk/webpay/payment.rb', line 13 def initialize( = {}) self.commerce = [:commerce] || TBK::Commerce.default_commerce self.request_ip = [:request_ip] self.amount = [:amount] self.order_id = [:order_id] self.session_id = [:session_id] self.confirmation_url = [:confirmation_url] self.success_url = [:success_url] self.failure_url = [:failure_url] end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
6 7 8 |
# File 'lib/tbk/webpay/payment.rb', line 6 def amount @amount end |
#commerce ⇒ Object
Returns the value of attribute commerce.
4 5 6 |
# File 'lib/tbk/webpay/payment.rb', line 4 def commerce @commerce end |
#confirmation_url ⇒ Object
Returns the value of attribute confirmation_url.
9 10 11 |
# File 'lib/tbk/webpay/payment.rb', line 9 def confirmation_url @confirmation_url end |
#failure_url ⇒ Object
Returns the value of attribute failure_url.
11 12 13 |
# File 'lib/tbk/webpay/payment.rb', line 11 def failure_url @failure_url end |
#order_id ⇒ Object
Returns the value of attribute order_id.
7 8 9 |
# File 'lib/tbk/webpay/payment.rb', line 7 def order_id @order_id end |
#request_ip ⇒ Object
Returns the value of attribute request_ip.
5 6 7 |
# File 'lib/tbk/webpay/payment.rb', line 5 def request_ip @request_ip end |
#session_id ⇒ Object
Returns the value of attribute session_id.
8 9 10 |
# File 'lib/tbk/webpay/payment.rb', line 8 def session_id @session_id end |
#success_url ⇒ Object
Returns the value of attribute success_url.
10 11 12 |
# File 'lib/tbk/webpay/payment.rb', line 10 def success_url @success_url end |
Instance Method Details
#redirect_url ⇒ Object
29 30 31 |
# File 'lib/tbk/webpay/payment.rb', line 29 def redirect_url "#{ self.process_url }?TBK_VERSION_KCC=#{ TBK::VERSION::KCC }&TBK_TOKEN=#{ self.token }" end |
#to_html_form(options = {}, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tbk/webpay/payment.rb', line 33 def to_html_form( = {}, &block) form = <<-EOF <form method="POST" class="#{ [:class] || 'tbk_payment_form'}" id="#{ [:id] }" action="#{ self.process_url }"> <input type="hidden" name="TBK_PARAM" value="#{ self.param }"> <input type="hidden" name="TBK_VERSION_KCC" value="#{ TBK::VERSION::KCC }"> <input type="hidden" name="TBK_CODIGO_COMERCIO" value="#{ self.commerce.id }"> <input type="hidden" name="TBK_KEY_ID" value="#{ self.commerce.webpay_key_id }"> #{ yield if block_given? } </form> EOF form = form.html_safe if form.respond_to? :html_safe form end |
#token ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/tbk/webpay/payment.rb', line 52 def token unless @token @token = fetch_token TBK::Webpay.logger.payment(self) end @token end |
#transaction_id ⇒ Object
25 26 27 |
# File 'lib/tbk/webpay/payment.rb', line 25 def transaction_id @transaction_id ||= (rand * 10000000000).to_i end |