<commit_before>=== Payment States

A payment consists of multiple payment transactions. Also, a payment has a state which determines the set of possible subsequent operations available.

Initially a client of the api can make either an *authorization*, a *purchase*, or a *credit* call (all other operations such as refund would require an initial payment to have already existed).
That initial operation will create a https://github.com/killbill/killbill-api/blob/master/src/main/java/org/killbill/billing/payment/api/Payment.java[Payment] and an initial https://github.com/killbill/killbill-api/blob/c243233be112165bf04a89a715b79112c6c5d1f7/src/main/java/org/killbill/billing/payment/api/PaymentTransaction.java[PaymentTransaction].
The user can then submit additional requests for the same payment (capture, refund, ...) and each of those calls will result in additional `PaymentTransaction` attached to the same payment.
The payments have a state which will drive the set of possible subsequent operations available. For instance, it is possible to make a capture call against a payment in a state `AUTH_SUCCESS` but it is not possible to make such an operation against a payment in an `AUTH_ERRORED` state.
The set of payment state transitions are configured in an https://github.com/killbill/killbill/blob/master/payment/src/main/resources/org/killbill/billing/payment/PaymentStates.xml[xml file] and the Kill Bill payment subsystem is in charge to enforce the transitions. The following diagram below shows all the possible transitions:

graphviz::https://github.com/killbill/killbill-docs/raw/v3/userguide/assets/payment_states.dot[format=svg,align=center]

In addition to the payment state transitions, each `PaymentTransaction` has a status to reflect the result of the operation. The `PaymentTransaction` status depends on the plugin result and it can be summarized below:

|===
|plugin result | payment transaction status | payment state | http response | description

|PROCESSED
|SUCCESS
|{AUTH,CAPTURE,..}_SUCCESS
| 201 - Created
|The payment transaction went through and was successful

|PENDING
|PENDING
|{AUTH,CAPTURE,..}_PENDING
| 201 - Created<commit_msg>Revert "fix incorrect image reference"<commit_after>=== Payment States

A payment consists of multiple payment transactions. Also, a payment has a state which determines the set of possible subsequent operations available.

Initially a client of the api can make either an *authorization*, a *purchase*, or a *credit* call (all other operations such as refund would require an initial payment to have already existed).
That initial operation will create a https://github.com/killbill/killbill-api/blob/master/src/main/java/org/killbill/billing/payment/api/Payment.java[Payment] and an initial https://github.com/killbill/killbill-api/blob/c243233be112165bf04a89a715b79112c6c5d1f7/src/main/java/org/killbill/billing/payment/api/PaymentTransaction.java[PaymentTransaction].
The user can then submit additional requests for the same payment (capture, refund, ...) and each of those calls will result in additional `PaymentTransaction` attached to the same payment.
The payments have a state which will drive the set of possible subsequent operations available. For instance, it is possible to make a capture call against a payment in a state `AUTH_SUCCESS` but it is not possible to make such an operation against a payment in an `AUTH_ERRORED` state.
The set of payment state transitions are configured in an https://github.com/killbill/killbill/blob/master/payment/src/main/resources/org/killbill/billing/payment/PaymentStates.xml[xml file] and the Kill Bill payment subsystem is in charge to enforce the transitions. The following diagram below shows all the possible transitions:

graphviz::assets/payment_states.dot[format=svg,align=center]

In addition to the payment state transitions, each `PaymentTransaction` has a status to reflect the result of the operation. The `PaymentTransaction` status depends on the plugin result and it can be summarized below:

|===
|plugin result | payment transaction status | payment state | http response | description

|PROCESSED
|SUCCESS
|{AUTH,CAPTURE,..}_SUCCESS
| 201 - Created
|The payment transaction went through and was successful

|PENDING
|PENDING
|{AUTH,CAPTURE,..}_PENDING
| 201 - Created
{'fraction_non_alphanumeric': 0.07255447380621233, 'fraction_numerical': 0.015994436717663423, 'mean_word_length': 5.392592592592592, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3305738', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1092, 'n_words': 485}