Displaying the credit card payment form on an account page

Hi everyone, I’m having a bit of trouble getting this situated and was hoping someone might be able to help shed some light on this for me.

I’m working on a project right now and I need to finish a custom page in the account section that allows a user to pay an outstanding invoice. In our Magento 1 installation, someone who previously worked on the site was able to get the credit card form to display by declaring a block that inherits from Mage_Checkout_Block_Onepage_Payment_Methods and having Magento pull in the proper template. I was hoping there might be an equivalent class in Magento 2 but it doesn’t seem that there is one.

However, I know this functionality exists somewhere, but for the life of me I can’t find a solution that works. All of the posts on StackOverflow and other forums are about creating a new payment method and deal with integrating that on the checkout page. I’ve tried pulling out various pieces and copying the implementation that some of these modules do, and encountered a few different errors, like:

  • Issues with Knockout not being able to see my method renderer object (undefined function errors, etc.) when trying to include the cc-form.phtml template
  • Blocks like MagentoPaymentBlockFormContainer and MagentoPaymentBlockFormCc missing dependencies and being unable to do certain things due to incomplete state
  • Exceptions arising from my attempts at satisfying some of these missing dependencies e.g. trying to inject a MethodInterface through the layout XML failing because it doesn’t implement ArgumentInterface

I’m not sure where to turn next because I feel like I’ve been spinning my wheels with this for a while now. I might be able to just write our own template and be done with it, but I’m not sure how well it’s going to play with the backend logic in that scenario. The controller for the endpoint I’ll be requesting is mostly custom logic, but it does rely on a MethodInterface instance at some point to capture the funds, and I’m unsure whether Magento populates the payment method form with any special values that I’d need to recreate. For that reason I’m really hoping I can incorporate the default form, somehow.

Do any of you have experience with this, or understand how that part of the framework works well enough to give me an idea of how I could get started with something like this?

submitted by /u/parks_canada
[link] [comments]