A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/stripe/stripe-python/wiki/Migration-guide-for-v8-(StripeClient) below:

Migration guide for v8 (StripeClient) · stripe/stripe-python Wiki · GitHub

" ⚠️ " symbol highlights breaking changes.

Introduces StripeClient and the service-based call pattern. This new interface allows you to easily call Stripe APIs and has several benefits over the existing resource-based pattern:

While there are no plans yet to completely remove the previous resource-based call pattern, it will be deprecated soon and new API endpoints will be supported only in the new pattern. We strongly recommend migrating to the new service-based pattern as you begin to use new APIs. This will help you avoid mixing the two patterns in your integration, which can lead to confusion as you maintain your code.

To migrate from a resource-based to service-based pattern:

  1. Initialize a StripeClient instance.

    Before

    stripe.api_key = "sk_test_123"

    After

    client = stripe.StripeClient("sk_test_123")

    You can also pass in previously configurable global options as keyword arguments into the StripeClient constructor:

    Before

    stripe.api_key = "sk_test_123"
    stripe.api_version = "2022-11-15"
    stripe.max_network_retries = 3
    stripe.proxy = "https://user:pass@example.com:1234"

    After

    client = stripe.StripeClient(
      "sk_test_123",
      stripe_version="2022-11-15",
      max_network_retries=3,
      proxy="https://user:pass@example.com:1234",
    )
  2. Convert resource method calls to StripeClient calls. On resource-based calls, request parameters and request options were each individually passed in as a mix of positional and keyword arguments. But for service-base calls, request parameters and request options are passed in as separate dictionary arguments.

    Before

    customer = stripe.Customer.create(email="jenny.rosen@example.com", stripe_account="acct_123")

    After

    customer = client.customers.create(params={"email": "jenny.rosen@example.com"}, options={"stripe_account": "acct_123"})
  3. When using one of our Update APIs, the StripeClient version is called update() instead of modify()

    Before

    customer = stripe.Customer.modify(
      "cus_123",
      description="new description",
    )

    After

    customer = client.customers.update(
      "cus_123",
      params={
        "description": "new description",
      }
    )
  4. Convert nested resource operations to StripeClient calls. As with class and instance calls, request parameters and request options become separate dictionary arguments in the service-based pattern.

    Before

    stripe.Customer.list_balance_transactions(
      "cus_123",
      limit=3,
      stripe_version="2022-11-15",
    )

    After

    customer = client.customers.balance_transactions.list(
      "cus_123",
      params={"limit": 3},
      options={"stripe_version": "2022-11-15"},
    );
  5. To construct a webhook event, use the StripeClient.construct_event() method:

    Before

    event = stripe.Webhook.construct_event(
      payload, sig_header, secret
    )

    After

    event = client.construct_event(
      payload, sig_header, secret
    )

" ⚠️ " symbol highlights breaking changes

BEFORE

stripe.Customer.create(
  "sk_test_123",  # api key
  "KG5LxwFBepaKHyUD",  # idempotency key
  "2022-11-15",  # stripe version
  "acct_123",  # stripe account
)

AFTER

stripe.Customer.create(
  api_key="sk_test_123",
  idempotency_key="KG5LxwFBepaKHyUD",
  stripe_version="2022-11-15",
  stripe_account="acct_123",
)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4