This lets you query the Stripe Payment Intents API using just PHP, without using the Stripe PHP library.
Parameters
$query
– The query string with your desired parameters. This is everything that comes afterhttps://api.stripe.com/v1/payment_intents
. See the available parameters for this in the Stripe API Reference.
Return Values
This returns an array or object if successful, or a string if there is a curl error.
Mandatory Step
You must replace YOUR_SECRET_KEY_FROM_STRIPE
on line 12 with your own secret API key from Stripe.
/** * Call Stripe Payment Intents API * * @return array|object|string An array or object if successful, or a string if there is an error. */ function query_stripe_paymentintents($query) { $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => "https://api.stripe.com/v1/payment_intents$query", CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_USERPWD => 'YOUR_SECRET_KEY_FROM_STRIPE' )); $response = curl_exec($ch); $err = curl_error($ch); unset($ch); return (! $err) ? json_decode($response) : $err; }
Questions and Comments are Welcome