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

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

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

  1. require './vendor/autoload.php';
  2. $stripe = new \Stripe\StripeClient('SECRET_KEY');
  3. $stripe->paymentIntents->retrieve('pi_1234ABC', []);

然后,我只需使用 print_r($stripe); . 当我运行它时,输出以下对象。不用说,这不是我所期望的,我找不到任何其他方法来处理输出。

  1. Stripe\StripeClient Object
  2. (
  3. [coreServiceFactory:Stripe\StripeClient:private] => Stripe\Service\CoreServiceFactory Object
  4. (
  5. [client:Stripe\Service\AbstractServiceFactory:private] => Stripe\StripeClient Object
  6. *RECURSION*
  7. [services:Stripe\Service\AbstractServiceFactory:private] => Array
  8. (
  9. [paymentIntents] => Stripe\Service\PaymentIntentService Object
  10. (
  11. [client:protected] => Stripe\StripeClient Object
  12. *RECURSION*
  13. )
  14. )
  15. )
  16. [config:Stripe\BaseStripeClient:private] => Array
  17. (
  18. [api_key] => SECRET_KEY
  19. [client_id] =>
  20. [stripe_account] =>
  21. [stripe_version] =>
  22. [api_base] => https://api.stripe.com
  23. [connect_base] => https://connect.stripe.com
  24. [files_base] => https://files.stripe.com
  25. )
  26. [defaultOpts:Stripe\BaseStripeClient:private] => Stripe\Util\RequestOptions Object
  27. (
  28. [apiKey] =>
  29. [headers] => Array
  30. (
  31. [Stripe-Account] =>
  32. [Stripe-Version] =>
  33. )
  34. [apiBase] =>
  35. )
  36. )
wribegjk

wribegjk1#

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

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

然后你可以这样做:

  1. echo $paymentIntent->status;
  2. echo PHP_EOL;
  3. echo $paymentIntent;

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

相关问题