Get the Card ID of the Card on File from invoice payment

When an invoice is paid, is it possible to get the card ID used for that invoice payment? Specifically, when a recurring invoice is being paid, and a new card on file has been stored to the customer.

The docs mention this in some capacity in invoices.payment_requests.card_id:

card_id string

The ID of the credit or debit card on file to charge for the payment request. To get the cards on file for a customer, call ListCards and include the customer_id of the invoice recipient.

Must I cycle through all cards on file thru Cards API? If so, how will I know which card is linked to this invoice?

The docs make it seem that the card ID is a parameter within payment_requests, however the payload does not include the card_id in practice.

It is important in our use case that we keep track of which card on file is being used for recurring invoices/subscription payments, so any help on this would be appreciated.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Create a Card on File from a Payment ID
Charge a Card on File
Integrate Customer Profiles with Other Services

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

With payments and recurring invoices the card_id is never exposed for security reasons. You can call ListCards and set the customer_id as a query parameter to get all the cards from a customer profile. With the card response you can match the fingerprint of the payment to the fingerprint of the card to know what card was used for the payment. :slightly_smiling_face: