Score:0

Custom payment module form problem

cn flag

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. This is the code I am using.

/**
 * 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 code.

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;
  }

}

I can't see cresh-placeholder in the form.

cn flag
Maybe it's because of the broken markup and the browser is compensating? (You have an extra `</div>`)
cn flag
@Clive Thanks for the comment, yep, that's a mistake, I've removed `</div>`, but that didn't help :(
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.