Jump to content

Fundraising/Data and flow/Transaction IDs

From Wikitech

Each financial transaction has IDs associated, with a range of targets and granularities.

trxn vs txn

Civi uses the trxn naming in their database tables. In wmf_contribution_extra though it has gateway_txn_id. This is what is used in the queue messages and throughout our code.

ID Abbreviation Target Granularity Description Example
Contribution Tracking ID CTID contribution_tracking.id per session This is the largest granularity association, and spans all attempts made by this donor until we cut them off for being frustrating.

Ingenico: also at transaction.Merchant Reference

12345
CiviCRM Contribution ID civicrm_contribution.id per completed payment The local CRM ID, only assigned once a donation is recorded in our system. You can search for this ID (and the Contact ID) in the quicksearch box in the top-left corner of the page.
CiviCRM Transaction ID civicrm_contribution.trxn_id per completed payment This is another CRM local ID, usually based on the gateway name, gateway transaction ID and a timestamp or other sequence fields when necessary to guarantee uniqueness.
Gateway Transaction ID wmf_contribution_extra.gateway_txn_id depends on gateway Processor's ID for this transaction. This has different meanings depending on the processor (see below). Ingenico:

000000293000000010370000100001

Ingenico Order ID

INGENICO Recurring payments share the same Order ID, so we append the Effort ID when creating a local Transaction ID.
Ingenico hosted checkout ID Temporarily stored in smashpig.pending.message, under a JSON property called gateway_session_id. Per session An ID generated when we make the initial createHostedCheckout call to Ingenico, before we redirect the donor to their form. When the donor comes back, we use this ID to query the status of their payment session and see if it has a transaction associated with it. 064358d8-367d-71ff-9f8f-4ee7c57237c0

PayPal Transaction ID

PAYPAL
PayPal Checkout Token Temporarily stored in smashpig.pending.message, under a JSON property called gateway_session_id. Per session Similar to Ingenico's hosted checkout ID, created before redirect and used after return to query whether a payment exists. EC-4VW60845G5703234A

Adyen ...

Amazon ...

Amazon has IDs for each stage of the process - one ID for the authorization, one for the capture, one for the billing agreement.

DLocal ...

Recurring? RECURRING ... Term in civicrm_contribution.trxn_id N/A This is a flag in trxn_id to let us know that payments are part of a subscription.
Refund? RFD ... Term in civicrm_contribution.trxn_id N/A Flag to let us know that the payment was a refund. In the distant past we had to create a separate contribution with a negative amount in order to record refunds. Nowadays we just set the contribution_status_id to 9 (Refunded). We will create a separate contribution with transaction prefix RFD if for some reason (currency fluctuation, perhaps) we have to refund more than the original amount.
CiviCRM Invoice ID civicrm_contribution.invoice_id Contribution Tracking ID plus a sequence indicator (incremented on each attempt with the same CT ID). Usually separated by a '.', except for Amazon Pay which uses a '-' due to allowed character restrictions.

Ingenico: Merchant Reference

12345.1
Gateway Subscription ID FIXME: Start a custom table for this, or make the trxn_id transformation reversible? Per recurring donation
CiviCRM Recurring Contribution ID civicrm_contribution_recur.id Foreign key for civicrm_contribution.contribution_recur_id
CiviCRM Subscription ID civicrm_contribution_recur.trxn_id We make a unique key from the Gateway Subscription ID, usually by prefixing with the gateway name, but this hasn't been standardized yet.

Ingenico Tokenized subscriptions do not have the gateway name prefixed

Updonate subscriptions do

123

Updonate: INGENICO 123

CiviCRM Processor ID civicrm_contribution_recur.processor_id Gateway Subscription ID 123
CiviCRM recurring Invoice ID civicrm_contribution_recur.invoice_id We stash the Adyen 'Shopper ID' here and pass it to SmashPig as 'processor_contact_id' to charge recurring payments
Initial Scheme Transaction ID civicrm_contribution_recur_smashpig.initial_scheme_transaction_id ID set at the card network for transactions authenticated with 3DS. Ingenico says we have to save the ID of the first transaction and send it along with each recurring installment.