You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spryker新手求助:扩展DummyPaymentHandlerPlugin类失败

Spryker扩展DummyPaymentHandlerPlugin类不生效的排查解决步骤
  • 确认自定义插件结构合规
    自定义插件需正确继承原类或实现对应接口,示例代码:

    namespace Pyz\Zed\Payment\Communication\Plugin;
    
    use Spryker\Zed\DummyPayment\Communication\Plugin\DummyPaymentHandlerPlugin;
    
    class CustomDummyPaymentHandlerPlugin extends DummyPaymentHandlerPlugin
    {
        public function handlePayment(array $paymentTransfer): void
        {
            // 写入你的自定义逻辑
            parent::handlePayment($paymentTransfer);
        }
    }
    
  • 校验工厂注册逻辑
    在Pyz\Zed\Payment\Business\PaymentFactory的createPaymentHandlerPlugins方法中,替换或添加自定义插件,确保键名与原插件一致:

    namespace Pyz\Zed\Payment\Business;
    
    use Pyz\Zed\Payment\Communication\Plugin\CustomDummyPaymentHandlerPlugin;
    use Spryker\Zed\Payment\Business\PaymentFactory as SprykerPaymentFactory;
    
    class PaymentFactory extends SprykerPaymentFactory
    {
        protected function createPaymentHandlerPlugins(): array
        {
            return [
                'dummyPayment' => new CustomDummyPaymentHandlerPlugin(),
                // 保留其他支付插件配置
            ];
        }
    }
    
  • 刷新生成文件与依赖配置
    执行以下命令确保代码生成与依赖注入正确:

    console transfer:generate
    console dev:ide:generate
    
  • 清除缓存并验证
    执行缓存清理命令刷新插件注册缓存:

    console cache:clear
    

    触发支付流程,通过日志或调试语句检查自定义逻辑是否执行。

  • 检查命名空间与类加载
    确认自定义插件的命名空间符合Spryker模块结构,类文件名与类名严格一致(大小写敏感),避免因自动加载失败导致插件未生效。

内容的提问来源于stack exchange,提问作者Dalbin Shimy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 21:20:20