【问题标题】:Stripe: Retrieving a paymentIntent in Laravel?Stripe:在 Laravel 中检索 paymentIntent?
【发布时间】:2020-12-04 01:52:16
【问题描述】:

我正在尝试获取 paymentIntent 以查看收费金额。我的代码是:

public getIntent($paymentIntentId) 
{
  $stripe = Stripe::setApiKey('____');
  $intent = $stripe->paymentIntents->retrieve($paymentIntentId, []);
  return $intent;
}

我不断收到错误记录为trying to retrieve property of non-object。我不确定我做错了什么。我验证了 apiKey 是正确的,$paymentIntentId 是有效的。当我通过 cURL 检索它时,它工作正常,所以我认为这是我的 Laravel 代码的问题。

【问题讨论】:

    标签: php laravel stripe-payments


    【解决方案1】:

    这是怎么做的:

    来自文档:https://stripe.com/docs/api/payment_intents/retrieve

    $stripe = new \Stripe\StripeClient(
      '[your key]'
    );
    $stripe->paymentIntents->retrieve(
      '[payment intent id]',
      []
    );
    

    或者如果你想使用Stripe::setApiKey(),它不会返回任何东西。这就是您收到此错误的原因。要以这种方式获得意图,您必须这样做:

    Stripe::setApiKey('___');
    $intent = Stripe\PaymentIntent::retrieve($paymentIntentId)
    

    【讨论】:

      猜你喜欢
      • 2021-02-04
      • 1970-01-01
      • 2019-11-20
      • 1970-01-01
      • 2019-09-26
      • 1970-01-01
      • 2021-03-23
      • 2020-08-07
      • 2020-04-17
      相关资源
      最近更新 更多