Class: AtPay::Button
- Inherits:
-
Object
- Object
- AtPay::Button
- Defined in:
- lib/atpay/button.rb
Defined Under Namespace
Classes: QRCode
Constant Summary collapse
- OPTIONS =
{ subject: 'Email Order Form', title: 'Pay', background_color: '#6dbe45', foreground_color: '#ffffff', image: 'https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png', processor: ENV['ATPAY_PAYMENT_ADDRESS'] || 'payments.atpay.com', templates: File.join(File.dirname(__FILE__), '..', '..', 'assets', 'button', 'templates'), analytic_url: nil, wrap: false, wrap_text: 'Made for Mobile' }
Instance Method Summary collapse
- #default_mailto ⇒ Object
-
#initialize(token, short_token, amount, merchant_name, options = {}) ⇒ Button
constructor
A new instance of Button.
- #render(args = {}) ⇒ Object
Constructor Details
#initialize(token, short_token, amount, merchant_name, options = {}) ⇒ Button
Returns a new instance of Button.
21 22 23 24 25 26 27 28 |
# File 'lib/atpay/button.rb', line 21 def initialize(token, short_token, amount, merchant_name, ={}) @token = token @short_token = short_token @amount = amount @merchant_name = merchant_name @options = OPTIONS.merge() @options[:image] = nil if @options[:image] == '' end |
Instance Method Details
#default_mailto ⇒ Object
30 31 32 |
# File 'lib/atpay/button.rb', line 30 def default_mailto "mailto:#{mailto_processor}?subject=#{mailto_subject}&body=#{mailto_body}" end |
#render(args = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/atpay/button.rb', line 34 def render(args={}) @options.update args template.render({ 'url' => default_mailto, 'outlook_url' => outlook_mailto, 'yahoo_url' => yahoo_mailto, 'content' => amount, 'dollar' => amount.match(/\$\d+(?=\.)/).to_s, 'cents' => ".#{amount.match(/(?<=\.)[^.]*/).to_s}", }.update(string_hash @options)) end |