I am trying to use the Stripe API to retrieve the details of a payment. The below code is what I have copied from their docs.
require './vendor/autoload.php';
$stripe = new \Stripe\StripeClient('SECRET_KEY');
$stripe->paymentIntents->retrieve('pi_1234ABC', []);
I then simply print the output using print_r($stripe);
. When I run this is outputs the following object. Needless to say, this isn't what I was expecting and I can't find any other way of dealing with the output.
Stripe\StripeClient Object
(
[coreServiceFactory:Stripe\StripeClient:private] => Stripe\Service\CoreServiceFactory Object
(
[client:Stripe\Service\AbstractServiceFactory:private] => Stripe\StripeClient Object
*RECURSION*
[services:Stripe\Service\AbstractServiceFactory:private] => Array
(
[paymentIntents] => Stripe\Service\PaymentIntentService Object
(
[client:protected] => Stripe\StripeClient Object
*RECURSION*
)
)
)
[config:Stripe\BaseStripeClient:private] => Array
(
[api_key] => SECRET_KEY
[client_id] =>
[stripe_account] =>
[stripe_version] =>
[api_base] => https://api.stripe.com
[connect_base] => https://connect.stripe.com
[files_base] => https://files.stripe.com
)
[defaultOpts:Stripe\BaseStripeClient:private] => Stripe\Util\RequestOptions Object
(
[apiKey] =>
[headers] => Array
(
[Stripe-Account] =>
[Stripe-Version] =>
)
[apiBase] =>
)
)
You need to assign the result of the retrieve operation to a variable. Something like this:
$paymentIntent = $stripe->paymentIntents->retrieve('pi_1234ABC', []);
Then you can do things like this:
echo $paymentIntent->status;
echo PHP_EOL;
echo $paymentIntent;
That will echo the status of the Payment Intent, then a new line, then the entire Payment Intent.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.