PHP Requires Chilkat v11.7.0+
PHP
Stripe: Find a catalog price by its lookup key
See more Stripe Examples
Retrieve an active price by its catalog lookup key and read its price ID, currency, amount, and billing type.
Stripe documentation and cURL example
Chilkat PHP Downloads
<?php
use Chilkat2\HttpCurl;
use Chilkat2\JsonObject;
use Chilkat2\StringBuilder;
$success = false;
// Requires an unlocked Chilkat bundle. See Global Unlock Sample.
// Supply a restricted sandbox key from merchant-controlled configuration.
$apiKey = 'YOUR_STRIPE_TEST_KEY';
$curl = new HttpCurl();
$cmd = new StringBuilder();
$json = new JsonObject();
$lookupKey = new StringBuilder();
$lookupKey->SetString('support_monthly_usd');
// curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D={lookupKey}&limit=2" \
// -u "$STRIPE_API_KEY:" \
// -H "Stripe-Version: 2026-10-28.endive"
$cmd->SetString('curl -X GET "https://api.stripe.com/v1/prices?active=true&lookup_keys%5B%5D=@LOOKUP@&limit=2"');
$cmd->Append(' -u "@KEY@:"');
$cmd->Append(' -H "Stripe-Version: 2026-10-28.endive"');
$replaced = $cmd->Replace('@LOOKUP@', $lookupKey->GetEncoded('url_rfc3986', 'utf-8'));
$replaced = $cmd->Replace('@KEY@', $apiKey);
try {
$curl->DoYourThing($cmd->GetAsString());
} catch (\Chilkat2\Exception $e) {
echo 'No HTTP response. Chilkat failure code: ', $curl->FailReason, "\n";
exit;
}
try {
$curl->GetResponseJson($json);
$success = true;
} catch (\Chilkat2\Exception $e) {
$success = false;
}
if (($curl->StatusCode != 200) || (!$success)) {
echo 'Stripe HTTP ', $curl->StatusCode, ' Request-Id: ', $curl->GetResponseHeaderField('Request-Id'), "\n";
if ($success) {
echo $json->StringOf('error.message'), "\n";
}
exit;
}
if (($json->SizeOfArray('data') != 1) || ($json->BoolOf('has_more'))) {
echo "Expected one active price for this lookup key.\n";
exit;
}
echo 'id = ', $json->StringOf('data[0].id'), "\n";
echo 'lookup_key = ', $json->StringOf('data[0].lookup_key'), "\n";
echo 'currency = ', $json->StringOf('data[0].currency'), "\n";
echo 'unit_amount_decimal = ', $json->StringOf('data[0].unit_amount_decimal'), "\n";
echo 'type = ', $json->StringOf('data[0].type'), "\n";