stripe 11.1.0 → 11.3.0.pre.beta.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 +4 -4
- data/CHANGELOG.md +1317 -652
- data/OPENAPI_VERSION +1 -1
- data/README.md +11 -0
- data/VERSION +1 -1
- data/lib/stripe/api_operations/request.rb +2 -1
- data/lib/stripe/api_version.rb +1 -0
- data/lib/stripe/object_types.rb +16 -0
- data/lib/stripe/request_signing_authenticator.rb +79 -0
- data/lib/stripe/resources/account_notice.rb +32 -0
- data/lib/stripe/resources/capital/financing_offer.rb +49 -0
- data/lib/stripe/resources/capital/financing_summary.rb +15 -0
- data/lib/stripe/resources/capital/financing_transaction.rb +27 -0
- data/lib/stripe/resources/financial_connections/account.rb +3 -0
- data/lib/stripe/resources/financial_connections/account_inferred_balance.rb +14 -0
- data/lib/stripe/resources/gift_cards/card.rb +59 -0
- data/lib/stripe/resources/gift_cards/transaction.rb +93 -0
- data/lib/stripe/resources/invoice.rb +113 -0
- data/lib/stripe/resources/invoice_payment.rb +12 -0
- data/lib/stripe/resources/issuing/credit_underwriting_record.rb +88 -0
- data/lib/stripe/resources/margin.rb +37 -0
- data/lib/stripe/resources/order.rb +120 -0
- data/lib/stripe/resources/payment_intent.rb +50 -0
- data/lib/stripe/resources/quote.rb +104 -0
- data/lib/stripe/resources/quote_phase.rb +39 -0
- data/lib/stripe/resources/quote_preview_invoice.rb +43 -0
- data/lib/stripe/resources/quote_preview_subscription_schedule.rb +11 -0
- data/lib/stripe/resources/subscription_schedule.rb +20 -0
- data/lib/stripe/resources/tax/form.rb +49 -0
- data/lib/stripe/resources/terminal/reader.rb +60 -0
- data/lib/stripe/resources.rb +15 -0
- data/lib/stripe/stripe_client.rb +62 -28
- data/lib/stripe/stripe_configuration.rb +2 -1
- data/lib/stripe/util.rb +8 -1
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe.rb +54 -0
- metadata +20 -4
    
        data/lib/stripe/resources.rb
    CHANGED
    
    | @@ -3,6 +3,7 @@ | |
| 3 3 |  | 
| 4 4 | 
             
            require "stripe/resources/account"
         | 
| 5 5 | 
             
            require "stripe/resources/account_link"
         | 
| 6 | 
            +
            require "stripe/resources/account_notice"
         | 
| 6 7 | 
             
            require "stripe/resources/account_session"
         | 
| 7 8 | 
             
            require "stripe/resources/apple_pay_domain"
         | 
| 8 9 | 
             
            require "stripe/resources/application_fee"
         | 
| @@ -18,6 +19,9 @@ require "stripe/resources/billing/meter_event_summary" | |
| 18 19 | 
             
            require "stripe/resources/billing_portal/configuration"
         | 
| 19 20 | 
             
            require "stripe/resources/billing_portal/session"
         | 
| 20 21 | 
             
            require "stripe/resources/capability"
         | 
| 22 | 
            +
            require "stripe/resources/capital/financing_offer"
         | 
| 23 | 
            +
            require "stripe/resources/capital/financing_summary"
         | 
| 24 | 
            +
            require "stripe/resources/capital/financing_transaction"
         | 
| 21 25 | 
             
            require "stripe/resources/card"
         | 
| 22 26 | 
             
            require "stripe/resources/cash_balance"
         | 
| 23 27 | 
             
            require "stripe/resources/charge"
         | 
| @@ -44,20 +48,25 @@ require "stripe/resources/exchange_rate" | |
| 44 48 | 
             
            require "stripe/resources/file"
         | 
| 45 49 | 
             
            require "stripe/resources/file_link"
         | 
| 46 50 | 
             
            require "stripe/resources/financial_connections/account"
         | 
| 51 | 
            +
            require "stripe/resources/financial_connections/account_inferred_balance"
         | 
| 47 52 | 
             
            require "stripe/resources/financial_connections/account_owner"
         | 
| 48 53 | 
             
            require "stripe/resources/financial_connections/account_ownership"
         | 
| 49 54 | 
             
            require "stripe/resources/financial_connections/session"
         | 
| 50 55 | 
             
            require "stripe/resources/financial_connections/transaction"
         | 
| 51 56 | 
             
            require "stripe/resources/forwarding/request"
         | 
| 52 57 | 
             
            require "stripe/resources/funding_instructions"
         | 
| 58 | 
            +
            require "stripe/resources/gift_cards/card"
         | 
| 59 | 
            +
            require "stripe/resources/gift_cards/transaction"
         | 
| 53 60 | 
             
            require "stripe/resources/identity/verification_report"
         | 
