Skip to content

Provide a public helper to sign webhook data #1697

Closed

Description

@Viicos

Is your feature request related to a problem? Please describe.

The Node SDK provides a generateTestHeaderString() utility to manually sign payloads for testing. It would be great to have a similar utility in the Python SDK.

We currently copy over this internal test fixture, but the signing logic is an internal detail that can change at any point in time.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. mbroshi-stripe commented on Dec 16, 2025

    @mbroshi-stripe
    Contributor

    Hi @Viicos! Thanks for creating this issue! I agree that we should have a test payload-signing utility in Python similar to what we have in Node. For now, your workaround is sound since that logic is unlikely to change for the foreseeable future, but there should be an affordance to abstract away that logic.

    We have added this to our backlog, but we will need to evaluate it against other planned work. In the meantime, you can keep your current workaround, or feel free to create a PR to address this issue.

  2. kartheek0107 commented on Dec 27, 2025

    @kartheek0107

    Hi! I’m interested in working on this issue and would like to explore a PR. I’ll start by reviewing the existing internal signing logic and the Node SDK helper.

    Please let me know if that sounds good.

  3. Zhang-Charlie commented on Apr 17, 2026

    @Zhang-Charlie

    Hi @kartheek0107, are you still planning to work on this? If not, I’d be happy to take it on with a scoped PR for a public webhook test-signing helper and tests. If I don’t hear back in about a week, I’ll plan to start on it.

  4. kartheek0107 commented on Apr 19, 2026

    @kartheek0107

    Hi @Zhang-Charlie, thanks for checking in! I actually have the logic mapped out from the Node SDK and was planning to push a PR this week. I'll have a draft up by [Wednesday/Thursday]. If I don't hit that, feel free to take over!

  5. vishwakt commented on May 14, 2026

    @vishwakt

    Hi @mbroshi-stripe, I've opened #1810 to address this. Below are some notes on the implementation and i'm happy to update the implementation based on your feedback.

    What it adds

    A public WebhookSignature.generate_test_header_string() helper, mirroring stripe-node's generateTestHeaderString().

    import stripe
    
    header = stripe.WebhookSignature.generate_test_header_string(
        payload=payload_json,
        secret="whsec_test_secret",
    )
    event = stripe.Webhook.construct_event(payload_json, header, "whsec_test_secret")

    Design choices

    • Placed on WebhookSignature rather than Webhook, since that's where EXPECTED_SCHEME, _compute_signature, and verify_header already live. Happy to move it to Webhook if you'd prefer a 1:1 surface with stripe-node.
    • Keyword arguments instead of an options dict which is idiomatic in Python, while preserving the full Node parameter surface: payload, secret, timestamp, scheme, signature.
    • Defaults match Node:
    • classmethod so EXPECTED_SCHEME is the default for scheme, consistent with how verify_header is structured.
    • No async variant. stripe-node has one only because of its CryptoProvider abstraction while the Python SDK's signing path is synchronous.

    @kartheek0107 @Zhang-Charlie apologies for the overlap. I saw this one being open for a while, so took a stab at it. I'm happy to defer or coordinate if either of you already has something in flight.

  6. xavdid commented on Aug 10, 2026

    @xavdid
    Member

    This was added in v15.5.0 as stripe.WebhookSignature.generate_signature_header(...)

    Thank you for filing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions