条纹检索 PaymentIntents API。如何处理输出?
Stripe Retrieve PaymentIntents API. How to work with the output?
我正在尝试使用 Stripe API 来检索付款的详细信息。下面的代码是我从他们的文档中复制的。
require './vendor/autoload.php';
$stripe = new \Stripe\StripeClient('SECRET_KEY');
$stripe->paymentIntents->retrieve('pi_1234ABC', []);
然后我使用 print_r($stripe);
简单地打印输出。
当我 运行 这是输出以下对象。不用说,这不是我所期待的,我找不到任何其他方式来处理输出。
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] =>
)
)
您需要将检索操作的结果分配给一个变量。像这样:
$paymentIntent = $stripe->paymentIntents->retrieve('pi_1234ABC', []);
那么你可以这样做:
echo $paymentIntent->status;
echo PHP_EOL;
echo $paymentIntent;
这将回显付款意向的状态,然后换行,然后是整个付款意向。
我正在尝试使用 Stripe API 来检索付款的详细信息。下面的代码是我从他们的文档中复制的。
require './vendor/autoload.php';
$stripe = new \Stripe\StripeClient('SECRET_KEY');
$stripe->paymentIntents->retrieve('pi_1234ABC', []);
然后我使用 print_r($stripe);
简单地打印输出。
当我 运行 这是输出以下对象。不用说,这不是我所期待的,我找不到任何其他方式来处理输出。
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] =>
)
)
您需要将检索操作的结果分配给一个变量。像这样:
$paymentIntent = $stripe->paymentIntents->retrieve('pi_1234ABC', []);
那么你可以这样做:
echo $paymentIntent->status;
echo PHP_EOL;
echo $paymentIntent;
这将回显付款意向的状态,然后换行,然后是整个付款意向。