| 54 61 | 
             
            require "stripe/resources/identity/verification_session"
         | 
| 55 62 | 
             
            require "stripe/resources/invoice"
         | 
| 56 63 | 
             
            require "stripe/resources/invoice_item"
         | 
| 57 64 | 
             
            require "stripe/resources/invoice_line_item"
         | 
| 65 | 
            +
            require "stripe/resources/invoice_payment"
         | 
| 58 66 | 
             
            require "stripe/resources/issuing/authorization"
         | 
| 59 67 | 
             
            require "stripe/resources/issuing/card"
         | 
| 60 68 | 
             
            require "stripe/resources/issuing/cardholder"
         | 
| 69 | 
            +
            require "stripe/resources/issuing/credit_underwriting_record"
         | 
| 61 70 | 
             
            require "stripe/resources/issuing/dispute"
         | 
| 62 71 | 
             
            require "stripe/resources/issuing/personalization_design"
         | 
| 63 72 | 
             
            require "stripe/resources/issuing/physical_bundle"
         | 
| @@ -66,6 +75,8 @@ require "stripe/resources/issuing/transaction" | |
| 66 75 | 
             
            require "stripe/resources/line_item"
         | 
| 67 76 | 
             
            require "stripe/resources/login_link"
         | 
| 68 77 | 
             
            require "stripe/resources/mandate"
         | 
| 78 | 
            +
            require "stripe/resources/margin"
         | 
| 79 | 
            +
            require "stripe/resources/order"
         | 
| 69 80 | 
             
            require "stripe/resources/payment_intent"
         | 
| 70 81 | 
             
            require "stripe/resources/payment_link"
         | 
| 71 82 | 
             
            require "stripe/resources/payment_method"
         | 
| @@ -79,6 +90,9 @@ require "stripe/resources/product" | |
| 79 90 | 
             
            require "stripe/resources/product_feature"
         | 
| 80 91 | 
             
            require "stripe/resources/promotion_code"
         | 
| 81 92 | 
             
            require "stripe/resources/quote"
         | 
| 93 | 
            +
            require "stripe/resources/quote_phase"
         | 
| 94 | 
            +
            require "stripe/resources/quote_preview_invoice"
         | 
| 95 | 
            +
            require "stripe/resources/quote_preview_subscription_schedule"
         | 
| 82 96 | 
             
            require "stripe/resources/radar/early_fraud_warning"
         | 
| 83 97 | 
             
            require "stripe/resources/radar/value_list"
         | 
| 84 98 | 
             
            require "stripe/resources/radar/value_list_item"
         | 
| @@ -98,6 +112,7 @@ require "stripe/resources/subscription_item" | |
| 98 112 | 
             
            require "stripe/resources/subscription_schedule"
         | 
| 99 113 | 
             
            require "stripe/resources/tax/calculation"
         | 
| 100 114 | 
             
            require "stripe/resources/tax/calculation_line_item"
         | 
| 115 | 
            +
            require "stripe/resources/tax/form"
         | 
| 101 116 | 
             
            require "stripe/resources/tax/registration"
         | 
| 102 117 | 
             
            require "stripe/resources/tax/settings"
         | 
| 103 118 | 
             
            require "stripe/resources/tax/transaction"
         | 
    
        data/lib/stripe/stripe_client.rb
    CHANGED
    
    | @@ -206,9 +206,10 @@ module Stripe | |
| 206 206 | 
             
                end
         | 
| 207 207 |  | 
| 208 208 | 
             
                def execute_request(method, path,
         | 
| 209 | 
            -
                                    api_base: nil, api_key: nil, | 
| 209 | 
            +
                                    api_base: nil, api_key: nil,
         | 
| 210 | 
            +
                                    headers: {}, params: {}, api_mode: nil, usage: [])
         | 
| 210 211 | 
             
                  http_resp, api_key = execute_request_internal(
         | 
| 211 | 
            -
                    method, path, api_base, api_key, headers, params, usage
         | 
| 212 | 
            +
                    method, path, api_base, api_key, headers, params, api_mode, usage
         | 
| 212 213 | 
             
                  )
         | 
| 213 214 |  | 
| 214 215 | 
             
                  begin
         | 
| @@ -239,6 +240,7 @@ module Stripe | |
| 239 240 | 
             
                def execute_request_stream(method, path,
         | 
| 240 241 | 
             
                                           api_base: nil, api_key: nil, usage: [],
         | 
| 241 242 | 
             
                                           headers: {}, params: {},
         | 
| 243 | 
            +
                                           api_mode: nil,
         | 
| 242 244 | 
             
                                           &read_body_chunk_block)
         | 
| 243 245 | 
             
                  unless block_given?
         | 
| 244 246 | 
             
                    raise ArgumentError,
         | 
| @@ -246,7 +248,8 @@ module Stripe | |
| 246 248 | 
             
                  end
         | 
| 247 249 |  | 
| 248 250 | 
             
                  http_resp, api_key = execute_request_internal(
         | 
| 249 | 
            -
                    method, path, api_base, api_key, | 
| 251 | 
            +
                    method, path, api_base, api_key,
         | 
| 252 | 
            +
                    headers, params, api_mode, usage, &read_body_chunk_block
         | 
| 250 253 | 
             
                  )
         | 
| 251 254 |  | 
| 252 255 | 
             
                  # When the read_body_chunk_block is given, we no longer have access to the
         | 
| @@ -425,8 +428,8 @@ module Stripe | |
| 425 428 | 
             
                end
         | 
| 426 429 |  | 
| 427 430 | 
             
                private def execute_request_internal(method, path,
         | 
| 428 | 
            -
                                                     api_base, api_key, headers, params, | 
| 429 | 
            -
                                                     &read_body_chunk_block)
         | 
| 431 | 
            +
                                                     api_base, api_key, headers, params,
         | 
| 432 | 
            +
                                                     api_mode, usage, &read_body_chunk_block)
         | 
| 430 433 | 
             
                  raise ArgumentError, "method should be a symbol" \
         | 
| 431 434 | 
             
                  unless method.is_a?(Symbol)
         | 
| 432 435 | 
             
                  raise ArgumentError, "path should be a string" \
         | 
| @@ -434,9 +437,10 @@ module Stripe | |
| 434 437 |  | 
| 435 438 | 
             
                  api_base ||= config.api_base
         | 
| 436 439 | 
             
                  api_key ||= config.api_key
         | 
| 440 | 
            +
                  authenticator ||= config.authenticator
         | 
| 437 441 | 
             
                  params = Util.objects_to_ids(params)
         | 
| 438 442 |  | 
| 439 | 
            -
                   | 
| 443 | 
            +
                  check_keys!(api_key, authenticator)
         | 
| 440 444 |  | 
| 441 445 | 
             
                  body_params = nil
         | 
| 442 446 | 
             
                  query_params = nil
         | 
| @@ -449,8 +453,9 @@ module Stripe | |
| 449 453 |  | 
| 450 454 | 
             
                  query_params, path = merge_query_params(query_params, path)
         | 
| 451 455 |  | 
| 452 | 
            -
                  headers = request_headers(api_key, method)
         | 
| 456 | 
            +
                  headers = request_headers(api_key, method, api_mode)
         | 
| 453 457 | 
             
                            .update(Util.normalize_headers(headers))
         | 
| 458 | 
            +
             | 
| 454 459 | 
             
                  url = api_url(path, api_base)
         | 
| 455 460 |  | 
| 456 461 | 
             
                  # Merge given query parameters with any already encoded in the path.
         | 
| @@ -461,13 +466,16 @@ module Stripe | |
| 461 466 | 
             
                  # a log-friendly variant of the encoded form. File objects are displayed
         | 
| 462 467 | 
             
                  # as such instead of as their file contents.
         | 
| 463 468 | 
             
                  body, body_log =
         | 
| 464 | 
            -
                    body_params ? encode_body(body_params, headers) : [nil, nil]
         | 
| 469 | 
            +
                    body_params ? encode_body(body_params, headers, api_mode) : [nil, nil]
         | 
| 470 | 
            +
             | 
| 471 | 
            +
                  authenticator.authenticate(method, headers, body) unless api_key
         | 
| 465 472 |  | 
| 466 473 | 
             
                  # stores information on the request we're about to make so that we don't
         | 
| 467 474 | 
             
                  # have to pass as many parameters around for logging.
         | 
| 468 475 | 
             
                  context = RequestLogContext.new
         | 
| 469 476 | 
             
                  context.account         = headers["Stripe-Account"]
         | 
| 470 477 | 
             
                  context.api_key         = api_key
         | 
| 478 | 
            +
                  context.authenticator   = authenticator
         | 
| 471 479 | 
             
                  context.api_version     = headers["Stripe-Version"]
         | 
| 472 480 | 
             
                  context.body            = body_log
         | 
| 473 481 | 
             
                  context.idempotency_key = headers["Idempotency-Key"]
         | 
| @@ -504,8 +512,16 @@ module Stripe | |
| 504 512 | 
             
                  (api_base || config.api_base) + url
         | 
| 505 513 | 
             
                end
         | 
| 506 514 |  | 
| 507 | 
            -
                private def  | 
| 508 | 
            -
                   | 
| 515 | 
            +
                private def check_keys!(api_key, authenticator)
         | 
| 516 | 
            +
                  if api_key && authenticator
         | 
| 517 | 
            +
                    raise AuthenticationError, "Can't specify both API key " \
         | 
| 518 | 
            +
                                               "and authenticator. Either set your API key" \
         | 
| 519 | 
            +
                                               'using "Stripe.api_key = <API-KEY>", or set your authenticator ' \
         | 
| 520 | 
            +
                                               'using "Stripe.authenticator = <AUTHENTICATOR>"' \
         | 
| 521 | 
            +
                  end
         | 
| 522 | 
            +
             | 
