jekyll-stripe 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: db627821ef25a1c022310df2d4bf7fc521d76e882d5fb69e036283294ecf9eca
4
+ data.tar.gz: 53f3dda3adc375766c71480ace4e6e7107058891bf1204fbc3d83fdde1549cf1
5
+ SHA512:
6
+ metadata.gz: eea093f118d6926d15d81d1e8a2803eacbb2f1336df1a226b58d82bd7300e2a2f0a8da9a99884ffcfe864d23ad95497cb3c528ab27e882a62e0c4370ff435cfa
7
+ data.tar.gz: 96e55dd3253dd1a0c577700038f72565f246b985f0aef650c554b75685914d5ddf378534f90637cc8fb78155daa7acbda0dbc05507dc05043cbc341418d7785e
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /*.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jekyll-stripe.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Shai Schechter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # jekyll-stripe
2
+
3
+ A Jekyll plugin for easily letting site visitors buy products you've set up in your Stripe dashboard.
4
+
5
+ ## Installation
6
+
7
+ Add the following to your site's `Gemfile`:
8
+
9
+ ```
10
+ gem 'jekyll-stripe'
11
+ ```
12
+
13
+ Add the following to your site's `_config.yml`:
14
+
15
+ ```
16
+ plugins:
17
+ - jekyll-stripe
18
+ ```
19
+
20
+ If you are using a Jekyll version less than `3.5.0`, use the `gems` key instead of `plugins`.
21
+
22
+ ## Usage
23
+
24
+ Add the following right before `</head>` in your site's layout:
25
+
26
+ ```
27
+ {% stripe pk_live_1234567890 %}
28
+ ```
29
+
30
+ Where `pk_live_1234567890` is your Stripe **Publishable** API Key. **_Never put your secret key here!_**
31
+
32
+ And then wherever you want to show a buy button, add:
33
+
34
+ ```
35
+ {% stripe_button price_1234567890 %}
36
+ ```
37
+
38
+ Where `price_1234567890` is the `API ID` for the `Price` you want this button to be used to purchase. You can create `Prices` within `Products` in your Stripe dashboard.
39
+
40
+ If the customer cancels during checkout they'll be redirected to the page where they clicked the button.
41
+
42
+ If checkout succeeds, the customer will be redirected to the same page with `-thanks` appended, e.g. `https://example.com/my-course-thanks/` if the button was on `https://example.com/my-course/`.
43
+
44
+ Use Stripe webhooks (or Zapier, etc) if you need something to happen behind the scenes after a confirmed purchase.
45
+
46
+ ## Known limitations
47
+
48
+ - Ability to customize:
49
+ - Button text
50
+ - Button styling (though you can do this easily with CSS)
51
+ - Success/cancel URLs
52
+ - Other settings
53
+ - Protection against incorrect setup
54
+ - Protection against accidentally using secret key
55
+
56
+ ## Stripe docs
57
+
58
+ https://stripe.com/docs/payments/checkout/client
59
+
60
+ ## Contributing
61
+
62
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/shai126/jekyll-stripe](https://github.com/shai126/jekyll-stripe).
63
+
64
+ ## License
65
+
66
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jekyll/stripe"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "jekyll-stripe/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "jekyll-stripe"
7
+ spec.version = Jekyll::Stripe::VERSION
8
+ spec.authors = ["Shai Schechter"]
9
+
10
+ spec.summary = %q{A Jekyll plugin for easily letting site visitors buy products you've set up in your Stripe dashboard.}
11
+ spec.homepage = "https://github.com/shai126/jekyll-stripe"
12
+ spec.license = "MIT"
13
+
14
+ # Specify which files should be added to the gem when it is released.
15
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
16
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
17
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "jekyll", ">= 3.3", "< 5.0"
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 12.3.3"
26
+ end
@@ -0,0 +1,29 @@
1
+ module Jekyll
2
+ class StripeTag < Liquid::Tag
3
+ def initialize(tag_name, text, tokens)
4
+ super
5
+ @key = text.strip
6
+ end
7
+
8
+ def render(context)
9
+ File.read(File.expand_path "./jekyll-stripe/template.html", File.dirname(__FILE__)).sub! '%APIKEY%', @key
10
+ end
11
+ end
12
+
13
+ class StripeButtonTag < Liquid::Tag
14
+ def initialize(tag_name, text, tokens)
15
+ super
16
+ @id = text.strip
17
+ end
18
+
19
+ def render(context)
20
+ style = "background-color:#6772E5;color:#FFF;padding:8px 12px;border:0;border-radius:4px;font-size:1em"
21
+
22
+ "<button style=\"#{style}\" type=\"button\" role=\"link\" data-buybutton-id=\"#{@id}\">Buy now</button> " +
23
+ "<span class=\"buybutton-error\"></span>"
24
+ end
25
+ end
26
+ end
27
+
28
+ Liquid::Template.register_tag('stripe', Jekyll::StripeTag)
29
+ Liquid::Template.register_tag('stripe_button', Jekyll::StripeButtonTag)
@@ -0,0 +1,27 @@
1
+ <script src="https://js.stripe.com/v3"></script>
2
+
3
+ <script>
4
+ (function() {
5
+ var stripe = Stripe('%APIKEY%');
6
+
7
+ document.addEventListener('click', function (event) {
8
+ var target = event.target;
9
+ var id = target.getAttribute('data-buybutton-id');
10
+
11
+ if (id) {
12
+ stripe.redirectToCheckout({
13
+ lineItems: [{price: id, quantity: 1}],
14
+ mode: 'payment',
15
+ successUrl: ("" + window.location).replace(/\/?$/, '-thanks/'),
16
+ cancelUrl: ("" + window.location)
17
+ })
18
+ .then(function (result) {
19
+ var errorElement = target.nextSibling;
20
+ if (errorElement && /\bbuybutton-error\b/.test(errorElement.className)) {
21
+ errorElement.textContent = result.error ? result.error.message : '';
22
+ }
23
+ });
24
+ }
25
+ });
26
+ })();
27
+ </script>
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Stripe
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-stripe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Shai Schechter
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '3.3'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 12.3.3
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 12.3.3
61
+ description:
62
+ email:
63
+ executables: []
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - Gemfile
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - bin/console
73
+ - bin/setup
74
+ - jekyll-stripe.gemspec
75
+ - lib/jekyll-stripe.rb
76
+ - lib/jekyll-stripe/template.html
77
+ - lib/jekyll-stripe/version.rb
78
+ homepage: https://github.com/shai126/jekyll-stripe
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubygems_version: 3.0.6
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: A Jekyll plugin for easily letting site visitors buy products you've set
101
+ up in your Stripe dashboard.
102
+ test_files: []