0

I started working on magento2 since 2 months, i have payment method which was working before and suddenly it stopped. i could not able to figure out the problem.

Please find the zip file. https://drive.google.com/open?id=12IpO3fh-8MfJnMTwHlz26vY7puy5biEg

I tried to copy the module and used in new installed magento but in front-end it displayed the drop down list but order is not getting completed.

enter image description here


This is screen shot of back end which is not Listing out the drop down list. When I tried place order from magento backed, it is not saving the "XYZ" selected value in Database.

Back end does't display drop down values


  1. my registration.php file at : \app\code\K2B\PickPay

    \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'K2B_PickPay', DIR );


  1. File Pickpay.php at : \app\code\K2B\PickPay\Block\Form

    <?php
    
    namespace K2B\PickPay\Block\Form;
    
    class Pickpay extends \Magento\Payment\Block\Form
    {
        /**
         * Checkmo template
         *
         * @var string
         */
        protected $_template = 'K2B_PickPay::form/pickpay.phtml';
    }
    
  2. File Pickpay.php at : \app\code\K2B\PickPay\Block\Info

       <?php
    namespace K2B\PickPay\Block\Info;
    
    class Pickpay extends \Magento\Payment\Block\Info
    {
        /**
         * @var string
         */
        protected $_template = 'K2B_PickPay::info/pickpay.phtml';
    
        /**
         * @return string
         */
        public function toPdf()
        {
            $this->setTemplate('K2B_PickPay::info/pdf/pickpay.phtml');
            return $this->toHtml();
        }
    }?>
    
  3. Model pickpay.php in \app\code\K2B\PickPay\Model

    '

    • Pay In Store payment method model */ class Pickpay extends \Magento\Payment\Model\Method\AbstractMethod { const PAYMENT_METHOD_PICKPAY_CODE = 'pickpay'; /**
      • Payment code *
      • @var string */ protected $_code = self::PAYMENT_METHOD_PICKPAY_CODE; /**
      • Availability option *
      • @var bool */ protected $_isOffline = true; /**
      • @var string */ protected $_formBlockType = 'K2B\PickPay\Block\Form\Pickpay'; /**
      • @var string */ protected $_infoBlockType = 'K2B\PickPay\Block\Info\Pickpay'; /**
      • Assign data to info model instance *
      • @param \Magento\Framework\DataObject|mixed $data
      • @return $this
      • @throws \Magento\Framework\Exception\LocalizedException / public function assignData(\Magento\Framework\DataObject $data) { $additionalData = $data->getData(PaymentInterface::KEY_ADDITIONAL_DATA); if (!is_object($additionalData)) { $additionalData = new DataObject($additionalData ?: []); }
        /
        $myfile = fopen("./var/log/pickpay.txt", "a");
        $txt = "getPickpayLocation:".$additionalData->getPickpayLocation();
        fwrite($myfile, "\n". $txt); fclose($myfile);*/ $this->getInfoInstance() ->setPickpayLocation($additionalData->getPickpayLocation()); return $this; } }'
  4. File UpgradeSchema.php in \app\code\K2B\PickPay\Setup

    namespace K2B\PickPay\Setup;

    use Magento\Framework\Setup\UpgradeSchemaInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\SchemaSetupInterface;

    class UpgradeSchema implements UpgradeSchemaInterface {
    /** * {@inheritdoc} */ public function upgrade( SchemaSetupInterface $setup, ModuleContextInterface $context ) { $installer = $setup;

        $installer->startSetup();       
        if (version_compare($context->getVersion(), '2.0.1', '<')) {          
          $installer->getConnection()->addColumn(
                $installer->getTable('quote_payment'),
                'pickpay_location',
                [
                    'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    'length' => 255,
                    'comment' => 'Pay and Pick Store Location'
                ]
            );
          $installer->getConnection()->addColumn(
                $installer->getTable('sales_order_payment'),
                'pickpay_location',
                [
                    'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
                    'length' => 255,
                    'comment' => 'Pay and Pick Store Location'
                ]
            );
        }
    
        $installer->endSetup();
    } }
    
  • Please let me know if you need more details. Thanks in advance. Sorry, i was not able to put the code in correct format. – JB Pakalapati May 9 '18 at 14:13
  • Please upload module zip then anyone can get more idea – Yogesh May 9 '18 at 14:14
  • any one got change to review ? – JB Pakalapati May 12 '18 at 3:22
  • As you said When i tried place order from magento backed, it is not saving the "XYZ" selected value in Database, that's mean the module is working on frontend? – Vinaya Maheshwari May 12 '18 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.