| 523 | 
            +
                  unless api_key || authenticator
         | 
| 524 | 
            +
                    # Default to missing API key error message for general users.
         | 
| 509 525 | 
             
                    raise AuthenticationError, "No API key provided. " \
         | 
| 510 526 | 
             
                                               'Set your API key using "Stripe.api_key = <API-KEY>". ' \
         | 
| 511 527 | 
             
                                               "You can generate API keys from the Stripe web interface. " \
         | 
| @@ -524,7 +540,7 @@ module Stripe | |
| 524 540 | 
             
                # Encodes a set of body parameters using multipart if `Content-Type` is set
         | 
| 525 541 | 
             
                # for that, or standard form-encoding otherwise. Returns the encoded body
         | 
| 526 542 | 
             
                # and a version of the encoded body that's safe to be logged.
         | 
| 527 | 
            -
                private def encode_body(body_params, headers)
         | 
| 543 | 
            +
                private def encode_body(body_params, headers, api_mode)
         | 
| 528 544 | 
             
                  body = nil
         | 
| 529 545 | 
             
                  flattened_params = Util.flatten_params(body_params)
         | 
| 530 546 |  | 
| @@ -540,15 +556,22 @@ module Stripe | |
| 540 556 | 
             
                    flattened_params =
         | 
| 541 557 | 
             
                      flattened_params.map { |k, v| [k, v.is_a?(String) ? v : v.to_s] }.to_h
         | 
| 542 558 |  | 
| 559 | 
            +
                  elsif api_mode == :preview
         | 
| 560 | 
            +
                    body = JSON.generate(body_params)
         | 
| 561 | 
            +
                    headers["Content-Type"] = "application/json"
         | 
| 543 562 | 
             
                  else
         | 
| 544 563 | 
             
                    body = Util.encode_parameters(body_params)
         | 
| 545 564 | 
             
                  end
         | 
| 546 565 |  | 
| 547 | 
            -
                   | 
| 548 | 
            -
             | 
| 549 | 
            -
             | 
| 550 | 
            -
             | 
| 551 | 
            -
             | 
| 566 | 
            +
                  body_log = if api_mode == :preview
         | 
| 567 | 
            +
                               body
         | 
| 568 | 
            +
                             else
         | 
| 569 | 
            +
                               # We don't use `Util.encode_parameters` partly as an optimization (to
         | 
| 570 | 
            +
                               # not redo work we've already done), and partly because the encoded
         | 
| 571 | 
            +
                               # forms of certain characters introduce a lot of visual noise and it's
         | 
| 572 | 
            +
                               # nice to have a clearer format for logs.
         | 
| 573 | 
            +
                               flattened_params.map { |k, v| "#{k}=#{v}" }.join("&")
         | 
| 574 | 
            +
                             end
         | 
| 552 575 |  | 
| 553 576 | 
             
                  [body, body_log]
         | 
| 554 577 | 
             
                end
         | 
| @@ -734,10 +757,11 @@ module Stripe | |
| 734 757 | 
             
                end
         | 
| 735 758 |  | 
| 736 759 | 
             
                private def specific_api_error(resp, error_data, context)
         | 
| 760 | 
            +
                  message = error_data[:message]
         | 
