If checkout doesnt work well can use the payment intents API
Simple Difference Comparison: https://stripe.com/docs/payments/payment-intents/migration/charges Code Example: https://gist.github.com/westonganger/6ac28553b13a0bc7fe07dcf8d86ce3bd
| DATE_FORMAT = "%F".freeze ### Rails default is "%m/%d/%Y" | |
| TIME_FORMAT = "#{DATE_FORMAT} %l:%M%p %Z".freeze | |
| format_defaults = { | |
| date_time12: TIME_FORMAT, | |
| date_time24: "#{DATE_FORMAT} %H:%M %Z".freeze, | |
| }.freeze | |
| Date::DATE_FORMATS.merge!(format_defaults.merge({default: DATE_FORMAT})) | |
| Time::DATE_FORMATS.merge!(format_defaults.merge({default: TIME_FORMAT})) |
| def sample_pdf_upload | |
| sample_path = Rails.root.join("spec/fixtures/sample_file.pdf") | |
| #fixture_file_upload(sample_path, 'application/pdf') ### MINITEST | |
| Rack::Test::UploadedFile.new(sample_path) ### RSPEC | |
| end | |
| def sample_csv_upload | |
| sample_path = Rails.root.join("spec/fixtures/sample_file.csv") | |
| #fixture_file_upload(sample_path, 'text/csv') ### MINITEST | |
| Rack::Test::UploadedFile.new(sample_path) ### RSPEC |
| require 'capybara/rails' | |
| require 'capybara/rspec' | |
| require 'rack/handler/puma' | |
| require 'selenium/webdriver' | |
| # Default cache time of 24 hours before webdrivers checks for new versions | |
| Webdrivers.cache_time = 24.hours.to_i | |
| # Logging levels are :info (more verbosity), :warn (default), :error, etc |
| window.generate_params_query_string = function(json){ | |
| if(typeof json == 'string'){ | |
| json = JSON.parse(json); | |
| } | |
| var params_str_array = []; | |
| var parse_plain_value = function(current_obj, current_prefix){ | |
| var strParam = current_prefix + "=" + encodeURIComponent(current_obj); | |
| params_str_array.push(strParam); |
| module I18n | |
| class CustomExceptionHandler < ExceptionHandler | |
| def call(exception, locale, key, options) | |
| if exception.is_a?(MissingTranslation) && key.to_s != 'i18n.plural.rule' | |
| raise exception.to_exception | |
| else | |
| super | |
| end | |
| end | |
| end |
| ### Adapted from below, custom changes marked with "CUSTOM" | |
| ### https://github.com/electric-feel/i18n-backend-side_by_side/blob/master/lib/i18n/backend/side_by_side.rb | |
| require 'i18n' | |
| require 'i18n/core_ext/hash' | |
| module I18n | |
| module Backend | |
| using HashRefinements |
| Hash.class_eval do | |
| def deep_set(keys_array, val) | |
| keys_array[0...-1].inject(self){|result, key| | |
| if !result[key].is_a?(Hash) | |
| result[key] = {} | |
| end | |
| result[key] | |
| }.send(:[]=, keys_array.last, val) |
| // AUTOMATIC IFRAME HEIGHT | |
| document.querySelector('iframe#my-iframe').addEventListener('load', function(){ | |
| this.style.height = this.contentWindow.document.body.offsetHeight + "px"; | |
| this.style.width = '100%'; | |
| this.style.maxWidth = '1200px'; | |
| }); |
If checkout doesnt work well can use the payment intents API
Simple Difference Comparison: https://stripe.com/docs/payments/payment-intents/migration/charges Code Example: https://gist.github.com/westonganger/6ac28553b13a0bc7fe07dcf8d86ce3bd
| /* Note: The html string returned fron this method will not contain any actual remotely referenced JS/CSS just the HTML as in the source */ | |
| window.get_html_snapshot = function(hideItems, hideClasses){ | |
| hideItems = hideItems || false; | |
| hideClasses = hideClasses || ".modal, .modal-backdrop"; | |
| var input_types_to_skip = ["button", "submit", "file", "image", "password"]; | |
| // First write all input[type=text] field value so they can be seen when HTML is loaded | |
| $('input').each(function(){ |