从 Stripe 中的传输中获取 destination_payment API

Get destination_payment from transfer in Stripe API

我正在使用 Stripe API,特别是在 Python 中,但这个问题通常是关于 API 端点的,因此可以应用于任何语言。我正在按照 here 的说明创建到关联帐户的程序化转账,并在下面的演示中:

import stripe
stripe.api_key = 'rk_test_xxxxxxx'
acct_id = 'acct_xxxxx'
resp = stripe.Transfer.create(
    amount=100,
    currency='usd',
    destination=acct_id,
    description='Test Transfer 1'
)

然后,如 API 中所示,我能够从该转账中检索 destination_payment 对象,该对象实际显示在关联帐户的付款提要中:

dest_pmt = resp['destination_payment']

这就是我们的合作伙伴会看到的对象。但是,我希望能够修改该目标支付对象——具体来说,能够编辑它的描述和元数据。 (目前,描述仅显示为 dest_pmt 的值,并且没有元数据。)但是目标付款的 ID 以 py_xxxxx 的形式出现,我不知道要连接到哪个端点用于以该形式检索对象。当我联系 Stripe 支持人员时,他们建议我可以 retrieve/modify(为了简单起见,我在此示例中使用检索)它使用支付意图端点,例如:

resp_2 = stripe.PaymentIntent.retrieve(
    dest_pmt,
    stripe_account=acct_id
)

但是我得到了以下错误:

InvalidRequestError: Request req_xxxxxx: No such payment_intent: 'py_xxxxxxxxx'

此外,我正在使用标准连接帐户作为参考,但我认为这不会产生很大的不同。任何解决此问题的帮助将不胜感激!

您使用 Stripe-Account header 进行检索的想法是正确的,但是 py_123 objects 中转和目的地费用实际上是费用类型 objects。您可以使用 Charge /retrieve API (ref):

检索它们
charge = stripe.Charge.retrieve(
  dest_pmt, # 'py_123'
  stripe_account=acct_id
)