Payment statuses no longer use the PaymentStatusInfo and PaymentStatusItem classes, and are no longer exposed using hook_payment_status_info().
Instead, contexts are Payment/Status plugins that need to implement \Drupal\payment\Plugin\Payment\Status\PaymentStatusInterface and can optionally extend \Drupal\payment\Plugin\Payment\Status\Base. Plugins should be annotated using \Drupal\payment\Annotations\PaymentStatus. They can be set and got from payment entities using \Drupal\payment\Plugin\Core\Entity\PaymentInterface::setStatus(), \Drupal\payment\Plugin\Core\Entity\PaymentInterface::setStatuses(), \Drupal\payment\Plugin\Core\Entity\PaymentInterface::getStatus(), and \Drupal\payment\Plugin\Core\Entity\PaymentInterface::getStatuses(), much like you would do in 7.x-1.x.
As part of this change, all PAYMENT_STATUS_* constants have been removed. Use payment_upgrade_8x2x_map_status() to upgrade the old constants' values to payment status plugin IDs.
This change also introduced hook_payment_status_alter().
Define a payment status (7.x-1.x)
/**
* Implements hook_payment_status_info().
*/
function payment_payment_status_info() {
return array(
new PaymentStatusInfo(array(
'status' => PAYMENT_STATUS_PENDING,
'title' => t('Pending'),
'parent' => PAYMENT_STATUS_MONEY_NOT_TRANSFERRED,
)),
);
}
Define a payment status (8.x-2.x)
# In $module.payment.status.yml, where $module is your module's machine name.
# Top-level items are plugin IDs. Allowed keys are:
# - label (required): The US English human-readable plugin label.
# - description (optional): The US English human-readable plugin description.
# - parent_id (optional): The plugin ID of the parent status.
# - deriver (optional): The fully-qualified name of a class that provides plugin derivatives.
# - operations_provider (optional): The fully-qualified name of a class that implements \Drupal\payment\Plugin\Payment\OperationsProviderInterface.
payment_authorized:
description: The payment has been authorized by the payer, and the funds are waiting to be transferred.
label: Authorized
parent_id: payment_no_money_transferred
Set a status on a payment (7.x-1.x)
$payment->setStatus(new PaymentStatusItem(PAYMENT_STATUS_SUCCESS);
Set a status on a payment (8.x-2.x)
$manager = \Drupal\payment\Payment::statusManager();
$payment->setStatus($manager->createInstance('payment_success');