You are here

function commerce_payment_update_8201 in Commerce Core 8.2

Remove the authorization_expires field from payments, add the expires and completed fields.

File

modules/payment/commerce_payment.install, line 39
Install, update and uninstall functions for the commerce_payment module.

Code

function commerce_payment_update_8201() {
  $entity_definition_update = \Drupal::entityDefinitionUpdateManager();
  $storage_definition = BaseFieldDefinition::create('timestamp')
    ->setName('authorization_expires')
    ->setTargetEntityTypeId('commerce_payment')
    ->setLabel(t('Authorization expires'))
    ->setDescription(t('The time when the payment authorization expires.'))
    ->setDisplayConfigurable('view', TRUE);
  $entity_definition_update
    ->uninstallFieldStorageDefinition($storage_definition);
  $storage_definition = BaseFieldDefinition::create('timestamp')
    ->setLabel(t('Expires'))
    ->setDescription(t('The time when the payment expires.'))
    ->setDisplayConfigurable('view', TRUE);
  $entity_definition_update
    ->installFieldStorageDefinition('expires', 'commerce_payment', 'commerce_payment', $storage_definition);
  $storage_definition = BaseFieldDefinition::create('timestamp')
    ->setLabel(t('Completed'))
    ->setDescription(t('The time when the payment was completed.'))
    ->setDisplayConfigurable('view', TRUE);
  $entity_definition_update
    ->installFieldStorageDefinition('completed', 'commerce_payment', 'commerce_payment', $storage_definition);
}