Got it!
To check your published keys, you just need to request a strip for the new token using cURL . If this key is invalid, the response will contain an error message starting with "An invalid API key was provided . "
Here is an example written in PHP:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://api.stripe.com/v1/tokens"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "card[number]=4242424242424242&card[exp_month]=12&card[exp_year]=2017&card[cvc]=123"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERPWD, $publishableKey . ":"); $response = json_decode(curl_exec($ch),true); if( curl_errno($ch) ){ echo 'Error:' . curl_error($ch); } curl_close ($ch); if(substr($response["error"]["message"],0, 24 ) == "Invalid API Key provided"){ echo "Invalid API Key provided"; }
Same idea for checking private keys.
Etienne martin
source share