#rodney_api

1 messages ¡ Page 1 of 1 (latest)

high starBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1328608279265280073

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

dire vector
#

Hi! Looking into your query.

dire vector
#

Thank you for waiting! Can I check if you are using the right Java SDK version that is compatible with the webhook event Stripe API version?

#

Additionally, do you have a sample event ID I can look at?

raven blade
#

hey thanks!

We're using com.stripe:stripe-java:25.13.0

evt_1QgxECHu5QhcXEGNdBbo8E9j is an event with the previous_attributes object

#

we currently cast the incoming StripeObject to the associated object for the event, so for example:

fun handleCustomerSubscriptionUpdated(
    event: Event,
    stripeObject: StripeObject,
  ): CompletableFuture<Boolean> {

    val subscription = stripeObject as Subscription

for customer.subscription.updated

topaz dragon
#

Hi @raven blade I'm Jack, and I'm also an engineer at Stripe

#

Can you share with me the code that you wrote to deserialize the webhook event?

raven blade
#

I believe this is direct from the docs:

    // Deserialize the nested object inside the event
    val dataObjectDeserializer = event?.dataObjectDeserializer
    var stripeObject: StripeObject?
    // Deserialization failed, probably due to an API version mismatch.
    // Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
    // instructions on how to handle this case, or return an error here.
    if (dataObjectDeserializer?.getObject()?.isPresent == true)
      stripeObject = dataObjectDeserializer.getObject().get()
    else
      throw ResponseStatusException(
        HttpStatus.BAD_REQUEST,
        "⚠️  Webhook error while validating signature.\n",
      )
#

for the event we use this right above:

    val event: Event? =
      try {
        Webhook.constructEvent(payload, sigHeader, endpointSecret)
      } catch (e: SignatureVerificationException) {
        // Invalid signature
        logger.info("⚠️  Webhook error while validating signature.")
        throw ResponseStatusException(
          HttpStatus.BAD_REQUEST,
          "⚠️  Webhook error while validating signature.\n",
        )
      }
topaz dragon
#

OK, when you call previousAttributes() on the deserialized event object , the function returns an empty map?

raven blade
#

there isn't a built-in previousAttributes field on the Subscription object, so to access i'd have to get the raw json and go from there. Which would be fine, but I can't find much/any info on that object

#

I assume it's used internally to drive the dashboard event descriptions since they tend to be a lot more descriptive about what has changed on the subscription and I'm interested in doing something along those lines. Right now we only know what has changed if we happen to store the changed field in our db somewhere which isn't ideal and ends up being a bit of a guessing game when implementing new subscription types/features in our code

topaz dragon
#

The function is avaible on the event class, not subscription class.

raven blade
#

ooh found it

#

looks to be just a Map<String, Object>, is there any guidance on interpreting it or is any field on the associated object (Subscription for example) pretty much fair game