Class: XapoTools::MicroPayment
- Inherits:
-
Object
- Object
- XapoTools::MicroPayment
- Defined in:
- lib/xapo_tools.rb
Overview
Xapo’s payment buttons snippet builder.
This class allows the construction of 2 kind of widgets, div and iframe. The result is a HTML snippet that could be embedded in a web page for doing micro payments though a payment button.
Attributes:
service_url (str): The endpoint URL that returns the payment widget.
app_id (str, optional): The id of the TPA for which the widget will be created.
app_secret (str, optional): The TPA secret used to encrypt widget configuration.
Instance Method Summary collapse
-
#build_div_widget(config) ⇒ Object
Build div HTML snippet in order to be embedded in apps.
-
#build_iframe_widget(config) ⇒ Object
Build an iframe HTML snippet in order to be embedded in apps.
-
#initialize(service_url, app_id = nil, app_secret = nil) ⇒ MicroPayment
constructor
A new instance of MicroPayment.
Constructor Details
#initialize(service_url, app_id = nil, app_secret = nil) ⇒ MicroPayment
Returns a new instance of MicroPayment.
56 57 58 59 60 |
# File 'lib/xapo_tools.rb', line 56 def initialize(service_url, app_id=nil, app_secret=nil) @service_url = service_url @app_id = app_id @app_secret = app_secret end |
Instance Method Details
#build_div_widget(config) ⇒ Object
Build div HTML snippet in order to be embedded in apps.
Args:
config (MicroPaymentConfig): The button configuration options.
See @MicroPaymentConfig.
Returns:
string: the div HTML snippet ot be embedded in a page.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/xapo_tools.rb', line 115 def (config) = build_url(config) snippet = YAML::load(<<-END) | <div id="tipButtonDiv" class="tipButtonDiv"></div> <div id="tipButtonPopup" class="tipButtonPopup"></div> <script> $(document).ready(function() {{ $("#tipButtonDiv").load("#{}"); }}); </script> END return snippet end |
#build_iframe_widget(config) ⇒ Object
Build an iframe HTML snippet in order to be embedded in apps.
Args:
config (MicroPaymentConfig): The button configuration options.
See @MicroPaymentConfig.
Returns:
string: the iframe HTML snippet ot be embedded in a page.
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/xapo_tools.rb', line 93 def (config) = build_url(config) snippet = YAML::load(<<-END) | <iframe id="tipButtonFrame" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:22px;" allowTransparency="true" src="#{}"> </iframe> END return snippet end |