Class: AtPay::Button::Template

Inherits:
Object
  • Object
show all
Defined in:
lib/atpay/button/template.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Template

Requires destination and email in addition to this, which should just be strings…



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/atpay/button/template.rb', line 8

def initialize(options)
  @options = {
    :subject => "Submit @Pay Payment",
    :title => "Pay",
    :background_color => "#6dbe45",
    :foreground_color => "#ffffff",
    :image => "https://www.atpay.com/wp-content/themes/atpay/images/bttn_cart.png",
    :processor => "[email protected]",
    :templates => File.join(File.dirname(__FILE__), "/templates"),
    :wrap => false,
    :wrap_text => "Made for Mobile"
  }.update(options)
end

Instance Method Details

#render(args = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/atpay/button/template.rb', line 22

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