Drupal自定义付款模块表格问题

发布于 2025-01-30 19:53:02 字数 1101 浏览 2 评论 0原文

我对Drupal有点陌生,我正在尝试创建自定义付款网关模块,并遇到问题。 在创建OnSitePaymentGateway时,一切都还好,我可以使用Paymethodaddform编辑结帐表格。但是对于OffSitePaymentGateWayBase,我无法输出其他信息以结帐表格。 此处的代码详细信息:

/**
 * Provides the Cresh payment gateway.
 *
 * @CommercePaymentGateway(
 *   id = "creshio",
 *   label = "Cresh.io",
 *   display_label = "Cresh.io",
 *    forms = {
 *     "offsite-payment" = "Drupal\commerce_creshio\PluginForm\CreshioForm",
 *   },
 *
 *   js_library = "commerce_creshio/creshlib",
 * )
 */
class Creshio extends OffsitePaymentGatewayBase { .... }

然后,我在src/ pluginform/中创建了creshioform.php,并添加了以下内容:

class CreshioForm extends BasePaymentOffsiteForm {
     public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
         $form = parent::buildConfigurationForm($form, $form_state);
         $form['#wrapper_id'] = Html::getUniqueId('payment-add-form-wrapper');
         $form['#prefix'] = '<div id="cresh-placeholder">';
         $form['#suffix'] = '</div>';
         return $form;
     }
}

我看不到cresh-placeholder的形式

I'm a bit new to drupal and i'm trying to create custom payment gateway module and stuck with a problem.
When creating OnSitePaymentGateway, everything is ok and i can edit checkout form with PaymentMethodAddForm. But for OffsitePaymentGatewayBase, I'm unable to output additional information to checkout form.
Here's code details:

/**
 * Provides the Cresh payment gateway.
 *
 * @CommercePaymentGateway(
 *   id = "creshio",
 *   label = "Cresh.io",
 *   display_label = "Cresh.io",
 *    forms = {
 *     "offsite-payment" = "Drupal\commerce_creshio\PluginForm\CreshioForm",
 *   },
 *
 *   js_library = "commerce_creshio/creshlib",
 * )
 */
class Creshio extends OffsitePaymentGatewayBase { .... }

Then I created CreshioForm.php in src/PluginForm/ and added following:

class CreshioForm extends BasePaymentOffsiteForm {
     public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
         $form = parent::buildConfigurationForm($form, $form_state);
         $form['#wrapper_id'] = Html::getUniqueId('payment-add-form-wrapper');
         $form['#prefix'] = '<div id="cresh-placeholder">';
         $form['#suffix'] = '</div>';
         return $form;
     }
}

And i can't see cresh-placeholder in the form

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文