What is the simplest way to discount a line item in the cart?

Hi. I need to discount items in the cart. I believe I can do it with the Storefront API and a custom app, but could I do it an easier way?

This is what I am thinking right now:

Have the customer input an invoice that I can check to see if they purchased a product on another site.

If they have, I can apply a discount to their purchase.

If they check out, I need to save the invoice number so it can’t be reused.

I would do the saving of the invoice number in a JSON metafield, but I can wait on that. I just need to get the whole thing up and running soon.

Is this the simplest way to do this?