Loading commerce_sage_payments.workflows.yml +138 −0 Original line number Diff line number Diff line Loading @@ -73,3 +73,141 @@ payment_sage_payments: label: 'Refund payment' from: [refund_pending] to: refunded # Transaction workflow for its remote state field. transaction_sage_payments: id: transaction_sage_payments group: commerce_transaction label: 'Sage Payments' # Sage Payments uses the same statuses for what would be a different state in # Drupal. They are differentiated by being marked as being of different type # e.g. Capture vs Authorization vs Void. For example, an Authorization/Batch # transaction is at a different stage of its lifecycle compared to later when # the same transaction becomes Capture/Batch. We provide unique state IDs we # concatenate the lower case versions of the remote type + status code as # given by the Direct API responses. # See \Drupal\commerce_sage_payments\Plugin\Commerce\PaymentType\SagePayments::getTransactionTransition(). # # The states listed here may not be exhaustive. We have include the ones we # have encountered while using the supported workflows. states: # Authorization workflow. ## Initial authorization without request for capture. authorization_batch: label: 'Batch' ## Authorization voided. void_declined: label: 'Declined' ## Requested to be captured pending batch processing. capture_batch: label: 'Batch' ## Successfully captured. capture_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. capture_error: label: 'Error' capture_declined: label: 'Declined' capture_expired: label: 'Expired' # Sale workflow. sale_batch: label: 'Batch' ## Successfully captured. sale_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. sale_error: label: 'Error' sale_declined: label: 'Declined' sale_expired: label: 'Expired' # Credit workflow. ## Requested to be refunded. credit_batch: label: 'Batch' ## Successfully refunded. credit_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. credit_error: label: 'Error' credit_declined: label: 'Declined' credit_expired: label: 'Expired' # The workflow is the similar for both Charge and Refund transactions. They # are initially in `Batch` status in Sage Payments. They then move to either # `Settled` for successfully captured/refunded transactions, or to # `Error/Declined/Expired`. We use the fact that there is only one transition # for each target state to programmatically determine the transition that a # transaction needs to go through based on its remote state when fetching # updates. If that ever changes (i.e. there is more than one transition for a # target `to` state) that update logic needs to be revisited otherwise a wrong # transition may be tirggered. # See \Drupal\commerce_sage_payments\Plugin\Commerce\PaymentType\SagePayments::getTransactionTransition(). transitions: # Authorization workflow. void_authorization: label: 'Void' from: ['authorization_batch'] to: 'void_declined' capture_authorization: label: 'Request capture' from: ['authorization_batch'] to: 'capture_batch' settle_capture: label: 'Settle' from: ['capture_batch'] to: 'capture_settled' fail_capture: label: 'Fail' from: ['capture_batch'] to: 'capture_error' decline_capture: label: 'Decline' from: ['capture_batch'] to: 'capture_declined' expire_capture: label: 'Expire' from: ['capture_batch'] to: 'capture_expired' # Sale workflow. settle_sale: label: 'Settle' from: ['sale_batch'] to: 'sale_settled' fail_sale: label: 'Fail' from: ['sale_batch'] to: 'sale_error' decline_sale: label: 'Decline' from: ['sale_batch'] to: 'sale_declined' expire_sale: label: 'Expire' from: ['sale_batch'] to: 'sale_expired' # Refund workflow. settle_credit: label: 'Settle' from: ['credit_batch'] to: 'credit_settled' fail_credit: label: 'Fail' from: ['credit_batch'] to: 'credit_error' decline_credit: label: 'Decline' from: ['credit_batch'] to: 'credit_declined' expire_credit: label: 'Expire' from: ['credit_batch'] to: 'credit_expired' Loading
commerce_sage_payments.workflows.yml +138 −0 Original line number Diff line number Diff line Loading @@ -73,3 +73,141 @@ payment_sage_payments: label: 'Refund payment' from: [refund_pending] to: refunded # Transaction workflow for its remote state field. transaction_sage_payments: id: transaction_sage_payments group: commerce_transaction label: 'Sage Payments' # Sage Payments uses the same statuses for what would be a different state in # Drupal. They are differentiated by being marked as being of different type # e.g. Capture vs Authorization vs Void. For example, an Authorization/Batch # transaction is at a different stage of its lifecycle compared to later when # the same transaction becomes Capture/Batch. We provide unique state IDs we # concatenate the lower case versions of the remote type + status code as # given by the Direct API responses. # See \Drupal\commerce_sage_payments\Plugin\Commerce\PaymentType\SagePayments::getTransactionTransition(). # # The states listed here may not be exhaustive. We have include the ones we # have encountered while using the supported workflows. states: # Authorization workflow. ## Initial authorization without request for capture. authorization_batch: label: 'Batch' ## Authorization voided. void_declined: label: 'Declined' ## Requested to be captured pending batch processing. capture_batch: label: 'Batch' ## Successfully captured. capture_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. capture_error: label: 'Error' capture_declined: label: 'Declined' capture_expired: label: 'Expired' # Sale workflow. sale_batch: label: 'Batch' ## Successfully captured. sale_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. sale_error: label: 'Error' sale_declined: label: 'Declined' sale_expired: label: 'Expired' # Credit workflow. ## Requested to be refunded. credit_batch: label: 'Batch' ## Successfully refunded. credit_settled: label: 'Settled' ## We have not been able to test the following statuses in the sandbox. We ## add them because we expect them to exist according to documentation. credit_error: label: 'Error' credit_declined: label: 'Declined' credit_expired: label: 'Expired' # The workflow is the similar for both Charge and Refund transactions. They # are initially in `Batch` status in Sage Payments. They then move to either # `Settled` for successfully captured/refunded transactions, or to # `Error/Declined/Expired`. We use the fact that there is only one transition # for each target state to programmatically determine the transition that a # transaction needs to go through based on its remote state when fetching # updates. If that ever changes (i.e. there is more than one transition for a # target `to` state) that update logic needs to be revisited otherwise a wrong # transition may be tirggered. # See \Drupal\commerce_sage_payments\Plugin\Commerce\PaymentType\SagePayments::getTransactionTransition(). transitions: # Authorization workflow. void_authorization: label: 'Void' from: ['authorization_batch'] to: 'void_declined' capture_authorization: label: 'Request capture' from: ['authorization_batch'] to: 'capture_batch' settle_capture: label: 'Settle' from: ['capture_batch'] to: 'capture_settled' fail_capture: label: 'Fail' from: ['capture_batch'] to: 'capture_error' decline_capture: label: 'Decline' from: ['capture_batch'] to: 'capture_declined' expire_capture: label: 'Expire' from: ['capture_batch'] to: 'capture_expired' # Sale workflow. settle_sale: label: 'Settle' from: ['sale_batch'] to: 'sale_settled' fail_sale: label: 'Fail' from: ['sale_batch'] to: 'sale_error' decline_sale: label: 'Decline' from: ['sale_batch'] to: 'sale_declined' expire_sale: label: 'Expire' from: ['sale_batch'] to: 'sale_expired' # Refund workflow. settle_credit: label: 'Settle' from: ['credit_batch'] to: 'credit_settled' fail_credit: label: 'Fail' from: ['credit_batch'] to: 'credit_error' decline_credit: label: 'Decline' from: ['credit_batch'] to: 'credit_declined' expire_credit: label: 'Expire' from: ['credit_batch'] to: 'credit_expired'