Skip to content

Instantly share code, notes, and snippets.

@mindlapse
mindlapse / guide.md
Last active September 7, 2021 15:05
A guide on how to use PaymentIntents with tipsi-stripe

Introduction

Card payments with Stripe should be performed with PaymentIntents.

This API was created to handle modern payments, where the cardholder's bank may require the user to authenticate themselves with the bank before a payment can be authorized.

Authentication requirements first started to appear with European banks regulated by PSD2 which introduced [Strong Customer Authentication

# frozen_string_literal: true
# @see https://gist.github.com/commitshappen/5928740df2e01f256778c2dbd14364a5 for the RateLimiter
module RateLimitable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def rate_limiter(bucket_name, global: {}, local: {})
# frozen_string_literal: true
class RateLimiter
class Error < StandardError; end
class UnknownIntervalError < RateLimiter::Error; end
class WaitTimeError < RateLimiter::Error; end
attr_reader :bucket_name, :interval, :maximum_wait_time, :rate, :redis
def initialize(bucket_name, options = {})