Payment state machine
The following diagram shows the state machine for a Payment as used by the Payment plug-in controller. It describes how a Payment moves from state to state when financial transactions, queries, or external edits are made against a payment and payment plug-ins are used to process payment transactions. The payment state is persisted in the PPCPAYMENT table.
When newly created (New), two financial transactions are valid on a Payment: approve or approveAndDeposit.
When a payment is in an Approving state, a possible financial transaction is reverseApproval. If successful, the Payment will move to a Canceled state. The Payment can also move to an Approved state by a query update or by an edit operation performed by the Payment plug-in controller . This type of edit operation is commonly associated with offline payment protocols and timeout situations.
When in an Approved state, a Payment can be canceled by a full reverseApproval (the total approved amount is reversed), or it can expire during a query or deposit transaction. With deposits and partial reverseApproval (amount to be reversed is less than the total amount approved) transactions, the Payment stays in the Approved state.
When a financial transaction fails, the Payment goes to the Failed state.
End states for payments are Failed, Canceled, and Expired.