stripe检索paymentintents api如何处理输出?

r55awzrz  于 2021-10-10  发布在  Java
关注(0)|答案(1)|浏览(434)

我正在尝试使用StripeAPI检索付款的详细信息。下面的代码是我从他们的文档中复制的。

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] => 
        )

)
wribegjk

wribegjk1#

您需要将检索操作的结果分配给一个变量。大概是这样的:

$paymentIntent = $stripe->paymentIntents->retrieve('pi_1234ABC', []);

然后你可以这样做:

echo $paymentIntent->status;
echo PHP_EOL;
echo $paymentIntent;

这将回显支付意图的状态,然后是新行,然后是整个支付意图。

相关问题