From 2e0e22e93e3c460527dcf36a38907d9a1641139d Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Mon, 6 Feb 2023 10:31:20 -0500 Subject: [PATCH 1/9] updates PR note with more realistic timeframe --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 2a0b2b05..3ad8cd9e 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -9,7 +9,7 @@ That's it! - Please give me ~1 week to get back to you. + Please give me ~4 week to get back to you. If you'd like to receive occasional updates, sign up for our newsletter at http://tinyletter.com/stripe-rails ---> \ No newline at end of file +--> From a0123914f6fff0b11e3dffceed17af57454585ca Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Mon, 6 Feb 2023 10:31:45 -0500 Subject: [PATCH 2/9] updates issue note with more realistic timeframe --- .github/issue_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 45c8dc73..824cca1c 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,4 +1,4 @@ \ No newline at end of file +--> From 1f11f0231ccab093c9457d3866e3ac116e6f96a5 Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:07:02 -0400 Subject: [PATCH 3/9] removes mentions of tinyletter (RIP tinyletter) --- .github/issue_template.md | 3 +-- .github/pull_request_template.md | 2 -- README.md | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/issue_template.md b/.github/issue_template.md index 824cca1c..726de73c 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,4 +1,3 @@ diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 3ad8cd9e..ed8488b1 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -10,6 +10,4 @@ That's it! Please give me ~4 week to get back to you. - - If you'd like to receive occasional updates, sign up for our newsletter at http://tinyletter.com/stripe-rails --> diff --git a/README.md b/README.md index bc5b449e..1ebeb8af 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ This gem can help your rails application integrate with Stripe in the following * manage product, prices, plans and coupons from within your app. * painlessly receive and validate webhooks from stripe. -[📫 Sign up for the Newsletter](http://tinyletter.com/stripe-rails) to receive occasional updates. - [Professionally supported stripe-rails is coming soon](https://tidelift.com/subscription/pkg/rubygems-stripe-rails?utm_source=rubygems-stripe-rails&utm_medium=referral&utm_campaign=readme) --- From 376ba520b8c6b7a1bef7e08512ddfd728f9f24d2 Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:12:24 -0400 Subject: [PATCH 4/9] removes testing for ruby 2.5.9 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index a9330fd6..38b6259e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - ruby: [2.5.9, 2.6.10, 2.7.7] + ruby: [2.6.10, 2.7.7] gemfile: [Gemfile, gemfiles/rails60.gemfile, gemfiles/rails52.gemfile, gemfiles/rails51.gemfile] steps: - uses: actions/checkout@v1 From 1e612a19b1acfc45d5ae9fdff3ff4fdd961a748a Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:15:45 -0400 Subject: [PATCH 5/9] webmock to allow googlechromelabs.github.io --- test/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec_helper.rb b/test/spec_helper.rb index 78abc266..a4eadc20 100644 --- a/test/spec_helper.rb +++ b/test/spec_helper.rb @@ -6,7 +6,7 @@ require 'minitest/autorun' require 'webmock/minitest' -WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com'] +WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com', 'googlechromelabs.github.io'] # Chrome Setup require 'selenium-webdriver' From 7b0f0d9871bcad75597cdb641e8253794545060b Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:17:57 -0400 Subject: [PATCH 6/9] webmock to allow storage.googleapis.com --- test/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec_helper.rb b/test/spec_helper.rb index a4eadc20..661e1ad4 100644 --- a/test/spec_helper.rb +++ b/test/spec_helper.rb @@ -6,7 +6,7 @@ require 'minitest/autorun' require 'webmock/minitest' -WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com', 'googlechromelabs.github.io'] +WebMock.disable_net_connect! allow_localhost: true, allow: ['codeclimate.com', 'chromedriver.storage.googleapis.com', 'googlechromelabs.github.io', 'storage.googleapis.com'] # Chrome Setup require 'selenium-webdriver' From 24cfb68b106c273962295b24ed7824533376fb81 Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:21:07 -0400 Subject: [PATCH 7/9] bump puma --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4c60bec3..31faa28c 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ group :test do gem 'webmock' # System tests gem 'capybara' - gem 'puma', '< 6' # https://github.com/teamcapybara/capybara/issues/2598 + gem 'puma' gem 'selenium-webdriver' gem 'webdrivers' end From c3eadcf32ec02ac7908f8a021c6bc3d0b8f1d547 Mon Sep 17 00:00:00 2001 From: SengMing Tan Date: Thu, 21 Mar 2024 15:23:14 -0400 Subject: [PATCH 8/9] removes testing for ruby 2.6.10 --- .github/workflows/ruby.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 38b6259e..57a4d314 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: - ruby: [2.6.10, 2.7.7] + ruby: [2.7.7] gemfile: [Gemfile, gemfiles/rails60.gemfile, gemfiles/rails52.gemfile, gemfiles/rails51.gemfile] steps: - uses: actions/checkout@v1 From 219504d437062912dd1e1d2f687dc7247a748591 Mon Sep 17 00:00:00 2001 From: Chip Castle Date: Sun, 3 Mar 2024 07:21:13 -0600 Subject: [PATCH 9/9] Allow stripe_elements_tag to accept a block --- Changelog.md | 4 ++++ README.md | 17 +++++++++++++++++ app/helpers/stripe/javascript_helper.rb | 6 ++++-- app/views/stripe/_elements.html.erb | 5 +++++ lib/stripe/rails/version.rb | 2 +- test/javascript_helper_spec.rb | 10 ++++++++++ 6 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 27c3744a..7fa90ed4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +## 2.5.0 (2023-03-21) + +- Allow `stripe_elements_tag` to accept a block. Thanks @chip ! + ## 2.4.0 (2023-02-04) - Add `tax_behavior` attribute to Price. Thanks @szechyjs ! diff --git a/README.md b/README.md index 1ebeb8af..db3c4f3a 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ This gem can help your rails application integrate with Stripe in the following - [Configuring your plans and coupons](#configuring-your-plans-and-coupons) [Stripe Elements](#stripe-elements) +- [Custom Elements](#custom-elements) [Webhooks](#webhooks) @@ -320,6 +321,22 @@ Simply include the `stripe_elements_tag` anywhere below the `stripe_javascript_t <%= stripe_elements_tag submit_path: billing_path %> ``` +Additionally, you can pass a block containing custom form elements to stripe_elements_tag: + +## Custom Elements + +> Stripe::Rails allows you to easily include your own custom form elements +> within the Stripe form by including those form elements in a block passed to +> `stripe_elements_tag`: + +```erb +<%= stripe_javascript_tag %> +<%= stripe_elements_tag(submit_path: billing_path) do %> + <%= label_tag 'email', 'Email' %> + <%= text_field :user, :email %> +<% end %> +``` + ### Configuration options Stripe::Rails comes bundled with default CSS and Javascript for Stripe elements, making it easy to drop in to your app. You can also specify your own assets paths: diff --git a/app/helpers/stripe/javascript_helper.rb b/app/helpers/stripe/javascript_helper.rb index 32150afa..9b63efd1 100644 --- a/app/helpers/stripe/javascript_helper.rb +++ b/app/helpers/stripe/javascript_helper.rb @@ -10,14 +10,16 @@ def stripe_javascript_tag(stripe_js_version = DEFAULT_STRIPE_JS_VERSION) def stripe_elements_tag(submit_path:, css_path: asset_path("stripe_elements.css"), - js_path: asset_path("stripe_elements.js")) + js_path: asset_path("stripe_elements.js"), + &block) render partial: 'stripe/elements', locals: { submit_path: submit_path, label_text: t('stripe_rails.elements.label_text'), submit_button_text: t('stripe_rails.elements.submit_button_text'), css_path: css_path, - js_path: js_path + js_path: js_path, + block: block } end end diff --git a/app/views/stripe/_elements.html.erb b/app/views/stripe/_elements.html.erb index b9ea5631..73f454cd 100644 --- a/app/views/stripe/_elements.html.erb +++ b/app/views/stripe/_elements.html.erb @@ -5,6 +5,11 @@ <%= form_tag submit_path, id: "stripe-form" do %> + <% if local_assigns[:block] %> +
+ <%= capture(&local_assigns[:block]) %> +
+ <% end %> <%= label_tag :card_element, label_text %>
<%= submit_tag submit_button_text %> diff --git a/lib/stripe/rails/version.rb b/lib/stripe/rails/version.rb index c2f21077..c8750a65 100644 --- a/lib/stripe/rails/version.rb +++ b/lib/stripe/rails/version.rb @@ -1,5 +1,5 @@ module Stripe module Rails - VERSION = '2.4.0'.freeze + VERSION = '2.5.0'.freeze end end diff --git a/test/javascript_helper_spec.rb b/test/javascript_helper_spec.rb index 8a321973..d0e3b104 100644 --- a/test/javascript_helper_spec.rb +++ b/test/javascript_helper_spec.rb @@ -77,5 +77,15 @@ end end end + + describe 'with block' do + let(:markup) { ''.html_safe } + + it 'should display block contents' do + block = lambda { markup } + result = view.stripe_elements_tag(submit_path: '/charge', &block) + assert_match %r%%, result + end + end end end