function commerce_paypal_post_update_5 in Commerce PayPal 8
Set the "payment_method_types" to "paypal_checkout".
File
- ./
commerce_paypal.post_update.php, line 130 - Post update functions for Commerce PayPal.
Code
function commerce_paypal_post_update_5(&$sandbox) {
$entity_type_manager = \Drupal::entityTypeManager();
$payment_gateway_storage = $entity_type_manager
->getStorage('commerce_payment_gateway');
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface[] $gateways */
$payment_gateways = array_filter($payment_gateway_storage
->loadMultiple(), function (PaymentGatewayInterface $gateway) {
return $gateway
->getPluginId() === 'paypal_checkout';
});
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
foreach ($payment_gateways as $payment_gateway) {
$configuration = $payment_gateway
->getPluginConfiguration();
$configuration['payment_method_types'] = [
'paypal_checkout',
];
$payment_gateway
->setPluginConfiguration($configuration);
$payment_gateway
->save();
}
}