<p>A transaction can have a single type and status at one time.
A transaction can also have a parent transaction relationship.</p>
<p><strong>There are 4 transaction types:</strong>
<code>authorize</code>, <code>capture</code>, <code>purchase</code>, <code>refund</code>.</p>
<p>A transaction type determines what the transactions is and how it is counted when determining the order totals.</p>
<p><code>authorize</code> is used when the customer is not immediately charged to their card, but an authorization is placed on their card. The authorization will be captured at a later time, and the customers card will then be charged. An authorization can have the status of <code>pending</code>, <code>redirect</code>, <code>processing</code>, <code>success</code>, or <code>failed</code>.</p>
<p><code>capture</code> transactions are always child transactions of <code>authorize</code> transactions. You can only capture a <code>authorize</code> transaction that had a <code>success</code> status. A capture can have the status of <code>success</code>, or <code>failed</code>.</p>
<p><code>purchase</code> is used when the customer is getting charged immediately to their card. An purchase can have the status of <code>pending</code>, <code>redirect</code>, <code>processing</code>, <code>success</code>, or <code>failed</code>.</p>
<p><code>refund</code> is used when the customer was refunded an amount. It can only be the child of a <code>capture</code> or <code>purchase</code> transactions that have the status of <code>success</code></p>
<p><strong>There are 5 transaction statuses:</strong>
<code>pending</code>, <code>redirect</code>, <code>processing</code>, <code>success</code>, <code>failed</code>.</p>
<p><code>pending</code> status is for when a transaction is first created. It could then be changed to different status once the gateway/customer determines what the transaction should be. For example, changed to the <code>redirect</code> status when the customer is being redirected off-site.</p>
<p><code>redirect</code> status us when the customer was sent off-site. A redirect status should only be used for <code>authorized</code> and <code>capture</code> transactions as capture and refunds are usually done by an admin from the control panel and not taken off-site to perform those actions.</p>
<p><code>processing</code> is a semi-successful status introduced due to asynchronous nature of some gateways where knowing if the transaction is successful or failed will happen at a later time. For example, in stripe the customer might be returned from a SCA offsite back to the craft site and we will update the transaction as <code>processing</code> before the webhook comes in with the results of the payment from the bank. When we get a <code>processing</code> status on an <code>authorize</code> or <code>purchase</code> transaction we still
'complete' the cart and turn it into an order. So the only way for a customer to complete a cart is to have a successful purchase or authorization or a successful processing transaction.</p>
<p><code>success</code> status means the transaction was successful. This covers the <code>authorization</code>, <code>capture</code>, <code>purchase</code> and <code>refund</code>.</p>
<p><code>failed</code> status means the transaction failed. This covers <code>authorization</code>, <code>capture</code>, <code>purchase</code> and <code>refund</code>.</p>
<p>We will update the docs with the above.</p>

CC BY-SA 4.0
2020-10-26T10:26:46.223Z
Very comprehensive, thanks! Can you also write about concept of "child transactions" a bit?
Piotr Pogorzelski
CC BY-SA 4.0
2020-10-26T21:19:30.590Z
Great to see this spelled out.  

Perhaps be worth explaining how 'capture' can be used just a tad more for non credit card contexts - e.g. we 'capture' a payment once it is visible in our bank account.  This then means the order becomes available for our module to push to our external inventory system.
Jeremy Daalder
CC BY-SA 4.0
2020-10-26T03:41:39.207Z
2020-10-26T03:41:39.207Z
Luke Holder
<p>Commerce transactions have multiple possible types and statuses:</p>
<pre><code>    const TYPE_AUTHORIZE = 'authorize';
    const TYPE_CAPTURE = 'capture';
    const TYPE_PURCHASE = 'purchase';
    const TYPE_REFUND = 'refund';

    const STATUS_PENDING = 'pending';
    const STATUS_REDIRECT = 'redirect';
    const STATUS_PROCESSING = 'processing';
    const STATUS_SUCCESS = 'success';
    const STATUS_FAILED = 'failed';
</code></pre>
<p>Can someone explain to me what each of them means?</p>

<plugin-craftcommerce>
Craft Commerce - explain transaction types and statuses to me
# Craft Commerce - explain transaction types and statuses to me

(Asked by: username_0 on 2020-10-25)

Commerce transactions have multiple possible types and statuses:
    const TYPE_AUTHORIZE = 'authorize';
    const TYPE_CAPTURE = 'capture';
    const TYPE_PURCHASE = 'purchase';
    const TYPE_REFUND = 'refund';

    const STATUS_PENDING = 'pending';
    const STATUS_REDIRECT = 'redirect';
    const STATUS_PROCESSING = 'processing';
    const STATUS_SUCCESS = 'success';
    const STATUS_FAILED = 'failed';

Can someone explain to me what each of them means?

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_1 on 2020-10-26. Score: 3 | Accepted answer

A transaction can have a single type and status at one time.
A transaction can also have a parent transaction relationship.

**There are 4 transaction types:**
`authorize`, `capture`, `purchase`, `refund`.

A transaction type determines what the transactions is and how it is counted when determining the order totals.

`authorize` is used when the customer is not immediately charged to their card, but an authorization is placed on their card. The authorization will be captured at a later time, and the customers card will then be charged. An authorization can have the status of `pending`, `redirect`, `processing`, `success`, or `failed`.

`capture` transactions are always child transactions of `authorize` transactions. You can only capture a `authorize` transaction that had a `success` status. A capture can have the status of `success`, or `failed`.

`purchase` is used when the customer is getting charged immediately to their card. An purchase can have the status of `pending`, `redirect`, `processing`, `success`, or `failed`.

`refund` is used when the customer was refunded an amount. It can only be the child of a `capture` or `purchase` transactions that have the status of `success`

**There are 5 transaction statuses:**
`pending`, `redirect`, `processing`, `success`, `failed`.

`pending` status is for when a transaction is first created. It could then be changed to different status once the gateway/customer determines what the transaction should be. For example, changed to the `redirect` status when the customer is being redirected off-site.

`redirect` status us when the customer was sent off-site. A redirect status should only be used for `authorized` and `capture` transactions as capture and refunds are usually done by an admin from the control panel and not taken off-site to perform those actions.

`processing` is a semi-successful status introduced due to asynchronous nature of some gateways where knowing if the transaction is successful or failed will happen at a later time. For example, in stripe the customer might be returned from a SCA offsite back to the craft site and we will update the transaction as `processing` before the webhook comes in with the results of the payment from the bank. When we get a `processing` status on an `authorize` or `purchase` transaction we still
'complete' the cart and turn it into an order. So the only way for a customer to complete a cart is to have a successful purchase or authorization or a successful processing transaction.

`success` status means the transaction was successful. This covers the `authorization`, `capture`, `purchase` and `refund`.

`failed` status means the transaction failed. This covers `authorization`, `capture`, `purchase` and `refund`.

We will update the docs with the above.

> **Comments:**
> **username_0**: Very comprehensive, thanks! Can you also write about concept of "child transactions" a bit?  
> **username_2**: Great to see this spelled out.    Perhaps be worth explaining how 'capture' can be used just a tad more for non credit card contexts - e.g. we 'capture' a payment once it is visible in our bank account.  This then means the order becomes available for our module to push to our external inventory system.  

---

