Trying to return only the last transaction.kind of an order

Windsinger
Tourist
19 0 1

Our store features a number of transactions (authorization, capture, terms ), and an order can have multiple transactions in its history. Example: card is authorized and later captured and maybe even refunded.

The below returns each transaction.kind but I only want the last transaction kind, so that I can display the correct verbiage based upon the current status of the order.  I tried transaction.kind.last, but this returned the last letter of each. Not sure why this is making my head spin. Any guidance is appreciated.

{% for transaction in order.transactions %}
{% if transaction.kind == "authorization" %}
authorization
{% elsif transaction.kind == "capture" %}
capture
{% elsif transaction.kind == "refund" %}
{% else %}
terms
{% endif %}
{% endfor %}
0 Likes