Hi @imfromio painful one to discover after a test run with “real” looking data, I know.
The key thing here is how those records were created. Payments that come from Commerce Hub processing (HubSpot payments or native Stripe) really cannot be deleted or modified over the API, only refunded/voided and managed in the UI (https://developers.hubspot.com/docs/api-reference/crm-commerce-payments-v3/guide )
But payments you create yourself through the Payments API are stored as commerce_payments objects and can be archived programmatically with DELETE /crm/v3/objects/commerce_payments/{commercePaymentId}, which moves them to the recycle bin for 90 days before permanent deletion (https://developers.hubspot.com/docs/api-reference/crm-commerce-payments-v3/basic/delete-crm-v3-objec...
If your duplicates were created via the API with a third-party processor, you should not need to manually break every line item link first. HubSpot will drop those associations once the payment object itself is archived. If you really want to clean associations explicitly, you can still use the Associations v4 API to remove links between commerce_payments and line_items before deleting, but that is more of a belt-and-suspenders step than a requirement (https://developers.hubspot.com/docs/api-reference/crm-associations-v4/guide )
I would take one duplicate payment, delete it with the commerce payments endpoint, then verify in the UI that the deal and line items look correct before doing it in bulk. If part of the pain here is that duplicate payments originate upstream, Stacksync helps by syncing only normalized, de-duplicated payment records into HubSpot so you do not have to clean up bad objects after the fact.
