Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By FatherShawn on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x-2.x
Introduced in version:
8.2.0-RC3
Issue links:
Description:
Prior to RC3, HasPaymentInstructionsInterface::buildPaymentInstructions
had no parameters. This method now expects a instance of PaymentInterface
.
Implementation Before:
/**
* {@inheritdoc}
*/
public function buildPaymentInstructions() {
}
Implementation Now:
/**
* {@inheritdoc}
*/
public function buildPaymentInstructions(PaymentInterface $payment) {
}
Also update all code that uses the method to include the parameter. Here is an example from commerce_payment_preprocess_commerce_checkout_completion_message()
/**
* Implements hook_preprocess_commerce_checkout_completion_message().
*/
function commerce_payment_preprocess_commerce_checkout_completion_message(&$variables) {
/** @var Drupal\commerce_order\Entity\OrderInterface $order */
$order = $variables['order_entity'];
if ($order->get('payment_gateway')->isEmpty()) {
return;
}
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
$payment_gateway = $order->get('payment_gateway')->entity;
/** @var \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\HasPaymentInstructionsInterface $payment_gateway_plugin */
$payment_gateway_plugin = $payment_gateway->getPlugin();
if ($payment_gateway_plugin instanceof HasPaymentInstructionsInterface) {
$payment_storage = \Drupal::entityTypeManager()->getStorage('commerce_payment');
$payments = $payment_storage->loadMultipleByOrder($order);
$payments = array_filter($payments, function ($payment) use ($payment_gateway) {
return $payment->getPaymentGatewayId() == $payment_gateway->id();
});
$payment = reset($payments);
if ($payment) {
$variables['payment_instructions'] = $payment_gateway_plugin->buildPaymentInstructions($payment);
}
}
}
Impacts:
Module developers