TransWikia.com

Craft Commerce - explain transaction types and statuses to me

Craft CMS Asked by piotrpog on December 3, 2020

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?

One 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.

Correct answer by Luke Holder on December 3, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP