|
I am creating an eCheck (ACH) payment module, and I’m having trouble with integrating custom user input fields into the onepage checkout process. Having looked at the existing payment gateway code, this and other forum/wiki articles, I’m just not sure what I am missing.
My problem is this: when I select my eCheck payment option on the Payment Information tab of OnePage, my eCheck form shows up, and I can enter in my data. Once I click submit, the Payment Method tab of the Checkout Progress sidebar appears, but the values I try to echo are blank. However, when I continue on and Place Order, my order completes successfully, and the order confirmation email that I receive has the info fields properly populated. I cannot figure out why my Checkout Progress -> Payment Method sidebar info template is not getting populated. If I change the post variables in my form template to the same ones used in the default Credit Card payment form template, I am able to then reference those object variables in the same method as my code below, and get data back.
Here are relevant snippets of code from my module:
From the form template for my payment method:
<li> <div class="input-box"> <label for="<?php echo $_code ?>_account_number"><?php echo $this->__('Bank Account Number') ?> <span class="required">*</span></label><br/> <input type="text" id="<?php echo $_code ?>_account_number" name="payment[account_number]" title="<?php echo $this->__('Bank Account Number') ?>" class="input-text" value="" /> </div> </li> <li> <div class="input-box"> <label for="<?php echo $_code ?>_routing_number"><?php echo $this->__('Routing/Transit Number') ?> <span class="required">*</span></label><br /> <input type="text" id="<?php echo $_code ?>_routing_number" name="payment[routing_number]" title="<?php echo $this->__('Routing/Transit Number') ?>" class="input-text" value="" maxlength="9"/> </div> </li> <li> <div class="input-box"> <label for="<?php echo $_code ?>_check_number"><?php echo $this->__('Next Available Check Number') ?> <span class="required">*</span></label><br /> <input type="text" id="<?php echo $_code ?>_check_number" name="payment[check_number]" title="<?php echo $this->__('Next Available Check Number') ?>" class="input-text" value="" maxlength="9"/> </div> </li>
From the info template for my payment method:
<?php echo Mage::helper('payment')->__('Check Number: %s', $this->htmlEscape($this->getCheckNumber())) ?><br/> <?php echo Mage::helper('payment')->__('Account No: %s', $this->htmlEscape($this->getAccountNumber() )) ?><br/> <?php echo Mage::helper('payment')->__('Routing No: %s', $this->htmlEscape($this->getRoutingNumber())) ?>
The assignData function in my payment method class
public function assignData($data) { if (!($data instanceof Varien_Object)) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $info->setRoutingNumber($data->getRoutingNumber()) ->setAccountNumber($data->getAccountNumber()) ->setCheckNumber($data->getCheckNumber()) ; return $this; }
The paymentToQuotePayment function from my extended Mage_Sales_Model_Convert_Order class:
public function paymentToQuotePayment(Mage_Sales_Model_Order_Payment $payment, $quotePayment=null) { $quotePayment = parent::paymentToQuotePayment($payment, $quotePayment); $quotePayment->setRoutingNumber($payment->getRoutingNumber()); $quotePayment->setAccountNumber($payment->getAccountNumber()); $quotePayment->setCheckNumber($payment->getCheckNumber()); return $quotePayment; }
My event observer for sales_convert_quote_payment_to_order_payment:
public function AddAdditionalParametersToOrderPayment($observer) { $orderPayment = $observer->getEvent()->getOrderPayment(); $payment = $observer->getEvent()->getQuotePayment(); $orderPayment->setRoutingNumber($payment->getRoutingNumber()); $orderPayment->setAccountNumber($payment->getAccountNumber()); $orderPayment->setCheckNumber($payment->getCheckNumber()); }
Finally, I have installed eav_attribute records for “routing_number”, “account_number”, and “check_number” for both the “order_payment” and “quote_payment” eav_entity_type’s via the standard Magento method. I see where my order_payment attributes have corresponding sales_order_entity_varchar records persisted after my order is placed.
I am developing against Magento 1.1.2. Part of my problem is that I’m in the dark as far as properly debugging the onepage. I’m using Eclipse PDT with the Zend Debugger module for apache, but the AJAX on onepage causes debugger/apache to crash everytime I load it. :-(
I have also looked at the <fieldsets> definitions within Mage_Sales config.xml. I see where the paymentToQuotePayment methods, etc have been updated to copy field sets. I tried to define extra fieldset definitions in my modules config.xml in the following style, but that didn’t seem to help either:
<sales_convert_quote_payment> <routing_number><to_order_payment>*</to_order_payment></routing_number> </sales_convert_quote_payment>
Anyway… if anyone knows of an obvious step I’ve overlooked, or what I might be doing improperly, I would GREATLY appreciate the help! I’m stuck at the moment! I had no problems creating a vanilla credit card payment module, but I have not done alot with altering the database structure in Magento and the process of adding custom input fields for this payment method has be confused.
Thanks in advance!
|