stripe-opal 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc9d8319a52f6039ea7ce3e2678ac1ed5518662a
4
- data.tar.gz: 5433fbf8ff21c0a433a4b4ad9f9661e4978cdc12
3
+ metadata.gz: 4fa489de910ffeab3aa1017c12b2dfd304e37527
4
+ data.tar.gz: ff4047b26e2faf0526b025740d458dc3b51009bf
5
5
  SHA512:
6
- metadata.gz: 582044474dbdf2103f3124b2ed35c18557bd080b14b9ebf386129b95a33b76aabb6b4eca85eeec78c421c297e2a09d253f8e676db01b526e64eba95b39a13905
7
- data.tar.gz: 6a0abe54fb30313a3b1b299527e7989e6c6a1a48fd57d38126cd2f32fa5a5b4140d02d6b30524420288e90227336e43d821ee43a55660ca4c53731a3aca96939
6
+ metadata.gz: 6edc287e605c2e8a74d492a26079f099dc4de8697f39dc3a340405f443ca235473431618dcab875f2ac7c6ad49dd6920839f3e2c0563fa6333f17b6a53de1c13
7
+ data.tar.gz: 5827afe5c3be486a302ade449bdf7aa96c953f137d81d496185a55de98bc76b8d5a633f8e5eb68fae758bdab14b572c608945880f11b0be2e415b51700f3b13d
@@ -0,0 +1,8 @@
1
+ .DS_Store
2
+ *.gem
3
+ Gemfile.lock
4
+ build
5
+ gh-pages
6
+ /.bundle
7
+ .yardoc
8
+ /doc
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (C) 2015 by Rick Carlino
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,120 @@
1
+ # Unofficial Stripe.JS wrapper for Opal
2
+
3
+ `stripe-opal` provides credit card payment capabilities to opal by wrapping Stripe.js and providing a nice ruby syntax for dealing with card payments.
4
+
5
+ ## Note
6
+
7
+ This is an unofficial Gem and I don't work for Stripe. The gem is maintained, but not officially supported or endorsed by Stripe.
8
+
9
+ ## Getting Started
10
+
11
+ ### Usage
12
+
13
+ Add this to `app/main/config/dependencies.rb` for your **Volt Project**:
14
+
15
+ ```ruby
16
+ javascript_file "https://js.stripe.com/v2/"
17
+ ```
18
+
19
+ OR, if you are writing a **static app that does not use Volt, but uses Opal**:
20
+
21
+ ```html
22
+ <script type="text/javascript" src="https://js.stripe.com/v2/"></script>
23
+ ```
24
+ THEN
25
+
26
+ Make this HTML form...
27
+
28
+ ```html
29
+ <form action="" method="POST" id="payment-form">
30
+ <span class="payment-errors"></span>
31
+
32
+ <div class="form-row">
33
+ <label>
34
+ <span>Card Number</span>
35
+ <input type="text" size="20" data-stripe="number"/>
36
+ </label>
37
+ </div>
38
+
39
+ <div class="form-row">
40
+ <label>
41
+ <span>CVC</span>
42
+ <input type="text" size="4" data-stripe="cvc"/>
43
+ </label>
44
+ </div>
45
+
46
+ <div class="form-row">
47
+ <label>
48
+ <span>Expiration (MM/YYYY)</span>
49
+ <input type="text" size="2" data-stripe="exp-month"/>
50
+ </label>
51
+ <span> / </span>
52
+ <input type="text" size="4" data-stripe="exp-year"/>
53
+ </div>
54
+
55
+ <button type="submit">Submit Payment</button>
56
+ </form>
57
+ ```
58
+
59
+ And run payments like this:
60
+
61
+ ```ruby
62
+
63
+ StripeOpal::Card
64
+ .get_token('#payment-form') # Notice the ID on the form above?
65
+ .then { |token| "Pass the `token.id` to a Volt::Task or AJAX call" }
66
+ .fail { |error| "Tell the user they put bad info in." }
67
+
68
+ ```
69
+
70
+ If you are developing a [Volt Framework](http://www.voltframework.com) app, it's best to put the code above in a controller method
71
+
72
+ ```
73
+ def pay_from_controller
74
+ StripeOpal::Card
75
+ .get_token('#payment-form') # Notice the ID on the form above?
76
+ .then { |token| "Pass the `token.id` to a Volt::Task or AJAX call" }
77
+ .fail { |error| "Tell the user they put bad info in." }
78
+ end
79
+ ```
80
+
81
+ and add `e-submit="pay_from_controller"` to the `<form>` tag.
82
+
83
+ ## Installation
84
+
85
+ Install stripe-opal from RubyGems:
86
+
87
+ ```
88
+ $ gem install stripe-opal
89
+ ```
90
+
91
+ Or include it in your Gemfile for Bundler:
92
+
93
+ ```ruby
94
+ gem 'stripe-opal'
95
+ ```
96
+
97
+ ## License
98
+
99
+ (The MIT License)
100
+
101
+ Copyright (C) 2015 by Rick Carlino
102
+
103
+ Permission is hereby granted, free of charge, to any person obtaining a copy
104
+ of this software and associated documentation files (the "Software"), to deal
105
+ in the Software without restriction, including without limitation the rights
106
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
107
+ copies of the Software, and to permit persons to whom the Software is
108
+ furnished to do so, subject to the following conditions:
109
+
110
+ The above copyright notice and this permission notice shall be included in
111
+ all copies or substantial portions of the Software.
112
+
113
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
116
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
117
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
118
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
119
+ THE SOFTWARE.
120
+
File without changes
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require 'opal-rspec'
5
+ Opal.append_path File.expand_path('../spec', __FILE__)
6
+
7
+ run Opal::Server.new { |s|
8
+ s.main = 'opal/rspec/sprockets_runner'
9
+ s.append_path 'spec'
10
+ s.debug = false
11
+ s.index_path = 'spec/index.html.erb'
12
+ }
13
+
@@ -0,0 +1,8 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ </head>
5
+ <body>
6
+ <%= javascript_include_tag @server.main %>
7
+ </body>
8
+ </html>
@@ -0,0 +1,9 @@
1
+ require 'opal-rspec'
2
+ require 'stripe-opal'
3
+
4
+ module SomeHelpers
5
+ end
6
+
7
+ RSpec.configure do |config|
8
+ config.include SomeHelpers
9
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe StripOpal::Card do
4
+ let(:four) { 4 }
5
+
6
+ describe ".placeholder" do
7
+ it 'equals four' { expect(2 + 2).to eq(four) }
8
+ end
9
+ end
@@ -0,0 +1,20 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'stripe-opal'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.authors = ['Rick Carlino']
7
+ s.description = 'Wrapper around stripe.js to make Opal payments easier'
8
+ s.email = 'rick@datamelon.io'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.homepage = 'https://github.com/DataMelon/stripe-opal'
11
+ s.license = 'MIT'
12
+ s.name = 'stripe-opal'
13
+ s.require_paths = ['lib']
14
+ s.summary = 'Opal access to Stripe.js'
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.version = StripeOpal::VERSION
17
+ s.add_development_dependency 'opal-rspec', '~> 0.4.0'
18
+ s.add_development_dependency 'rake'
19
+ s.add_runtime_dependency 'opal', '>= 0.8.0'
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-opal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Carlino
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: opal
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 0.8.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 0.8.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: opal-rspec
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -52,15 +38,39 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: opal
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.0
55
55
  description: Wrapper around stripe.js to make Opal payments easier
56
56
  email: rick@datamelon.io
57
57
  executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - lib/stripe-opal.rb
61
+ - ".gitignore"
62
+ - Gemfile
63
+ - LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - config.ru
67
+ - spec/index.html.erb
68
+ - spec/spec_helper.rb
69
+ - spec/stripe_opal_card_spec.rb
70
+ - stripe-opal.gemspec
62
71
  homepage: https://github.com/DataMelon/stripe-opal
63
- licenses: []
72
+ licenses:
73
+ - MIT
64
74
  metadata: {}
65
75
  post_install_message:
66
76
  rdoc_options: []
@@ -1,38 +0,0 @@
1
- if RUBY_PLATFORM == 'opal'
2
- require 'native'
3
-
4
- module StripeOpal
5
-
6
- class Card
7
- def self.get_token(query_selector)
8
- new(query_selector).run.promise
9
- end
10
-
11
- attr_reader :query_selector, :promise, :callback
12
-
13
- def initialize(query_selector)
14
- @query_selector = query_selector
15
- @promise = Promise.new
16
- @callback = lambda { |a, b| resolve_or_reject(a, b) }
17
- end
18
-
19
- def run
20
- `Stripe.card.createToken(document.querySelector(#{query_selector}), #{self.callback});`
21
- self
22
- end
23
-
24
- def resolve_or_reject(status, response)
25
- status, response = Native(status), Native(response)
26
- if response[:error]
27
- promise.reject response, status
28
- else
29
- promise.resolve(response, status)
30
- end
31
- end
32
- end
33
- end
34
- else
35
- module StripeOpal
36
- VERSION = '0.0.3'
37
- end
38
- end