Sha256: 79529bccaeb873b6eb6293b93d58d3c41058e3b9335ca9ee7fbd196c3ec3320d
Contents?: true
Size: 888 Bytes
Versions: 1
Compression:
Stored size: 888 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.3' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stripe-opal-0.0.3 | lib/stripe-opal.rb |