command-linestripe-paymentscommand-line-arguments

Stripe CLI: How to trigger events with nested metadata


I'm using Stripe CLI to trigger local webhook events. The command lets me set metadata using the following option / syntax:

--add resource:path1.path2=value

The metadata structure I'm trying to create looks like this:

{
    id: 1,
    artistId: 2,
    image: { 
        url: `https://somepath` 
    }
}

Here is my command:

$ stripe trigger payment_intent.succeeded --add payment_intent:metadata.id=1 --add payment_intent:metadata.artistId=1 --add payment_intent:metadata.image.url=https://www.arweave.net/ij5O6dDlzxOuWHUnikZapq10kkeEVe_elLWvpfE6ado?ext=PNG
⣟ Checking for new versions... Setting up fixture for: payment_intent
Running fixture for: payment_intent
Trigger failed: Request failed, status=400, body={
  "error": {
    "message": "Invalid value type: {:url=\u003E\"https://www.arweave.net/ij5O6dDlzxOuWHUnikZapq10kkeEVe_elLWvpfE6ado?ext=PNG\"} must be a string",
    "param": "metadata",
    "type": "invalid_request_error"
  }
}

At first, I thought that the . in the URL was breaking the syntax. But I get the same error when I substitute the URL with foo.

I think I must me doing something wrong with the path syntax. Or maybe there's a max limit to the depth of the data structure?

Update:

To sidestep this problem, I tried achieving the same thing using a fixtures json file but it didn't work. I got the same error, even though the syntax is JSON and unambiguous. I contacted Stripe support and they also seemed confused by this behavior. I'm awaiting a response from their escalation team.


Solution

  • Stripe support confirmed that the metadata object can only have key / value pairs in which the values are strings. I was trying to use objects as values to create more complex data structures and this is not supported. :-(