stripe 5.55.0 → 13.5.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 +567 -4
- data/Gemfile +12 -4
- data/Makefile +18 -3
- data/OPENAPI_VERSION +1 -0
- data/README.md +93 -21
- data/Rakefile +3 -6
- data/VERSION +1 -1
- data/examples/README.md +16 -0
- data/examples/example_template.rb +36 -0
- data/examples/meter_event_stream.rb +57 -0
- data/examples/thinevent_webhook_handler.rb +39 -0
- data/{bin → exe}/stripe-console +1 -1
- data/justfile +43 -0
- data/lib/data/ca-certificates.crt +1241 -1937
- data/lib/stripe/api_operations/create.rb +6 -2
- data/lib/stripe/api_operations/delete.rb +12 -7
- data/lib/stripe/api_operations/list.rb +6 -9
- data/lib/stripe/api_operations/nested_resource.rb +63 -35
- data/lib/stripe/api_operations/request.rb +29 -65
- data/lib/stripe/api_operations/save.rb +20 -10
- data/lib/stripe/api_operations/search.rb +11 -9
- data/lib/stripe/api_operations/singleton_save.rb +90 -0
- data/lib/stripe/api_requestor.rb +1131 -0
- data/lib/stripe/api_resource.rb +48 -18
- data/lib/stripe/api_resource_test_helpers.rb +9 -3
- data/lib/stripe/api_version.rb +8 -0
- data/lib/stripe/connection_manager.rb +5 -7
- data/lib/stripe/errors.rb +11 -13
- data/lib/stripe/event_types.rb +14 -0
- data/lib/stripe/events/v1_billing_meter_error_report_triggered_event.rb +23 -0
- data/lib/stripe/events/v1_billing_meter_no_meter_found_event.rb +13 -0
- data/lib/stripe/instrumentation.rb +37 -15
- data/lib/stripe/list_object.rb +5 -3
- data/lib/stripe/multipart_encoder.rb +7 -7
- data/lib/stripe/oauth.rb +14 -21
- data/lib/stripe/object_types.rb +151 -103
- data/lib/stripe/request_options.rb +129 -0
- data/lib/stripe/resources/account.rb +129 -25
- data/lib/stripe/resources/account_link.rb +12 -0
- data/lib/stripe/resources/account_session.rb +25 -0
- data/lib/stripe/resources/alipay_account.rb +1 -1
- data/lib/stripe/resources/apple_pay_domain.rb +38 -0
- data/lib/stripe/resources/application_fee.rb +9 -2
- data/lib/stripe/resources/application_fee_refund.rb +9 -2
- data/lib/stripe/resources/apps/secret.rb +55 -0
- data/lib/stripe/resources/balance.rb +14 -0
- data/lib/stripe/resources/balance_transaction.rb +19 -0
- data/lib/stripe/resources/bank_account.rb +53 -4
- data/lib/stripe/resources/billing/alert.rb +87 -0
- data/lib/stripe/resources/billing/credit_balance_summary.rb +14 -0
- data/lib/stripe/resources/billing/credit_balance_transaction.rb +26 -0
- data/lib/stripe/resources/billing/credit_grant.rb +90 -0
- data/lib/stripe/resources/billing/meter.rb +85 -0
- data/lib/stripe/resources/billing/meter_event.rb +26 -0
- data/lib/stripe/resources/billing/meter_event_adjustment.rb +26 -0
- data/lib/stripe/resources/billing/meter_event_summary.rb +17 -0
- data/lib/stripe/resources/billing_portal/configuration.rb +34 -0
- data/lib/stripe/resources/billing_portal/session.rb +27 -0
- data/lib/stripe/resources/capability.rb +7 -2
- data/lib/stripe/resources/card.rb +34 -3
- data/lib/stripe/resources/cash_balance.rb +4 -0
- data/lib/stripe/resources/charge.rb +52 -3
- data/lib/stripe/resources/checkout/session.rb +83 -5
- data/lib/stripe/resources/climate/order.rb +67 -0
- data/lib/stripe/resources/climate/product.rb +27 -0
- data/lib/stripe/resources/climate/supplier.rb +26 -0
- data/lib/stripe/resources/confirmation_token.rb +39 -0
- data/lib/stripe/resources/country_spec.rb +14 -0
- data/lib/stripe/resources/coupon.rb +48 -0
- data/lib/stripe/resources/credit_note.rb +67 -9
- data/lib/stripe/resources/credit_note_line_item.rb +4 -0
- data/lib/stripe/resources/customer.rb +172 -28
- data/lib/stripe/resources/customer_balance_transaction.rb +9 -1
- data/lib/stripe/resources/customer_cash_balance_transaction.rb +15 -0
- data/lib/stripe/resources/customer_session.rb +29 -0
- data/lib/stripe/resources/discount.rb +7 -0
- data/lib/stripe/resources/dispute.rb +41 -3
- data/lib/stripe/resources/entitlements/active_entitlement.rb +26 -0
- data/lib/stripe/resources/entitlements/feature.rb +49 -0
- data/lib/stripe/resources/ephemeral_key.rb +23 -0
- data/lib/stripe/resources/event.rb +38 -0
- data/lib/stripe/resources/exchange_rate.rb +34 -0
- data/lib/stripe/resources/file.rb +37 -15
- data/lib/stripe/resources/file_link.rb +26 -0
- data/lib/stripe/resources/financial_connections/account.rb +101 -6
- data/lib/stripe/resources/financial_connections/account_owner.rb +4 -0
- data/lib/stripe/resources/financial_connections/account_ownership.rb +4 -0
- data/lib/stripe/resources/financial_connections/session.rb +14 -0
- data/lib/stripe/resources/financial_connections/transaction.rb +26 -0
- data/lib/stripe/resources/forwarding/request.rb +52 -0
- data/lib/stripe/resources/funding_instructions.rb +8 -0
- data/lib/stripe/resources/identity/verification_report.rb +24 -0
- data/lib/stripe/resources/identity/verification_session.rb +117 -5
- data/lib/stripe/resources/invoice.rb +247 -20
- data/lib/stripe/resources/invoice_item.rb +54 -0
- data/lib/stripe/resources/invoice_line_item.rb +22 -1
- data/lib/stripe/resources/invoice_rendering_template.rb +65 -0
- data/lib/stripe/resources/issuing/authorization.rb +210 -5
- data/lib/stripe/resources/issuing/card.rb +128 -4
- data/lib/stripe/resources/issuing/cardholder.rb +36 -0
- data/lib/stripe/resources/issuing/dispute.rb +47 -2
- data/lib/stripe/resources/issuing/personalization_design.rb +119 -0
- data/lib/stripe/resources/issuing/physical_bundle.rb +26 -0
- data/lib/stripe/resources/issuing/token.rb +32 -0
- data/lib/stripe/resources/issuing/transaction.rb +79 -0
- data/lib/stripe/resources/line_item.rb +4 -0
- data/lib/stripe/resources/login_link.rb +4 -0
- data/lib/stripe/resources/mandate.rb +4 -0
- data/lib/stripe/resources/payment_intent.rb +238 -15
- data/lib/stripe/resources/payment_link.rb +39 -2
- data/lib/stripe/resources/payment_method.rb +78 -5
- data/lib/stripe/resources/payment_method_configuration.rb +59 -0
- data/lib/stripe/resources/payment_method_domain.rb +79 -0
- data/lib/stripe/resources/payout.rb +63 -5
- data/lib/stripe/resources/person.rb +8 -1
- data/lib/stripe/resources/plan.rb +51 -0
- data/lib/stripe/resources/price.rb +30 -1
- data/lib/stripe/resources/product.rb +55 -1
- data/lib/stripe/resources/product_feature.rb +13 -0
- data/lib/stripe/resources/promotion_code.rb +25 -0
- data/lib/stripe/resources/quote.rb +97 -39
- data/lib/stripe/resources/radar/early_fraud_warning.rb +17 -0
- data/lib/stripe/resources/radar/value_list.rb +56 -0
- data/lib/stripe/resources/radar/value_list_item.rb +46 -0
- data/lib/stripe/resources/refund.rb +70 -5
- data/lib/stripe/resources/reporting/report_run.rb +31 -0
- data/lib/stripe/resources/reporting/report_type.rb +21 -1
- data/lib/stripe/resources/reversal.rb +17 -2
- data/lib/stripe/resources/review.rb +24 -3
- data/lib/stripe/resources/setup_attempt.rb +12 -0
- data/lib/stripe/resources/setup_intent.rb +113 -7
- data/lib/stripe/resources/shipping_rate.rb +25 -0
- data/lib/stripe/resources/sigma/scheduled_query_run.rb +17 -0
- data/lib/stripe/resources/source.rb +52 -10
- data/lib/stripe/resources/source_transaction.rb +7 -0
- data/lib/stripe/resources/subscription.rb +118 -5
- data/lib/stripe/resources/subscription_item.rb +54 -6
- data/lib/stripe/resources/subscription_schedule.rb +60 -5
- data/lib/stripe/resources/tax/calculation.rb +48 -0
- data/lib/stripe/resources/tax/calculation_line_item.rb +13 -0
- data/lib/stripe/resources/tax/registration.rb +54 -0
- data/lib/stripe/resources/tax/settings.rb +17 -0
- data/lib/stripe/resources/tax/transaction.rb +56 -0
- data/lib/stripe/resources/tax/transaction_line_item.rb +13 -0
- data/lib/stripe/resources/tax_code.rb +9 -0
- data/lib/stripe/resources/tax_id.rb +34 -12
- data/lib/stripe/resources/tax_rate.rb +26 -0
- data/lib/stripe/resources/terminal/configuration.rb +54 -0
- data/lib/stripe/resources/terminal/connection_token.rb +16 -0
- data/lib/stripe/resources/terminal/location.rb +57 -0
- data/lib/stripe/resources/terminal/reader.rb +138 -11
- data/lib/stripe/resources/test_helpers/test_clock.rb +58 -3
- data/lib/stripe/resources/token.rb +29 -0
- data/lib/stripe/resources/topup.rb +40 -3
- data/lib/stripe/resources/transfer.rb +29 -6
- data/lib/stripe/resources/treasury/credit_reversal.rb +37 -0
- data/lib/stripe/resources/treasury/debit_reversal.rb +37 -0
- data/lib/stripe/resources/treasury/financial_account.rb +109 -0
- data/lib/stripe/resources/treasury/financial_account_features.rb +15 -0
- data/lib/stripe/resources/treasury/inbound_transfer.rb +130 -0
- data/lib/stripe/resources/treasury/outbound_payment.rb +152 -0
- data/lib/stripe/resources/treasury/outbound_transfer.rb +152 -0
- data/lib/stripe/resources/treasury/received_credit.rb +47 -0
- data/lib/stripe/resources/treasury/received_debit.rb +47 -0
- data/lib/stripe/resources/treasury/transaction.rb +26 -0
- data/lib/stripe/resources/treasury/transaction_entry.rb +30 -0
- data/lib/stripe/resources/usage_record.rb +9 -0
- data/lib/stripe/resources/usage_record_summary.rb +4 -0
- data/lib/stripe/resources/v2/billing/meter_event.rb +16 -0
- data/lib/stripe/resources/v2/billing/meter_event_adjustment.rb +15 -0
- data/lib/stripe/resources/v2/billing/meter_event_session.rb +15 -0
- data/lib/stripe/resources/v2/event.rb +13 -0
- data/lib/stripe/resources/v2/event_destination.rb +13 -0
- data/lib/stripe/resources/webhook_endpoint.rb +55 -0
- data/lib/stripe/resources.rb +51 -10
- data/lib/stripe/search_result_object.rb +5 -2
- data/lib/stripe/services/account_capability_service.rb +39 -0
- data/lib/stripe/services/account_external_account_service.rb +68 -0
- data/lib/stripe/services/account_link_service.rb +17 -0
- data/lib/stripe/services/account_login_link_service.rb +19 -0
- data/lib/stripe/services/account_person_service.rb +61 -0
- data/lib/stripe/services/account_service.rb +100 -0
- data/lib/stripe/services/account_session_service.rb +17 -0
- data/lib/stripe/services/apple_pay_domain_service.rb +50 -0
- data/lib/stripe/services/application_fee_refund_service.rb +60 -0
- data/lib/stripe/services/application_fee_service.rb +35 -0
- data/lib/stripe/services/apps/secret_service.rb +52 -0
- data/lib/stripe/services/apps_service.rb +13 -0
- data/lib/stripe/services/balance_service.rb +12 -0
- data/lib/stripe/services/balance_transaction_service.rb +32 -0
- data/lib/stripe/services/billing/alert_service.rb +74 -0
- data/lib/stripe/services/billing/credit_balance_summary_service.rb +19 -0
- data/lib/stripe/services/billing/credit_balance_transaction_service.rb +30 -0
- data/lib/stripe/services/billing/credit_grant_service.rb +74 -0
- data/lib/stripe/services/billing/meter_event_adjustment_service.rb +19 -0
- data/lib/stripe/services/billing/meter_event_service.rb +19 -0
- data/lib/stripe/services/billing/meter_event_summary_service.rb +19 -0
- data/lib/stripe/services/billing/meter_service.rb +81 -0
- data/lib/stripe/services/billing_portal/configuration_service.rb +52 -0
- data/lib/stripe/services/billing_portal/session_service.rb +19 -0
- data/lib/stripe/services/billing_portal_service.rb +14 -0
- data/lib/stripe/services/billing_service.rb +20 -0
- data/lib/stripe/services/charge_service.rb +69 -0
- data/lib/stripe/services/checkout/session_line_item_service.rb +19 -0
- data/lib/stripe/services/checkout/session_service.rb +72 -0
- data/lib/stripe/services/checkout_service.rb +13 -0
- data/lib/stripe/services/climate/order_service.rb +68 -0
- data/lib/stripe/services/climate/product_service.rb +30 -0
- data/lib/stripe/services/climate/supplier_service.rb +30 -0
- data/lib/stripe/services/climate_service.rb +15 -0
- data/lib/stripe/services/confirmation_token_service.rb +17 -0
- data/lib/stripe/services/country_spec_service.rb +28 -0
- data/lib/stripe/services/coupon_service.rb +51 -0
- data/lib/stripe/services/credit_note_line_item_service.rb +17 -0
- data/lib/stripe/services/credit_note_preview_lines_service.rb +17 -0
- data/lib/stripe/services/credit_note_service.rb +93 -0
- data/lib/stripe/services/customer_balance_transaction_service.rb +50 -0
- data/lib/stripe/services/customer_cash_balance_service.rb +28 -0
- data/lib/stripe/services/customer_cash_balance_transaction_service.rb +28 -0
- data/lib/stripe/services/customer_funding_instructions_service.rb +19 -0
- data/lib/stripe/services/customer_payment_method_service.rb +28 -0
- data/lib/stripe/services/customer_payment_source_service.rb +76 -0
- data/lib/stripe/services/customer_service.rb +89 -0
- data/lib/stripe/services/customer_session_service.rb +17 -0
- data/lib/stripe/services/customer_tax_id_service.rb +50 -0
- data/lib/stripe/services/dispute_service.rb +48 -0
- data/lib/stripe/services/entitlements/active_entitlement_service.rb +30 -0
- data/lib/stripe/services/entitlements/feature_service.rb +52 -0
- data/lib/stripe/services/entitlements_service.rb +14 -0
- data/lib/stripe/services/ephemeral_key_service.rb +28 -0
- data/lib/stripe/services/event_service.rb +22 -0
- data/lib/stripe/services/exchange_rate_service.rb +28 -0
- data/lib/stripe/services/file_link_service.rb +38 -0
- data/lib/stripe/services/file_service.rb +35 -0
- data/lib/stripe/services/financial_connections/account_owner_service.rb +19 -0
- data/lib/stripe/services/financial_connections/account_service.rb +81 -0
- data/lib/stripe/services/financial_connections/session_service.rb +30 -0
- data/lib/stripe/services/financial_connections/transaction_service.rb +30 -0
- data/lib/stripe/services/financial_connections_service.rb +15 -0
- data/lib/stripe/services/forwarding/request_service.rb +41 -0
- data/lib/stripe/services/forwarding_service.rb +13 -0
- data/lib/stripe/services/identity/verification_report_service.rb +30 -0
- data/lib/stripe/services/identity/verification_session_service.rb +106 -0
- data/lib/stripe/services/identity_service.rb +14 -0
- data/lib/stripe/services/invoice_item_service.rb +61 -0
- data/lib/stripe/services/invoice_line_item_service.rb +31 -0
- data/lib/stripe/services/invoice_rendering_template_service.rb +50 -0
- data/lib/stripe/services/invoice_service.rb +202 -0
- data/lib/stripe/services/invoice_upcoming_lines_service.rb +17 -0
- data/lib/stripe/services/issuing/authorization_service.rb +65 -0
- data/lib/stripe/services/issuing/card_service.rb +52 -0
- data/lib/stripe/services/issuing/cardholder_service.rb +52 -0
- data/lib/stripe/services/issuing/dispute_service.rb +63 -0
- data/lib/stripe/services/issuing/personalization_design_service.rb +52 -0
- data/lib/stripe/services/issuing/physical_bundle_service.rb +30 -0
- data/lib/stripe/services/issuing/token_service.rb +41 -0
- data/lib/stripe/services/issuing/transaction_service.rb +41 -0
- data/lib/stripe/services/issuing_service.rb +20 -0
- data/lib/stripe/services/mandate_service.rb +17 -0
- data/lib/stripe/services/oauth_service.rb +63 -0
- data/lib/stripe/services/payment_intent_service.rb +204 -0
- data/lib/stripe/services/payment_link_line_item_service.rb +17 -0
- data/lib/stripe/services/payment_link_service.rb +57 -0
- data/lib/stripe/services/payment_method_configuration_service.rb +50 -0
- data/lib/stripe/services/payment_method_domain_service.rb +66 -0
- data/lib/stripe/services/payment_method_service.rb +86 -0
- data/lib/stripe/services/payout_service.rb +66 -0
- data/lib/stripe/services/plan_service.rb +49 -0
- data/lib/stripe/services/price_service.rb +52 -0
- data/lib/stripe/services/product_feature_service.rb +50 -0
- data/lib/stripe/services/product_service.rb +70 -0
- data/lib/stripe/services/promotion_code_service.rb +50 -0
- data/lib/stripe/services/quote_computed_upfront_line_items_service.rb +17 -0
- data/lib/stripe/services/quote_line_item_service.rb +17 -0
- data/lib/stripe/services/quote_service.rb +92 -0
- data/lib/stripe/services/radar/early_fraud_warning_service.rb +32 -0
- data/lib/stripe/services/radar/value_list_item_service.rb +52 -0
- data/lib/stripe/services/radar/value_list_service.rb +63 -0
- data/lib/stripe/services/radar_service.rb +15 -0
- data/lib/stripe/services/refund_service.rb +63 -0
- data/lib/stripe/services/reporting/report_run_service.rb +41 -0
- data/lib/stripe/services/reporting/report_type_service.rb +30 -0
- data/lib/stripe/services/reporting_service.rb +14 -0
- data/lib/stripe/services/review_service.rb +33 -0
- data/lib/stripe/services/setup_attempt_service.rb +17 -0
- data/lib/stripe/services/setup_intent_service.rb +105 -0
- data/lib/stripe/services/shipping_rate_service.rb +50 -0
- data/lib/stripe/services/sigma/scheduled_query_run_service.rb +30 -0
- data/lib/stripe/services/sigma_service.rb +13 -0
- data/lib/stripe/services/source_service.rb +64 -0
- data/lib/stripe/services/source_transaction_service.rb +17 -0
- data/lib/stripe/services/subscription_item_service.rb +69 -0
- data/lib/stripe/services/subscription_item_usage_record_service.rb +23 -0
- data/lib/stripe/services/subscription_item_usage_record_summary_service.rb +19 -0
- data/lib/stripe/services/subscription_schedule_service.rb +72 -0
- data/lib/stripe/services/subscription_service.rb +127 -0
- data/lib/stripe/services/tax/calculation_line_item_service.rb +19 -0
- data/lib/stripe/services/tax/calculation_service.rb +37 -0
- data/lib/stripe/services/tax/registration_service.rb +54 -0
- data/lib/stripe/services/tax/settings_service.rb +30 -0
- data/lib/stripe/services/tax/transaction_line_item_service.rb +19 -0
- data/lib/stripe/services/tax/transaction_service.rb +48 -0
- data/lib/stripe/services/tax_code_service.rb +22 -0
- data/lib/stripe/services/tax_id_service.rb +38 -0
- data/lib/stripe/services/tax_rate_service.rb +38 -0
- data/lib/stripe/services/tax_service.rb +16 -0
- data/lib/stripe/services/terminal/configuration_service.rb +63 -0
- data/lib/stripe/services/terminal/connection_token_service.rb +19 -0
- data/lib/stripe/services/terminal/location_service.rb +64 -0
- data/lib/stripe/services/terminal/reader_service.rb +118 -0
- data/lib/stripe/services/terminal_service.rb +16 -0
- data/lib/stripe/services/test_helpers/confirmation_token_service.rb +19 -0
- data/lib/stripe/services/test_helpers/customer_service.rb +19 -0
- data/lib/stripe/services/test_helpers/issuing/authorization_service.rb +87 -0
- data/lib/stripe/services/test_helpers/issuing/card_service.rb +65 -0
- data/lib/stripe/services/test_helpers/issuing/personalization_design_service.rb +43 -0
- data/lib/stripe/services/test_helpers/issuing/transaction_service.rb +43 -0
- data/lib/stripe/services/test_helpers/issuing_service.rb +19 -0
- data/lib/stripe/services/test_helpers/refund_service.rb +19 -0
- data/lib/stripe/services/test_helpers/terminal/reader_service.rb +21 -0
- data/lib/stripe/services/test_helpers/terminal_service.rb +15 -0
- data/lib/stripe/services/test_helpers/test_clock_service.rb +63 -0
- data/lib/stripe/services/test_helpers/treasury/inbound_transfer_service.rb +43 -0
- data/lib/stripe/services/test_helpers/treasury/outbound_payment_service.rb +54 -0
- data/lib/stripe/services/test_helpers/treasury/outbound_transfer_service.rb +54 -0
- data/lib/stripe/services/test_helpers/treasury/received_credit_service.rb +21 -0
- data/lib/stripe/services/test_helpers/treasury/received_debit_service.rb +21 -0
- data/lib/stripe/services/test_helpers/treasury_service.rb +19 -0
- data/lib/stripe/services/test_helpers_service.rb +19 -0
- data/lib/stripe/services/token_service.rb +23 -0
- data/lib/stripe/services/topup_service.rb +49 -0
- data/lib/stripe/services/transfer_reversal_service.rb +56 -0
- data/lib/stripe/services/transfer_service.rb +47 -0
- data/lib/stripe/services/treasury/credit_reversal_service.rb +41 -0
- data/lib/stripe/services/treasury/debit_reversal_service.rb +41 -0
- data/lib/stripe/services/treasury/financial_account_features_service.rb +30 -0
- data/lib/stripe/services/treasury/financial_account_service.rb +70 -0
- data/lib/stripe/services/treasury/inbound_transfer_service.rb +52 -0
- data/lib/stripe/services/treasury/outbound_payment_service.rb +52 -0
- data/lib/stripe/services/treasury/outbound_transfer_service.rb +52 -0
- data/lib/stripe/services/treasury/received_credit_service.rb +30 -0
- data/lib/stripe/services/treasury/received_debit_service.rb +30 -0
- data/lib/stripe/services/treasury/transaction_entry_service.rb +30 -0
- data/lib/stripe/services/treasury/transaction_service.rb +30 -0
- data/lib/stripe/services/treasury_service.rb +22 -0
- data/lib/stripe/services/v1_services.rb +89 -0
- data/lib/stripe/services/v2/billing/meter_event_adjustment_service.rb +21 -0
- data/lib/stripe/services/v2/billing/meter_event_service.rb +21 -0
- data/lib/stripe/services/v2/billing/meter_event_session_service.rb +21 -0
- data/lib/stripe/services/v2/billing/meter_event_stream_service.rb +23 -0
- data/lib/stripe/services/v2/billing_service.rb +18 -0
- data/lib/stripe/services/v2/core/event_destination_service.rb +98 -0
- data/lib/stripe/services/v2/core/event_service.rb +32 -0
- data/lib/stripe/services/v2/core_service.rb +16 -0
- data/lib/stripe/services/v2_services.rb +14 -0
- data/lib/stripe/services/webhook_endpoint_service.rb +61 -0
- data/lib/stripe/services.rb +182 -0
- data/lib/stripe/singleton_api_resource.rb +3 -3
- data/lib/stripe/stripe_client.rb +55 -1028
- data/lib/stripe/stripe_configuration.rb +63 -42
- data/lib/stripe/stripe_object.rb +60 -38
- data/lib/stripe/stripe_response.rb +1 -3
- data/lib/stripe/stripe_service.rb +32 -0
- data/lib/stripe/thin_event.rb +37 -0
- data/lib/stripe/util.rb +109 -45
- data/lib/stripe/v2_list_object.rb +84 -0
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +3 -2
- data/lib/stripe.rb +39 -0
- data/stripe.gemspec +7 -4
- metadata +252 -13
- data/lib/stripe/resources/bitcoin_receiver.rb +0 -24
- data/lib/stripe/resources/bitcoin_transaction.rb +0 -16
- data/lib/stripe/resources/issuing/card_details.rb +0 -10
- data/lib/stripe/resources/order.rb +0 -33
- data/lib/stripe/resources/order_return.rb +0 -10
- data/lib/stripe/resources/recipient.rb +0 -14
- data/lib/stripe/resources/sku.rb +0 -13
- data/lib/stripe/resources/three_d_secure.rb +0 -14
data/lib/stripe/api_resource.rb
CHANGED
@@ -11,11 +11,26 @@ module Stripe
|
|
11
11
|
# for example, where this is allowed.
|
12
12
|
attr_accessor :save_with_parent
|
13
13
|
|
14
|
+
# TODO: (major) Remove OBJECT_NAME and stop using const_get here
|
15
|
+
# This is a workaround to avoid breaking users who have defined their own
|
16
|
+
# APIResource subclasses with a custom OBJECT_NAME. We should never fallback
|
17
|
+
# on this case otherwise.
|
18
|
+
OBJECT_NAME = ""
|
19
|
+
def self.object_name
|
20
|
+
const_get(:OBJECT_NAME)
|
21
|
+
end
|
22
|
+
|
14
23
|
def self.class_name
|
15
24
|
name.split("::")[-1]
|
16
25
|
end
|
17
26
|
|
18
27
|
def self.resource_url
|
28
|
+
if name.include?("Stripe::V2")
|
29
|
+
raise NotImplementedError,
|
30
|
+
"V2 resources do not have a defined URL. Please use the StripeClient " \
|
31
|
+
"to make V2 requests"
|
32
|
+
end
|
33
|
+
|
19
34
|
if self == APIResource
|
20
35
|
raise NotImplementedError,
|
21
36
|
"APIResource is an abstract class. You should perform actions " \
|
@@ -23,7 +38,7 @@ module Stripe
|
|
23
38
|
end
|
24
39
|
# Namespaces are separated in object names with periods (.) and in URLs
|
25
40
|
# with forward slashes (/), so replace the former with the latter.
|
26
|
-
"/v1/#{
|
41
|
+
"/v1/#{object_name.downcase.tr('.', '/')}s"
|
27
42
|
end
|
28
43
|
|
29
44
|
# A metaprogramming call that specifies that a field of a resource can be
|
@@ -78,33 +93,48 @@ module Stripe
|
|
78
93
|
end
|
79
94
|
|
80
95
|
def refresh
|
81
|
-
|
82
|
-
|
83
|
-
|
96
|
+
if self.class.name.include?("Stripe::V2")
|
97
|
+
raise NotImplementedError,
|
98
|
+
"It is not possible to refresh v2 objects. Please retrieve the object using the StripeClient instead."
|
99
|
+
end
|
100
|
+
|
101
|
+
opts = RequestOptions.extract_opts_from_hash(@retrieve_opts || {})
|
102
|
+
@retrieve_opts = {} # Make sure to clear the retrieve options
|
103
|
+
@obj = @requestor.execute_request_initialize_from(:get, resource_url, :api, self, params: @retrieve_params,
|
104
|
+
opts: opts)
|
105
|
+
initialize_from(
|
106
|
+
@obj.last_response.data,
|
107
|
+
@obj.instance_variable_get(:@opts),
|
108
|
+
@obj.last_response,
|
109
|
+
api_mode: :v1,
|
110
|
+
requestor: @requestor
|
111
|
+
)
|
84
112
|
end
|
85
113
|
|
86
114
|
def self.retrieve(id, opts = {})
|
87
|
-
|
88
|
-
|
115
|
+
if name.include?("Stripe::V2")
|
116
|
+
raise NotImplementedError,
|
117
|
+
"It is not possible to retrieve v2 objects on the resource. Please use the StripeClient instead."
|
118
|
+
end
|
119
|
+
|
120
|
+
instance = new(id)
|
121
|
+
# Explicitly send options for the retrieve call, to preserve custom headers
|
122
|
+
# This is so we can pass custom headers from this static function
|
123
|
+
# to the instance variable method call
|
124
|
+
# The custom headers will be cleaned up with the rest of the RequestOptions
|
125
|
+
instance.instance_variable_set(:@retrieve_opts, Util.normalize_opts(opts))
|
89
126
|
instance.refresh
|
90
|
-
instance
|
91
127
|
end
|
92
128
|
|
93
|
-
def request_stripe_object(method:, path:, params:, opts: {})
|
94
|
-
|
95
|
-
|
96
|
-
# If we're getting back this thing, update; otherwise, instantiate.
|
97
|
-
if Util.object_name_matches_class?(resp.data[:object], self.class)
|
98
|
-
initialize_from(resp.data, opts)
|
99
|
-
else
|
100
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
101
|
-
end
|
129
|
+
def request_stripe_object(method:, path:, params:, base_address: :api, opts: {})
|
130
|
+
APIRequestor.active_requestor.execute_request_initialize_from(method, path, base_address, self,
|
131
|
+
params: params, opts: opts)
|
102
132
|
end
|
103
133
|
|
104
|
-
protected def request_stream(method:, path:, params:, opts: {},
|
134
|
+
protected def request_stream(method:, path:, params:, base_address: :api, opts: {},
|
105
135
|
&read_body_chunk_block)
|
106
136
|
resp, = execute_resource_request_stream(
|
107
|
-
method, path, params, opts, &read_body_chunk_block
|
137
|
+
method, path, base_address, params, opts, &read_body_chunk_block
|
108
138
|
)
|
109
139
|
resp
|
110
140
|
end
|
@@ -8,10 +8,16 @@ module Stripe
|
|
8
8
|
# class MyAPIResource < APIResource
|
9
9
|
# class TestHelpers < APIResourceTestHelpers
|
10
10
|
class APIResourceTestHelpers
|
11
|
+
include Stripe::APIOperations::Request
|
12
|
+
|
11
13
|
def initialize(resource)
|
12
14
|
@resource = resource
|
13
15
|
end
|
14
16
|
|
17
|
+
def self.resource_class
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
15
21
|
# Adds a custom method to a test helper. This is used to add support for
|
16
22
|
# non-CRUDL API requests, e.g. capturing charges. custom_method takes the
|
17
23
|
# following parameters:
|
@@ -25,12 +31,12 @@ module Stripe
|
|
25
31
|
# adds a `capture` class method to the resource class that, when called,
|
26
32
|
# will send a POST request to `/v1/<object_name>/capture`.
|
27
33
|
def self.custom_method(name, http_verb:, http_path: nil)
|
28
|
-
Util.custom_method
|
34
|
+
Util.custom_method resource_class, self, name, http_verb, http_path
|
29
35
|
end
|
30
36
|
|
31
37
|
def self.resource_url
|
32
|
-
"/v1/test_helpers/"\
|
33
|
-
|
38
|
+
"/v1/test_helpers/" \
|
39
|
+
"#{resource_class.object_name.downcase.tr('.', '/')}s"
|
34
40
|
end
|
35
41
|
|
36
42
|
def resource_url
|
@@ -12,7 +12,7 @@ module Stripe
|
|
12
12
|
class ConnectionManager
|
13
13
|
# Timestamp (in seconds procured from the system's monotonic clock)
|
14
14
|
# indicating when the connection manager last made a request. This is used
|
15
|
-
# by `
|
15
|
+
# by `APIRequestor` to determine whether a connection manager should be
|
16
16
|
# garbage collected or not.
|
17
17
|
attr_reader :last_used
|
18
18
|
attr_reader :config
|
@@ -157,9 +157,7 @@ module Stripe
|
|
157
157
|
|
158
158
|
connection.open_timeout = config.open_timeout
|
159
159
|
connection.read_timeout = config.read_timeout
|
160
|
-
if connection.respond_to?(:write_timeout=)
|
161
|
-
connection.write_timeout = config.write_timeout
|
162
|
-
end
|
160
|
+
connection.write_timeout = config.write_timeout if connection.respond_to?(:write_timeout=)
|
163
161
|
|
164
162
|
connection.use_ssl = uri.scheme == "https"
|
165
163
|
|
@@ -192,9 +190,9 @@ module Stripe
|
|
192
190
|
|
193
191
|
@verify_ssl_warned = true
|
194
192
|
warn("WARNING: Running without SSL cert verification. " \
|
195
|
-
|
196
|
-
|
197
|
-
|
193
|
+
"You should never do this in production. " \
|
194
|
+
"Execute `Stripe.verify_ssl_certs = true` to enable " \
|
195
|
+
"verification.")
|
198
196
|
end
|
199
197
|
end
|
200
198
|
end
|
data/lib/stripe/errors.rb
CHANGED
@@ -4,22 +4,14 @@ module Stripe
|
|
4
4
|
# StripeError is the base error from which all other more specific Stripe
|
5
5
|
# errors derive.
|
6
6
|
class StripeError < StandardError
|
7
|
-
attr_reader :message
|
7
|
+
attr_reader :message, :code, :error, :http_body, :http_headers, :http_status, :json_body, :request_id
|
8
8
|
|
9
9
|
# Response contains a StripeResponse object that has some basic information
|
10
10
|
# about the response that conveyed the error.
|
11
|
-
attr_accessor :response
|
12
|
-
|
13
|
-
attr_reader :code
|
14
|
-
attr_reader :error
|
15
|
-
attr_reader :http_body
|
16
|
-
attr_reader :http_headers
|
17
|
-
attr_reader :http_status
|
18
|
-
attr_reader :json_body # equivalent to #data
|
19
|
-
attr_reader :request_id
|
11
|
+
attr_accessor :response # equivalent to #data
|
20
12
|
|
21
13
|
# Initializes a StripeError.
|
22
|
-
def initialize(message = nil, http_status: nil, http_body: nil,
|
14
|
+
def initialize(message = nil, http_status: nil, http_body: nil, # rubocop:todo Lint/MissingSuper
|
23
15
|
json_body: nil, http_headers: nil, code: nil)
|
24
16
|
@message = message
|
25
17
|
@http_status = http_status
|
@@ -35,7 +27,8 @@ module Stripe
|
|
35
27
|
def construct_error_object
|
36
28
|
return nil if @json_body.nil? || !@json_body.key?(:error)
|
37
29
|
|
38
|
-
ErrorObject
|
30
|
+
# ErrorObject is shared between v1 and v2, so use original object_classes to find
|
31
|
+
ErrorObject.construct_from(@json_body[:error], {}, nil, :v1)
|
39
32
|
end
|
40
33
|
|
41
34
|
# Whether the error was the result of an idempotent replay, meaning that it
|
@@ -138,7 +131,7 @@ module Stripe
|
|
138
131
|
def construct_error_object
|
139
132
|
return nil if @json_body.nil?
|
140
133
|
|
141
|
-
OAuthErrorObject.construct_from(@json_body)
|
134
|
+
OAuthErrorObject.construct_from(@json_body, {}, nil, :v1)
|
142
135
|
end
|
143
136
|
end
|
144
137
|
|
@@ -174,4 +167,9 @@ module Stripe
|
|
174
167
|
class UnsupportedResponseTypeError < OAuthError
|
175
168
|
end
|
176
169
|
end
|
170
|
+
|
171
|
+
# class definitions: The beginning of the section generated from our OpenAPI spec
|
172
|
+
class TemporarySessionExpiredError < StripeError
|
173
|
+
end
|
174
|
+
# class definitions: The end of the section generated from our OpenAPI spec
|
177
175
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stripe
|
4
|
+
module EventTypes
|
5
|
+
def self.thin_event_names_to_classes
|
6
|
+
{
|
7
|
+
# The beginning of the section generated from our OpenAPI spec
|
8
|
+
V1BillingMeterErrorReportTriggeredEvent.lookup_type => V1BillingMeterErrorReportTriggeredEvent,
|
9
|
+
V1BillingMeterNoMeterFoundEvent.lookup_type => V1BillingMeterNoMeterFoundEvent,
|
10
|
+
# The end of the section generated from our OpenAPI spec
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
# This event occurs when there are invalid async usage events for a given meter.
|
6
|
+
class V1BillingMeterErrorReportTriggeredEvent < Stripe::V2::Event
|
7
|
+
def self.lookup_type
|
8
|
+
"v1.billing.meter.error_report_triggered"
|
9
|
+
end
|
10
|
+
# There is additional data present for this event, accessible with the `data` property.
|
11
|
+
# See the Stripe API docs for more information.
|
12
|
+
|
13
|
+
# Retrieves the related object from the API. Make an API request on every call.
|
14
|
+
def fetch_related_object
|
15
|
+
_request(
|
16
|
+
method: :get,
|
17
|
+
path: related_object.url,
|
18
|
+
base_address: :api,
|
19
|
+
opts: { stripe_account: context }
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# File generated from our OpenAPI spec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module Stripe
|
5
|
+
# This event occurs when async usage events have missing or invalid meter ids.
|
6
|
+
class V1BillingMeterNoMeterFoundEvent < Stripe::V2::Event
|
7
|
+
def self.lookup_type
|
8
|
+
"v1.billing.meter.no_meter_found"
|
9
|
+
end
|
10
|
+
# There is additional data present for this event, accessible with the `data` property.
|
11
|
+
# See the Stripe API docs for more information.
|
12
|
+
end
|
13
|
+
end
|
@@ -4,8 +4,7 @@ module Stripe
|
|
4
4
|
class Instrumentation
|
5
5
|
# Event emitted on `request_begin` callback.
|
6
6
|
class RequestBeginEvent
|
7
|
-
attr_reader :method
|
8
|
-
attr_reader :path
|
7
|
+
attr_reader :method, :path
|
9
8
|
|
10
9
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
11
10
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -27,12 +26,8 @@ module Stripe
|
|
27
26
|
|
28
27
|
# Event emitted on `request_end` callback.
|
29
28
|
class RequestEndEvent
|
30
|
-
attr_reader :duration
|
31
|
-
|
32
|
-
attr_reader :method
|
33
|
-
attr_reader :num_retries
|
34
|
-
attr_reader :path
|
35
|
-
attr_reader :request_id
|
29
|
+
attr_reader :duration, :http_status, :method, :num_retries, :path, :request_id, :response_header, :response_body,
|
30
|
+
:request_header, :request_body
|
36
31
|
|
37
32
|
# Arbitrary user-provided data in the form of a Ruby hash that's passed
|
38
33
|
# from subscribers on `request_begin` to subscribers on `request_end`.
|
@@ -40,19 +35,46 @@ module Stripe
|
|
40
35
|
# in `request_end`.
|
41
36
|
attr_reader :user_data
|
42
37
|
|
43
|
-
def initialize(
|
44
|
-
|
45
|
-
@duration = duration
|
46
|
-
@http_status = http_status
|
47
|
-
@method = method
|
38
|
+
def initialize(request_context:, response_context:,
|
39
|
+
num_retries:, user_data: nil)
|
40
|
+
@duration = request_context.duration
|
41
|
+
@http_status = response_context.http_status
|
42
|
+
@method = request_context.method
|
48
43
|
@num_retries = num_retries
|
49
|
-
@path = path
|
50
|
-
@request_id = request_id
|
44
|
+
@path = request_context.path
|
45
|
+
@request_id = request_context.request_id
|
51
46
|
@user_data = user_data
|
47
|
+
@response_header = response_context.header
|
48
|
+
@response_body = response_context.body
|
49
|
+
@request_header = request_context.header
|
50
|
+
@request_body = request_context.body
|
52
51
|
freeze
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
55
|
+
class RequestContext
|
56
|
+
attr_reader :duration, :method, :path, :request_id, :body, :header
|
57
|
+
|
58
|
+
def initialize(duration:, context:, header:)
|
59
|
+
@duration = duration
|
60
|
+
@method = context.method
|
61
|
+
@path = context.path
|
62
|
+
@request_id = context.request_id
|
63
|
+
@body = context.body
|
64
|
+
@header = header
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class ResponseContext
|
69
|
+
attr_reader :http_status, :body, :header
|
70
|
+
|
71
|
+
def initialize(http_status:, response:)
|
72
|
+
@http_status = http_status
|
73
|
+
@header = response ? response.to_hash : nil
|
74
|
+
@body = response ? response.body : nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
56
78
|
# This class was renamed for consistency. This alias is here for backwards
|
57
79
|
# compatibility.
|
58
80
|
RequestEvent = RequestEndEvent
|
data/lib/stripe/list_object.rb
CHANGED
@@ -8,6 +8,9 @@ module Stripe
|
|
8
8
|
include Stripe::APIOperations::Create
|
9
9
|
|
10
10
|
OBJECT_NAME = "list"
|
11
|
+
def self.object_name
|
12
|
+
"list"
|
13
|
+
end
|
11
14
|
|
12
15
|
# This accessor allows a `ListObject` to inherit various filters that were
|
13
16
|
# given to a predecessor. This allows for things like consistent limits,
|
@@ -18,7 +21,7 @@ module Stripe
|
|
18
21
|
# there isn't a next page in order to replicate the behavior of the API
|
19
22
|
# when it attempts to return a page beyond the last.
|
20
23
|
def self.empty_list(opts = {})
|
21
|
-
ListObject.construct_from({ data: [] }, opts)
|
24
|
+
ListObject.construct_from({ data: [] }, opts, nil, :v1)
|
22
25
|
end
|
23
26
|
|
24
27
|
def initialize(*args)
|
@@ -93,8 +96,7 @@ module Stripe
|
|
93
96
|
def retrieve(id, opts = {})
|
94
97
|
id, retrieve_params = Util.normalize_id(id)
|
95
98
|
url = "#{resource_url}/#{CGI.escape(id)}"
|
96
|
-
|
97
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
99
|
+
execute_resource_request(:get, url, :api, retrieve_params, opts)
|
98
100
|
end
|
99
101
|
|
100
102
|
# Fetches the next page in the resource list (if there is one).
|
@@ -106,22 +106,22 @@ module Stripe
|
|
106
106
|
end
|
107
107
|
|
108
108
|
private def write_field(name, data, filename:)
|
109
|
-
if
|
110
|
-
@body << "\r\n"
|
111
|
-
else
|
109
|
+
if @first_field
|
112
110
|
@first_field = false
|
111
|
+
else
|
112
|
+
@body << "\r\n"
|
113
113
|
end
|
114
114
|
|
115
115
|
@body << "--#{@boundary}\r\n"
|
116
116
|
|
117
117
|
if filename
|
118
|
-
@body << %(Content-Disposition: form-data) +
|
118
|
+
@body << (%(Content-Disposition: form-data) +
|
119
119
|
%(; name="#{escape(name.to_s)}") +
|
120
|
-
%(; filename="#{escape(filename)}"\r\n)
|
120
|
+
%(; filename="#{escape(filename)}"\r\n))
|
121
121
|
@body << %(Content-Type: application/octet-stream\r\n)
|
122
122
|
else
|
123
|
-
@body << %(Content-Disposition: form-data) +
|
124
|
-
%(; name="#{escape(name.to_s)}"\r\n)
|
123
|
+
@body << (%(Content-Disposition: form-data) +
|
124
|
+
%(; name="#{escape(name.to_s)}"\r\n))
|
125
125
|
end
|
126
126
|
|
127
127
|
@body << "\r\n"
|
data/lib/stripe/oauth.rb
CHANGED
@@ -5,12 +5,10 @@ module Stripe
|
|
5
5
|
module OAuthOperations
|
6
6
|
extend APIOperations::Request::ClassMethods
|
7
7
|
|
8
|
-
def self.execute_resource_request(method, url, params, opts)
|
8
|
+
def self.execute_resource_request(method, url, base_address, params, opts)
|
9
9
|
opts = Util.normalize_opts(opts)
|
10
|
-
opts[:client] ||= opts[:client] || StripeClient.active_client
|
11
|
-
opts[:api_base] ||= opts[:client].config.connect_base
|
12
10
|
|
13
|
-
super(method, url, params, opts)
|
11
|
+
super(method, url, base_address, params, opts)
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
@@ -18,26 +16,25 @@ module Stripe
|
|
18
16
|
client_id = params[:client_id] || Stripe.client_id
|
19
17
|
unless client_id
|
20
18
|
raise AuthenticationError, "No client_id provided. " \
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
'Set your client_id using "Stripe.client_id = <CLIENT-ID>". ' \
|
20
|
+
"You can find your client_ids in your Stripe dashboard at " \
|
21
|
+
"https://dashboard.stripe.com/account/applications/settings, " \
|
22
|
+
"after registering your account as a platform. See " \
|
23
|
+
"https://stripe.com/docs/connect/standalone-accounts for details, " \
|
24
|
+
"or email support@stripe.com if you have any questions."
|
27
25
|
end
|
28
26
|
client_id
|
29
27
|
end
|
30
28
|
|
31
29
|
def self.authorize_url(params = {}, opts = {})
|
32
|
-
|
33
|
-
base = opts[:connect_base] || client.config.connect_base
|
30
|
+
base = opts[:connect_base] || APIRequestor.active_requestor.config.connect_base
|
34
31
|
|
35
32
|
path = "/oauth/authorize"
|
36
33
|
path = "/express" + path if opts[:express]
|
37
34
|
|
38
35
|
params[:client_id] = get_client_id(params)
|
39
36
|
params[:response_type] ||= "code"
|
40
|
-
query = Util.encode_parameters(params)
|
37
|
+
query = Util.encode_parameters(params, :v1)
|
41
38
|
|
42
39
|
"#{base}#{path}?#{query}"
|
43
40
|
end
|
@@ -45,21 +42,17 @@ module Stripe
|
|
45
42
|
def self.token(params = {}, opts = {})
|
46
43
|
opts = Util.normalize_opts(opts)
|
47
44
|
opts[:api_key] = params[:client_secret] if params[:client_secret]
|
48
|
-
|
49
|
-
:post, "/oauth/token", params, opts
|
45
|
+
OAuthOperations.execute_resource_request(
|
46
|
+
:post, "/oauth/token", :connect, params, opts
|
50
47
|
)
|
51
|
-
# This is just going to return a generic StripeObject, but that's okay
|
52
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
53
48
|
end
|
54
49
|
|
55
50
|
def self.deauthorize(params = {}, opts = {})
|
56
51
|
opts = Util.normalize_opts(opts)
|
57
52
|
params[:client_id] = get_client_id(params)
|
58
|
-
|
59
|
-
:post, "/oauth/deauthorize", params, opts
|
53
|
+
OAuthOperations.execute_resource_request(
|
54
|
+
:post, "/oauth/deauthorize", :connect, params, opts
|
60
55
|
)
|
61
|
-
# This is just going to return a generic StripeObject, but that's okay
|
62
|
-
Util.convert_to_stripe_object(resp.data, opts)
|
63
56
|
end
|
64
57
|
end
|
65
58
|
end
|