| 737 761 | 
             
                  Util.log_error("Stripe API error",
         | 
| 738 762 | 
             
                                 status: resp.http_status,
         | 
| 739 763 | 
             
                                 error_code: error_data[:code],
         | 
| 740 | 
            -
                                 error_message:  | 
| 764 | 
            +
                                 error_message: message,
         | 
| 741 765 | 
             
                                 error_param: error_data[:param],
         | 
| 742 766 | 
             
                                 error_type: error_data[:type],
         | 
| 743 767 | 
             
                                 idempotency_key: context.idempotency_key,
         | 
| @@ -758,26 +782,26 @@ module Stripe | |
| 758 782 | 
             
                  when 400, 404
         | 
| 759 783 | 
             
                    case error_data[:type]
         | 
| 760 784 | 
             
                    when "idempotency_error"
         | 
| 761 | 
            -
                      IdempotencyError.new( | 
| 785 | 
            +
                      IdempotencyError.new(message, **opts)
         | 
| 762 786 | 
             
                    else
         | 
| 763 787 | 
             
                      InvalidRequestError.new(
         | 
| 764 | 
            -
                         | 
| 788 | 
            +
                        message, error_data[:param],
         | 
| 765 789 | 
             
                        **opts
         | 
| 766 790 | 
             
                      )
         | 
| 767 791 | 
             
                    end
         | 
| 768 792 | 
             
                  when 401
         | 
| 769 | 
            -
                    AuthenticationError.new( | 
| 793 | 
            +
                    AuthenticationError.new(message, **opts)
         | 
| 770 794 | 
             
                  when 402
         | 
| 771 795 | 
             
                    CardError.new(
         | 
| 772 | 
            -
                       | 
| 796 | 
            +
                      message, error_data[:param],
         | 
| 773 797 | 
             
                      **opts
         | 
| 774 798 | 
             
                    )
         | 
| 775 799 | 
             
                  when 403
         | 
| 776 | 
            -
                    PermissionError.new( | 
| 800 | 
            +
                    PermissionError.new(message, **opts)
         | 
| 777 801 | 
             
                  when 429
         | 
| 778 | 
            -
                    RateLimitError.new( | 
| 802 | 
            +
                    RateLimitError.new(message, **opts)
         | 
| 779 803 | 
             
                  else
         | 
| 780 | 
            -
                    APIError.new( | 
| 804 | 
            +
                    APIError.new(message, **opts)
         | 
| 781 805 | 
             
                  end
         | 
| 782 806 | 
             
                end
         | 
| 783 807 |  | 
| @@ -845,16 +869,20 @@ module Stripe | |
| 845 869 | 
             
                        message + "\n\n(Network error: #{error.message})"
         | 
| 846 870 | 
             
                end
         | 
| 847 871 |  | 
| 848 | 
            -
                private def request_headers(api_key, method)
         | 
| 872 | 
            +
                private def request_headers(api_key, method, api_mode)
         | 
| 849 873 | 
             
                  user_agent = "Stripe/v1 RubyBindings/#{Stripe::VERSION}"
         | 
| 850 874 | 
             
                  user_agent += " " + format_app_info(Stripe.app_info) unless Stripe.app_info.nil?
         | 
| 851 875 |  | 
| 852 876 | 
             
                  headers = {
         | 
| 853 877 | 
             
                    "User-Agent" => user_agent,
         | 
| 854 878 | 
             
                    "Authorization" => "Bearer #{api_key}",
         | 
| 855 | 
            -
                    "Content-Type" => "application/x-www-form-urlencoded",
         | 
| 856 879 | 
             
                  }
         | 
| 857 880 |  | 
| 881 | 
            +
                  if api_mode != :preview
         | 
| 882 | 
            +
                    # TODO: (major) don't set Content-Type if method is not post
         | 
| 883 | 
            +
                    headers["Content-Type"] = "application/x-www-form-urlencoded"
         | 
| 884 | 
            +
                  end
         | 
| 885 | 
            +
             | 
| 858 886 | 
             
                  if config.enable_telemetry? && !@last_request_metrics.nil?
         | 
| 859 887 | 
             
                    headers["X-Stripe-Client-Telemetry"] = JSON.generate(
         | 
| 860 888 | 
             
                      last_request_metrics: @last_request_metrics.payload
         | 
| @@ -867,7 +895,12 @@ module Stripe | |
| 867 895 | 
             
                    headers["Idempotency-Key"] ||= SecureRandom.uuid
         | 
| 868 896 | 
             
                  end
         | 
| 869 897 |  | 
| 870 | 
            -
                   | 
| 898 | 
            +
                  if api_mode == :preview
         | 
| 899 | 
            +
                    headers["Stripe-Version"] = ApiVersion::PREVIEW
         | 
| 900 | 
            +
                  elsif config.api_version
         | 
| 901 | 
            +
                    headers["Stripe-Version"] = config.api_version
         | 
| 902 | 
            +
                  end
         | 
| 903 | 
            +
             | 
| 871 904 | 
             
                  headers["Stripe-Account"] = config.stripe_account if config.stripe_account
         | 
| 872 905 |  | 
| 873 906 | 
             
                  user_agent = @system_profiler.user_agent
         | 
| @@ -950,7 +983,8 @@ module Stripe | |
| 950 983 | 
             
                # that we can log certain information. It's useful because it means that we
         | 
| 951 984 | 
             
                # don't have to pass around as many parameters.
         | 
| 952 985 | 
             
                class RequestLogContext
         | 
| 953 | 
            -
                  attr_accessor :body, :account, :api_key, :api_version, :idempotency_key, :method, :path, :query, | 
| 986 | 
            +
                  attr_accessor :body, :account, :api_key, :authenticator, :api_version, :idempotency_key, :method, :path, :query,
         | 
| 987 | 
            +
                                :request_id
         | 
| 954 988 |  | 
| 955 989 | 
             
                  # The idea with this method is that we might want to update some of
         | 
| 956 990 | 
             
                  # context information because a response that we've received from the API
         | 
| @@ -25,7 +25,7 @@ module Stripe | |
| 25 25 | 
             
              # If `.logger` is set, the value of `.log_level` is ignored. The decision on
         | 
| 26 26 | 
             
              # what levels to print is entirely deferred to the logger.
         | 
| 27 27 | 
             
              class StripeConfiguration
         | 
| 28 | 
            -
                attr_accessor :api_key, :api_version, :client_id, :enable_telemetry, :logger, :stripe_account
         | 
| 28 | 
            +
                attr_accessor :api_key, :api_version, :authenticator, :client_id, :enable_telemetry, :logger, :stripe_account
         | 
| 29 29 |  | 
| 30 30 | 
             
                attr_reader :api_base, :uploads_base, :connect_base, :ca_bundle_path, :log_level, :initial_network_retry_delay,
         | 
| 31 31 | 
             
                            # rubocop:todo Layout/LineLength
         | 
| @@ -50,6 +50,7 @@ module Stripe | |
| 50 50 |  | 
| 51 51 | 
             
                def initialize
         | 
| 52 52 | 
             
                  @api_version = ApiVersion::CURRENT
         | 
| 53 | 
            +
             | 
| 53 54 | 
             
                  @ca_bundle_path = Stripe::DEFAULT_CA_BUNDLE_PATH
         | 
| 54 55 | 
             
                  @enable_telemetry = true
         | 
| 55 56 | 
             
                  @verify_ssl_certs = true
         | 
    
        data/lib/stripe/util.rb
    CHANGED
    
    | @@ -7,6 +7,7 @@ module Stripe | |
| 7 7 | 
             
                # Options that a user is allowed to specify.
         | 
| 8 8 | 
             
                OPTS_USER_SPECIFIED = Set[
         | 
| 9 9 | 
             
                  :api_key,
         | 
| 10 | 
            +
                  :authenticator,
         | 
| 10 11 | 
             
                  :idempotency_key,
         | 
| 11 12 | 
             
                  :stripe_account,
         | 
| 12 13 | 
             
                  :stripe_version
         | 
| @@ -279,7 +280,13 @@ module Stripe | |
| 279 280 | 
             
                  when String
         | 
| 280 281 | 
             
                    { api_key: opts }
         | 
| 281 282 | 
             
                  when Hash
         | 
| 282 | 
            -
                     | 
| 283 | 
            +
                    # If the user is using request signing for authentication,
         | 
| 284 | 
            +
                    # no need to check the api_key per request.
         | 
| 285 | 
            +
                    if !(opts.key?(:client) &&
         | 
| 286 | 
            +
                       opts.fetch(:client).config.authenticator) &&
         | 
| 287 | 
            +
                       opts.key?(:api_key)
         | 
| 288 | 
            +
                      check_api_key!(opts.fetch(:api_key))
         | 
| 289 | 
            +
                    end
         | 
| 283 290 | 
             
                    # Explicitly use dup here instead of clone to avoid preserving freeze
         | 
| 284 291 | 
             
                    # state on input params.
         | 
| 285 292 | 
             
                    opts.dup
         | 
    
        data/lib/stripe/version.rb
    CHANGED
    
    
    
        data/lib/stripe.rb
    CHANGED
    
    | @@ -13,6 +13,7 @@ require "set" | |
| 13 13 | 
             
            require "socket"
         | 
| 14 14 | 
             
            require "uri"
         | 
| 15 15 | 
             
            require "forwardable"
         | 
| 16 | 
            +
            require "base64"
         | 
| 16 17 |  | 
| 17 18 | 
             
            # Version
         | 
| 18 19 | 
             
            require "stripe/api_version"
         | 
| @@ -45,6 +46,7 @@ require "stripe/api_resource_test_helpers" | |
| 45 46 | 
             
            require "stripe/singleton_api_resource"
         | 
| 46 47 | 
             
            require "stripe/webhook"
         | 
| 47 48 | 
             
            require "stripe/stripe_configuration"
         | 
| 49 | 
            +
            require "stripe/request_signing_authenticator"
         | 
| 48 50 |  | 
| 49 51 | 
             
            # Named API resources
         | 
| 50 52 | 
             
            require "stripe/resources"
         | 
| @@ -71,6 +73,7 @@ module Stripe | |
| 71 73 |  | 
| 72 74 | 
             
                # User configurable options
         | 
| 73 75 | 
             
                def_delegators :@config, :api_key, :api_key=
         | 
| 76 | 
            +
                def_delegators :@config, :authenticator, :authenticator=
         | 
| 74 77 | 
             
                def_delegators :@config, :api_version, :api_version=
         | 
| 75 78 | 
             
                def_delegators :@config, :stripe_account, :stripe_account=
         | 
| 76 79 | 
             
                def_delegators :@config, :api_base, :api_base=
         | 
| @@ -117,6 +120,57 @@ module Stripe | |
| 117 120 | 
             
                  version: version,
         | 
| 118 121 | 
             
                }
         | 
| 119 122 | 
             
              end
         | 
| 123 | 
            +
             | 
| 124 | 
            +
              def self.add_beta_version(beta_name, version)
         | 
| 125 | 
            +
                if api_version.include?("; #{beta_name}=")
         | 
| 126 | 
            +
                  raise "Stripe version header #{api_version} already contains entry for beta #{beta_name}"
         | 
| 127 | 
            +
                end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                self.api_version = "#{api_version}; #{beta_name}=#{version}"
         | 
| 130 | 
            +
              end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
              class Preview
         | 
| 133 | 
            +
                def self._get_default_opts(opts)
         | 
| 134 | 
            +
                  { api_mode: :preview }.merge(opts)
         | 
| 135 | 
            +
                end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                def self.get(url, opts = {})
         | 
| 138 | 
            +
                  Stripe.raw_request(:get, url, {}, _get_default_opts(opts))
         | 
| 139 | 
            +
                end
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                def self.post(url, params = {}, opts = {})
         | 
| 142 | 
            +
                  Stripe.raw_request(:post, url, params, _get_default_opts(opts))
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
             | 
| 145 | 
            +
                def self.delete(url, opts = {})
         | 
| 146 | 
            +
                  Stripe.raw_request(:delete, url, {}, _get_default_opts(opts))
         | 
| 147 | 
            +
                end
         | 
| 148 | 
            +
              end
         | 
| 149 | 
            +
             | 
| 150 | 
            +
              class RawRequest
         | 
| 151 | 
            +
                include Stripe::APIOperations::Request
         | 
| 152 | 
            +
             | 
| 153 | 
            +
                def initialize
         | 
| 154 | 
            +
                  @opts = {}
         | 
| 155 | 
            +
                end
         | 
| 156 | 
            +
             | 
| 157 | 
            +
                def execute(method, url, params = {}, opts = {}, usage = [])
         | 
| 158 | 
            +
                  resp, = execute_resource_request(method, url, params, opts, usage)
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                  resp
         | 
| 161 | 
            +
                end
         | 
| 162 | 
            +
              end
         | 
| 163 | 
            +
             | 
| 164 | 
            +
              # Sends a request to Stripe REST API
         | 
| 165 | 
            +
              def self.raw_request(method, url, params = {}, opts = {})
         | 
| 166 | 
            +
                req = RawRequest.new
         | 
| 167 | 
            +
                req.execute(method, url, params, opts, ["raw_request"])
         | 
| 168 | 
            +
              end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
              def self.deserialize(data)
         | 
| 171 | 
            +
                data = JSON.parse(data) if data.is_a?(String)
         | 
| 172 | 
            +
                Util.convert_to_stripe_object(data, {})
         | 
| 173 | 
            +
              end
         | 
| 120 174 | 
             
            end
         | 
| 121 175 |  | 
| 122 176 | 
             
            Stripe.log_level = ENV["STRIPE_LOG"] unless ENV["STRIPE_LOG"].nil?
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: stripe
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 11. | 
| 4 | 
            +
              version: 11.3.0.pre.beta.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stripe
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2024-04- | 
| 11 | 
            +
            date: 2024-04-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Stripe is the easiest way to accept payments online.  See https://stripe.com
         | 
| 14 14 | 
             
              for details.
         | 
| @@ -51,9 +51,11 @@ files: | |
| 51 51 | 
             
            - lib/stripe/multipart_encoder.rb
         | 
| 52 52 | 
             
            - lib/stripe/oauth.rb
         | 
| 53 53 | 
             
            - lib/stripe/object_types.rb
         | 
| 54 | 
            +
            - lib/stripe/request_signing_authenticator.rb
         | 
| 54 55 | 
             
            - lib/stripe/resources.rb
         | 
| 55 56 | 
             
            - lib/stripe/resources/account.rb
         | 
| 56 57 | 
             
            - lib/stripe/resources/account_link.rb
         | 
| 58 | 
            +
            - lib/stripe/resources/account_notice.rb
         | 
| 57 59 | 
             
            - lib/stripe/resources/account_session.rb
         | 
| 58 60 | 
             
            - lib/stripe/resources/alipay_account.rb
         | 
| 59 61 | 
             
            - lib/stripe/resources/apple_pay_domain.rb
         | 
| @@ -70,6 +72,9 @@ files: | |
| 70 72 | 
             
            - lib/stripe/resources/billing_portal/configuration.rb
         | 
| 71 73 | 
             
            - lib/stripe/resources/billing_portal/session.rb
         | 
| 72 74 | 
             
            - lib/stripe/resources/capability.rb
         | 
| 75 | 
            +
            - lib/stripe/resources/capital/financing_offer.rb
         | 
| 76 | 
            +
            - lib/stripe/resources/capital/financing_summary.rb
         | 
| 77 | 
            +
            - lib/stripe/resources/capital/financing_transaction.rb
         | 
| 73 78 | 
             
            - lib/stripe/resources/card.rb
         | 
| 74 79 | 
             
            - lib/stripe/resources/cash_balance.rb
         | 
| 75 80 | 
             
            - lib/stripe/resources/charge.rb
         | 
| @@ -96,20 +101,25 @@ files: | |
| 96 101 | 
             
            - lib/stripe/resources/file.rb
         | 
| 97 102 | 
             
            - lib/stripe/resources/file_link.rb
         | 
| 98 103 | 
             
            - lib/stripe/resources/financial_connections/account.rb
         | 
| 104 | 
            +
            - lib/stripe/resources/financial_connections/account_inferred_balance.rb
         | 
| 99 105 | 
             
            - lib/stripe/resources/financial_connections/account_owner.rb
         | 
| 100 106 | 
             
            - lib/stripe/resources/financial_connections/account_ownership.rb
         | 
| 101 107 | 
             
            - lib/stripe/resources/financial_connections/session.rb
         | 
| 102 108 | 
             
            - lib/stripe/resources/financial_connections/transaction.rb
         | 
| 103 109 | 
             
            - lib/stripe/resources/forwarding/request.rb
         | 
| 104 110 | 
             
            - lib/stripe/resources/funding_instructions.rb
         | 
| 111 | 
            +
            - lib/stripe/resources/gift_cards/card.rb
         | 
| 112 | 
            +
            - lib/stripe/resources/gift_cards/transaction.rb
         | 
| 105 113 | 
             
            - lib/stripe/resources/identity/verification_report.rb
         | 
| 106 114 | 
             
            - lib/stripe/resources/identity/verification_session.rb
         | 
| 107 115 | 
             
            - lib/stripe/resources/invoice.rb
         | 
| 108 116 | 
             
            - lib/stripe/resources/invoice_item.rb
         | 
| 109 117 | 
             
            - lib/stripe/resources/invoice_line_item.rb
         | 
| 118 | 
            +
            - lib/stripe/resources/invoice_payment.rb
         | 
| 110 119 | 
             
            - lib/stripe/resources/issuing/authorization.rb
         | 
| 111 120 | 
             
            - lib/stripe/resources/issuing/card.rb
         | 
| 112 121 | 
             
            - lib/stripe/resources/issuing/cardholder.rb
         | 
| 122 | 
            +
            - lib/stripe/resources/issuing/credit_underwriting_record.rb
         | 
| 113 123 | 
             
            - lib/stripe/resources/issuing/dispute.rb
         | 
| 114 124 | 
             
            - lib/stripe/resources/issuing/personalization_design.rb
         | 
| 115 125 | 
             
            - lib/stripe/resources/issuing/physical_bundle.rb
         | 
| @@ -118,6 +128,8 @@ files: | |
| 118 128 | 
             
            - lib/stripe/resources/line_item.rb
         | 
| 119 129 | 
             
            - lib/stripe/resources/login_link.rb
         | 
| 120 130 | 
             
            - lib/stripe/resources/mandate.rb
         | 
| 131 | 
            +
            - lib/stripe/resources/margin.rb
         | 
| 132 | 
            +
            - lib/stripe/resources/order.rb
         | 
| 121 133 | 
             
            - lib/stripe/resources/payment_intent.rb
         | 
| 122 134 | 
             
            - lib/stripe/resources/payment_link.rb
         | 
| 123 135 | 
             
            - lib/stripe/resources/payment_method.rb
         | 
| @@ -131,6 +143,9 @@ files: | |
| 131 143 | 
             
            - lib/stripe/resources/product_feature.rb
         | 
| 132 144 | 
             
            - lib/stripe/resources/promotion_code.rb
         | 
| 133 145 | 
             
            - lib/stripe/resources/quote.rb
         | 
| 146 | 
            +
            - lib/stripe/resources/quote_phase.rb
         | 
| 147 | 
            +
            - lib/stripe/resources/quote_preview_invoice.rb
         | 
| 148 | 
            +
            - lib/stripe/resources/quote_preview_subscription_schedule.rb
         | 
| 134 149 | 
             
            - lib/stripe/resources/radar/early_fraud_warning.rb
         | 
| 135 150 | 
             
            - lib/stripe/resources/radar/value_list.rb
         | 
| 136 151 | 
             
            - lib/stripe/resources/radar/value_list_item.rb
         | 
| @@ -151,6 +166,7 @@ files: | |
| 151 166 | 
             
            - lib/stripe/resources/subscription_schedule.rb
         | 
| 152 167 | 
             
            - lib/stripe/resources/tax/calculation.rb
         | 
| 153 168 | 
             
            - lib/stripe/resources/tax/calculation_line_item.rb
         | 
| 169 | 
            +
            - lib/stripe/resources/tax/form.rb
         | 
| 154 170 | 
             
            - lib/stripe/resources/tax/registration.rb
         | 
| 155 171 | 
             
            - lib/stripe/resources/tax/settings.rb
         | 
| 156 172 | 
             
            - lib/stripe/resources/tax/transaction.rb
         | 
| @@ -212,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 212 228 | 
             
                  version: 2.3.0
         | 
| 213 229 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 214 230 | 
             
              requirements:
         | 
| 215 | 
            -
              - - " | 
| 231 | 
            +
              - - ">"
         | 
| 216 232 | 
             
                - !ruby/object:Gem::Version
         | 
| 217 | 
            -
                  version:  | 
| 233 | 
            +
                  version: 1.3.1
         | 
| 218 234 | 
             
            requirements: []
         | 
| 219 235 | 
             
            rubygems_version: 3.3.26
         | 
| 220 236 | 
             
            signing_key: 
         |