Stripe API 和 PHP:支付与支付意图/费用的关系

Stripe API and PHP: Relationship of PAYOUTS to Payment Intent / Charges

我是 STRIPE 的新手,我一直在阅读 STRIPE 的文档,我的任务是为连接的帐户(类型为标准)创建支出列表。另外,我必须在那些PAYOUT下显示详细信息,其中包含所有付款。

但是我看不出 PAYOUTS 与 PAYMENT INTENTS/CHARGES 有任何关系,是否可以知道 PAYOUTS 中包含的所有这些付款?我们正在为我们的用户创建标准连接帐户。

我不确定您是否拥有标准帐户的访问权限,但如果您这样做,您将能够list all of the Balance Transactions associated with that Payout, which will have a reference to the Payment Intent in the source field任何付款意向。

我遇到了同样的挑战,不得不通过 4 个支持者,一遍又一遍地告诉我的需求,然后我终于得到正确的提示并可以完成我的检查和 cron 工作。我在这里提供我的解决方案以节省其他人相同的体验:

$po = 'po_sadfahk.....'; // payout id (i do a loop of payouts)

\Stripe\Stripe::setApiKey($stripeSecretKey);
$balanceTransactions = \Stripe\BalanceTransaction::all([
  'payout' => "$po",
  'type' => 'charge',
  'limit' => 100, // default is 10, but a payout can have more pi's
  'expand' => ['data.source'],
]);

foreach ($balanceTransactions->data as $txn) {
  // my invoice id is added in description when creating the payment intent
  echo "Invoice: {$txn->description}\n"; 
  echo "Created: {$txn->created}\n";
  echo "Available: {$txn->available_on}\n";
  // in source we find the pi_id, amount and currency for each payment intent
  $charge = $txn->source; 
  echo "pi: {$charge->payment_intent}\n";
  $amount = $charge->amount/100;
  echo "$amount {$charge->currency}\n";
}

输出(裁剪为相关数据):

{
  "object": "list",
  "data": [
    {
      "id": "txn_1ISOaSGqFEoKRtad...",
      "object": "balance_transaction",
      "amount": 25000,
      "available_on": 1615680000,
      "created": 1615131127,
      "currency": "dkk",
      "description": "Invoice 44",
      ...
      "fee": 530,
      "fee_details": [
        {
          "amount": 530,
          "application": null,
          "currency": "dkk",
          "description": "Stripe processing fees",
          "type": "stripe_fee"
        }
      ],
      ...
      "source": {
        "id": "ch_1ISOaRGqFEoKR...",
        "object": "charge",
        "amount": 25000,
        ...
        "paid": true,
        "payment_intent": "pi_1ISOa3GqFE...", // here we go!
        "payment_method": "pm_1ISOaRGqFE...",
        "payment_method_details": {
          "card": {
            "brand": "visa",
            ...
          },
          "type": "card"
        },
        ... 
      },
      "status": "available",
      "type": "charge"
    }
  ],
  "has_more": false,
  "url": "/v1/balance_transactions"
}