When you're issuing a credit, you get the choice of which transactions to credit to.
Each time we ask the payment processor for money, it's a transaction. Each transaction can be to a different card or payment method or even payment processor. Each transaction can be at a different time, and for different amounts.
Each payment processor handles credits differently.
Some only allow one credit per transaction, even if you're crediting less than the full amount. In this case, it makes sense to credit to a transaction that matches the amount you're trying to credit.
They'll all have some time restriction on how long after a transaction originally occurred you can credit, though the time varies greatly. For this reason you may want to credit the oldest transaction you can that will still let you credit, so you have the option of crediting again in the future.
Sometimes it's a matter of which card the customer wants the money returned to. In that case you can choose the card they request.
If in doubt, leave it alone, and we'll try to credit from the oldest towards the newest.