Module: BrainblocksHelper

Defined in:
lib/brainblocks-rails/brainblocks_rails_helper.rb

Instance Method Summary collapse

Instance Method Details

#brainblocks(wallet = "xrb_1xau1obw9u14ung8okbstmh4wmc63iw9y5cq3way3pbkj4krh9j15f4j7dnz", amount = 1000, currency = "rai", on_success = "console.log('Payment successful!', data.token);") ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/brainblocks-rails/brainblocks_rails_helper.rb', line 2

def brainblocks(wallet = "xrb_1xau1obw9u14ung8okbstmh4wmc63iw9y5cq3way3pbkj4krh9j15f4j7dnz", amount = 1000, currency = "rai", on_success = "console.log('Payment successful!', data.token);")
  @brainblocks_id ||= -1

  element = "brainblocks-#{@brainblocks_id += 1}"
  button = tag.div id: element

  script = javascript_tag do
    "    brainblocks.Button.render({\n      payment: {\n        destination: '\#{wallet}',\n        currency:    '\#{currency}',\n        amount:      \#{amount}\n      }, onPayment: function(data) {\n        \#{on_success}\n      }\n    }, '#\#{element}');\n    END\n  end\n\n  button + script\nend\n".squish.html_safe