[英]Stripe Retrieve PaymentIntents API. How to work with the output?
I am trying to use the Stripe API to retrieve the details of a payment.我正在尝试使用 Stripe API 来检索付款的详细信息。 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);
然后我简单地使用
print_r($stripe);
打印输出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.这将回应支付意图的状态,然后是一个新行,然后是整个支付意图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.