cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Payment Extension

SOLVED

Custom Payment Extension

Firstly, I am new in the Magento extensions development process. Currently, I am developing a custom payment gateway for Magento2. As I tried to copy almost everything from this project I got it working. It shows in the Stores/Configuration/Sales/Payment Methods and can set fields, etc. When I log in as a customer and proceed to checkout the custom payment method is not shown. There is no error in the browser console. I would really appreciate it if you could tell me what could be wrong (something related to the view folder or with the business logic) or send me another project/tutorial which I can follow and get a working example. Also, the gateway has to redirect the customer to external URL - how I can add webhook for this (the external payment system will send information about the order to a specific endpoint and I have to handle it somehow). Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Custom Payment Extension

Hello @emil_kostadinov

 

I don't know why need dyanamic url

 

https://github.com/Instamojo/instamojo-magento-2/

 

check above code for same.

 

If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

14 REPLIES 14

Re: Custom Payment Extension

Hello @emil_kostadinov

 

In your issue, you mention it is not showing for only login user is that right?

 

Can you please check URL for reference

https://www.mageplaza.com/magento-2-create-payment-method/ 

https://webkul.com/blog/redirect-to-third-party-link-after-order-place-magento2/

 

Second link for how to redirect to the payment page.

 

If it will help you then mark as solution.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Custom Payment Extension

Thanks for the links! Will inform you when there is some result. I doesn't appear as a payment method on the checkout page (not logged in/logged user - both).

Re: Custom Payment Extension

Hello @emil_kostadinov

 

It will help you, if you have any issue then message into forums.

 

If it will work then mark as solution.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Custom Payment Extension

Just followed the first tutorial but when try to load the checkout page I got this exception:

Exception #0 (Magento\Framework\Exception\LocalizedException): We cannot retrieve the payment method code.

Re: Custom Payment Extension

Hello @emil_kostadinov

Please check with fresh window.


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Custom Payment Extension

The tutorial was for version 2.0.x but I got 2.2.x. So I copied the code from the repository and now it works! Thanks a lot! Then, changed some of the code to adapt to my custom external payment API but can't find any information how I can pass the redirect URL to the view. In the second link you sent it's a static URL but I the redirect URL is different for each order. Any ideas?

Re: Custom Payment Extension

Hello @emil_kostadinov

 

I don't know why need dyanamic url

 

https://github.com/Instamojo/instamojo-magento-2/

 

check above code for same.

 

If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

Re: Custom Payment Extension

Thanks again for that repository! As I can see afterPlaceOrder function redirects to instamojo/redirect but Controller/Redirect doesn't handle anything (maybe I miss something). Please correct me if I am wrong - the flow is when the order is placed it will redirect to some route which will check the order payment details, etc. and then redirect the user to the payment provider URL. After that, another route will handle the response from the payment provider and redirect the user to the specific order page?

Re: Custom Payment Extension

Hello @emil_kostadinov

 

yes you are right.

 

If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer