将付款意图存储在 Stripe php 上后,如何检索付款意图的净值

Arn*_*ath 2 php stripe-payments

当在 Stripe 上存储 PaymentIntent 费用时,假设40.00Stripe 费用为 1.46 美元,余额为 38.54,有没有办法我可以检索这个 38.54 余额,我尝试选择 PaymentIntent,就像它在 Stripe 文档中显示的那样,但我只能检索费用价格,即 40.00 美元,而不是余额

这是它的样子

Stripe 上的 PaymentIntent 费用是什么样的

这是我的检索代码

$order_total = sprintf('%.2f', $stripe->paymentIntents->retrieve( ''.$paymentIntent->id.'', [] )['amount'] / 100);

wsw*_*wsw 5

没有直接的方法可以net从 API 调用中获取金额,但是,您可以轻松获取原始金额charge amount和fee amountpayment_intent 中的金额。

  • 使用 Stripe PaymentIntent检索 API
  • 展开以payment_intent.charges.data.balance_transaction获取余额交易,您可以在其中找到费用参数

例如

  curl https://api.stripe.com/v1/payment_intents/pi_1GmxGNxxxxxWi \
  -u sk_test_uxxxxxxL: \
  -d "expand[]"="charges.data.balance_transaction"
Run Code Online (Sandbox Code Playgroud)

您只需从费用参数中减去 payment_intent 金额即可获得净额。