Query The Payment Intents From Stripe API with PHP

This lets you query the Stripe Payment Intents API using just PHP, without using the Stripe PHP library.

Parameters

  1. $query – The query string with your desired parameters. This is everything that comes after https://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.

PHP

/** 
 * 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;
}

See more:

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]