0

Using Magento 2.4.6 with PHP 8.2 When running composer require stripe/stripe-payments I have no problem. However when I run sudo bin/magento setup:upgrade I get

unable to apply data patch StripeIntegration\Payments\Setup\Patch\Data\Patch003InitialFees for module StripeIntegration_Payments. Original exception message: The "stripe_sub_enabled" attribute name is invalid. Reset the name and try again.

I should mention my composer.lock

  • Locking stripe/module-payments (3.4.1)
  • Locking stripe/stripe-payments (3.4.0)
  • Locking stripe/stripe-php (v7.128.0)

What am I doing wrong?

0

1 Answer 1

0

It looks like the product attribute stripe_sub_enabled doesn't exist. I'm not sure if this has been manually deleted or not, but it seems as though this should be created by \StripeIntegration\Payments\Setup\Patch\Data\InitialInstall.

   private function initSubscriptions($setup)
    {
        $groupName = 'Subscriptions by Stripe';

        $attributes = [
            'stripe_sub_enabled' => [
                'type'                  => 'int',
                'label'                 => 'Subscription Enabled',
                'input'                 => 'boolean',
                'source'                => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'sort_order'            => 100,
                'global'                => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group'                 => $groupName,
                'is_used_in_grid'       => false,
                'is_visible_in_grid'    => false,
                'is_filterable_in_grid' => false,
                'used_for_promo_rules'  => true,
                'required'              => false
            ],
            'stripe_sub_interval' => [
                'type'                  => 'varchar',
                'label'                 => 'Frequency',
                'input'                 => 'select',
                'source'                => 'StripeIntegration\Payments\Model\Adminhtml\Source\BillingInterval',
                'sort_order'            => 110,
                'global'                => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group'                 => $groupName,
                'is_used_in_grid'       => false,
                'is_visible_in_grid'    => false,
                'is_filterable_in_grid' => false,
                'used_for_promo_rules'  => true,
                'required'              => false
            ],
            'stripe_sub_interval_count' => [
                'type'                  => 'varchar',
                'label'                 => 'Repeat Every',
                'input'                 => 'text',
                'sort_order'            => 120,
                'global'                => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group'                 => $groupName,
                'is_used_in_grid'       => false,
                'is_visible_in_grid'    => false,
                'is_filterable_in_grid' => false,
                'used_for_promo_rules'  => true,
                'required'              => false
            ],
            'stripe_sub_trial'       => [
                'type'                  => 'int',
                'label'                 => 'Trial Days',
                'input'                 => 'text',
                'sort_order'            => 130,
                'global'                => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group'                 => $groupName,
                'is_used_in_grid'       => false,
                'is_visible_in_grid'    => false,
                'is_filterable_in_grid' => false,
                'used_for_promo_rules'  => true,
                'required'              => false
            ],
            'stripe_sub_initial_fee' => [
                'type'                  => 'decimal',
                'label'                 => 'Initial Fee',
                'input'                 => 'text',
                'sort_order'            => 140,
                'global'                => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
                'group'                 => $groupName,
                'is_used_in_grid'       => false,
                'is_visible_in_grid'    => false,
                'is_filterable_in_grid' => false,
                'used_for_promo_rules'  => true,
                'required'              => false
            ]
        ];

        $categorySetup = $this->_categorySetupFactory->create(['setup' => $setup]);

        foreach ($attributes as $code => $params)
            $categorySetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, $code, $params);

        $this->sortGroup($groupName, 11);
    }

The patch that's failing has a dependency on this, so shouldn't fail. StripeIntegration\Payments\Setup\Patch\Data

public static function getDependencies()
{
    /**
     * This is dependency to another patch. Dependency should be applied first
     * One patch can have few dependencies
     * Patches do not have versions, so if in old approach with Install/Ugrade data scripts you used
     * versions, right now you need to point from patch with higher version to patch with lower version
     * But please, note, that some of your patches can be independent and can be installed in any sequence
     * So use dependencies only if this important for you
     */
    return [
        \StripeIntegration\Payments\Setup\Patch\Data\InitialInstall::class
    ];
}

If this is your local environment, it may be worth just removing all entries for this module from the patch_list table in the database, then try to re-run setup:upgrade. This should mean that the datapatch that creates this attribute is run first, which should prevent the error happening that we're seeing here.

1
  • Thanks I actually just deleted the patch. However I will try your method. thx
    – Henri
    May 4, 2023 at 2:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.