9

The Stripe docs for "List all prices" mention a lookup_keys parameter. What kind of values does it expect?

I've tried passing a product ID, a plan/price ID, keywords... (test or dev.) But only end up with an empty array for the data property whenever I do.

Fabien Snauwaert
  • 4,995
  • 5
  • 52
  • 70
  • 2
    according to doc, ``A lookup key used to retrieve prices dynamically from a static string. This may be up to 200 characters.`` https://stripe.com/docs/api/prices/create#create_price-lookup_key – OMi Shah Dec 02 '21 at 09:43
  • 1
    When you create a price (https://stripe.com/docs/api/prices/create?lang=php), you need to manually assign a lookup key, so you can then use it to remember specific prices. – JMP Dec 02 '21 at 09:55
  • 15
    I don't find `lookup_keys` all that convenient because they cannot be set from the dashboard. (Which only allows for the setting of a "Price description" (AKA "nickname" in the API docs.) – Fabien Snauwaert Jan 17 '22 at 16:04
  • 4
    I agree, it would be more useful if we could see and modify the `lookup_key` in the Stripe dashboard. Instead I have been using the `metadata` which can be set in the dashboard, and now it's possible to search by it: `Stripe::Price.search({query: "metadata['my_string']:'my_value'"})` – viktorsmari Jul 18 '22 at 12:10
  • 3
    So how do we set the lookup_key then if not in the dashboard? They talk about "better manage" and then can't even figure out how to set the value after hours of searching. – Sum None Jul 18 '22 at 14:22
  • Nevermind, just wrote a method to do it. Seems you can use their CLI too? Anyway, not really convenient as you all were saying. – Sum None Jul 18 '22 at 15:43

1 Answers1

3

The solution is here: https://www.youtube.com/watch?v=-shbqtjrRM0

Basically, if wish set a lookup key, in stripe shell you can do it:

stripe prices update "PRICE_ID" --lookup-key "NEW_LOOK_UP_NAME".

The PRICE_ID can found in dashboard (tab products - API ID).

vctlzac
  • 837
  • 2
  • 16
  • 38
  • The stripe dashboard now allows you to set a lookup key for each price. However, the dashboard doesn't seem to display the lookup key value after you save it. That said, the lookup key that I set in the dashboard seems to be working in my code. – joelhaus Aug 24 '23 at 12:55