Sha256: 8519662caf9394707a0b41dc1268e67c9a62a1588224dcc8dffa2f4fccd8ecc5
Contents?: true
Size: 965 Bytes
Versions: 1
Compression:
Stored size: 965 Bytes
Contents
if RUBY_PLATFORM == 'opal' require 'native' module StripeOpal class Card def self.get_token(query_selector) new(query_selector).run.promise end attr_reader :query_selector, :promise, :callback def initialize(query_selector) @query_selector = query_selector @promise = Promise.new @callback = lambda { |a, b| resolve_or_reject(a, b) } end def run `Stripe.card.createToken(document.querySelector(#{query_selector}), #{self.callback});` self end def resolve_or_reject(status, response) status, response = Native(status), Native(response) if response[:error] promise.reject response, status else promise.resolve(response, status) end end end end else module StripeOpal VERSION = '0.0.6' end require 'opal' Opal.append_path File.expand_path('..', __FILE__).untaint end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stripe-opal-0.0.6 | lib/stripe-opal.rb |