【问题标题】:Stripe Retrieve PaymentIntents API. How to work with the output?Stripe 检索 PaymentIntents API。如何处理输出?
【发布时间】:2021-10-02 16:13:09
【问题描述】:

我正在尝试使用 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] => 
        )

)

【问题讨论】:

    标签: php api stripe-payments


    【解决方案1】:

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

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

    然后你可以这样做:

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

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

    【讨论】:

      猜你喜欢
      • 2019-08-22
      • 2018-10-07
      • 2021-08-24
      • 2021-12-27
      • 2021-11-08
      • 2017-12-30
      • 2015-07-26
      • 2015-07-01
      • 2022-06-13
      相关资源
      最近更新 更多