I'm working with the Stripe API, specifically in Python but this question is generally about API endpoints so could be applied to any language. I am creating a programmatic transfer to a connected account as explained here, and in a demo below:
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'
)
Then, as is shown in the API, I am able to retrieve from this transfer the destination_payment
object, which is what actually shows up in the Payments feed for a connected account:
dest_pmt = resp['destination_payment']
So this is the object our partners would see. But then, I want to be able to modify that destination payment object--specifically, to be able to edit the description and metadata of it. (Currently, the description just shows up as the value of dest_pmt
, and there is no metadata.) But the ID for the destination payment comes in the form py_xxxxx
and I don't know what endpoint to use to retrieve an object in that form. When I reached out to Stripe support, they suggested that I could retrieve/modify (and I use retrieve for this example just for simplicity) it using the payment intent endpoint, as such:
resp_2 = stripe.PaymentIntent.retrieve(
dest_pmt,
stripe_account=acct_id
)
But I got the following error:
InvalidRequestError: Request req_xxxxxx: No such payment_intent: 'py_xxxxxxxxx'
Also, I am using Standard Connected Accounts for reference, but I don't think it would make a huge difference. Any help to resolve this would be greatly appreciated!
You've got the right idea with the retrieval using the Stripe-Account
header, but the py_123
objects from transfers and destination charges are actually Charge type objects. You can retrieve them using the Charge /retrieve
API (ref):
charge = stripe.Charge.retrieve(
dest_pmt, # 'py_123'
stripe_account=acct_id
)