How do I export the "Payment ID" under "Information from the gateway" from the Shopify order data?

In the Shopify Admin > Order Detail > Timeline section, you might see a note under "Information from the gateway" that includes some code which is the Payment ID as shown in the example below:

The "Payment ID" is stored in the Order Transaction API data under the "receipt" subfield.  Please note that depending on the payment gateway used, this data may not be available.

In the above example, the Klarna payment gateway provides this information to the Shopify API so we're able to extract it from the order transaction data:

To export the "Payment ID" with EZ Exporter, you can use the formula below in the Calculated Fields:

" + ".join(sorted(set(to_list(get_attribute_value([i for i in load_json_data({{ transactions }}) if i.status in ["success", "pending"] and i.kind not in ["capture", "refund"]], "payment_id")))))

The formula is a bit complicated as there can be multiple transaction records and payment_id fields.  The formula above filters the transaction records and returns only unique payment_id values.

The output will be similar to the Payment ID column in Shopify's default order CSV export where multiple values are separated by the " + " character.


App: EZ Exporter

Tags: advanced features, shopify transactions, information from the gateway, klarna