1

I have a custom payment gateway that pass additional payment information back upon the return to Magento store that I would like to store on the associated order, so that it can be displayed on the admin page, similarly to what Paypal Express Checkout offer as shown below. What would be the best practice to do this (I prefer have it done within a controller action that handle the return).

enter image description here

2

A quick reference:

Take a look the sales order view xml:

vendor/magento/module-sales/view/adminhtml/layout/sales_order_view.xml

<block class="Magento\Sales\Block\Adminhtml\Order\Payment" name="order_payment"/>

As we can see, Magento\Sales\Block\Adminhtml\Order\Payment block will handle the payment output. It will get the payment info block:

vendor/magento/module-sales/Block/Adminhtml/Order/Payment.php

$paymentInfoBlock = $this->_paymentData->getInfoBlock($payment, $this->getLayout());

In Paypal case, the block info is vendor/magento/module-paypal/Block/Payment/Info.php. Paypal module built the model info to collect and provide access to PayPal-specific payment data: vendor/magento/module-paypal/Model/Info.php

SUMMARY:

--Create the model info.
--Create the block info to get the info from the model info.

  • Thank you for the replying. My 2nd part of question is how do we create the object equivalent of vendor/magento/module-paypal/Model/Info.php and then store it into the order? Let's say if I have Info.php for my custom module. Is there a function from Order, Quote, or Transaction object that I need to call to attach this info model for display later? – frostshoxx Sep 16 '16 at 16:29
  • @frostshoxx we create your own info block and info model, and then inject the info model on the constructor of info block. You should see more here: vendor/magento/module-paypal/Block/Payment/Info.php. – Khoa TruongDinh Sep 20 '16 at 14:48
  • It seems to me that the class Info is an extension of \Magento\Payment\Block\Info\Cc. Is it still applicable if the payment gateway I'm using does not use credit card? – frostshoxx Sep 20 '16 at 17:41
  • I'm not test yet, however, I think it is ok. – Khoa TruongDinh Sep 21 '16 at 2:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.