Closed rikterbeek closed 8 years ago
Hi @rikterbeek, look at https://github.com/magento/magento2/blob/develop/app/code/Magento/Vault/Model/Method/Vault.php, for instance. You must not extend AbstractMethod class in your own payment method but just implement Magento\Payment\Model\MethodInterface
interface.
Note that https://github.com/magento/magento2/blob/develop/app/code/Magento/Payment/Model/Method/Cc.php#L15 class is deprecated as well.
Hi @orlangur,
Thanks for this information. It is not totally clear now how to implement a payment method in the new structure do you have any technical documentation available about adding a payment method in the new way ?
Regards, Rik Adyen
Hi @rikterbeek, the dev documentation in a process, but you can use https://github.com/magento/magento2-samples/tree/master/sample-module-payment-gateway as an example. Also, a current version of Braintree is implemented in a new way.
Hi @joni-jones ,
The latest commit in https://github.com/magento/magento2-samples/tree/master/sample-module-payment-gateway is 3 months ago. Both master and 2.1 branch. Actually 2.1 is even with master for now. Will this sample work in 2.1.0???
My client want payment extension support both 2.0.x and 2.x? Is this possible??? I have seen a lot of bug relate to checkout since 2.0.7 to 2.1.0 for now. Some of them are fixed but they are fixed in new patch only.
Hi @hungpvdev, yes, it still should works. According to a second question, it depends on your implementation. If it will work with 2.0.7 it also should work with 2.1, but, really, before 2.1 release, were fixed a lot of bugs for checkout module also.
i think the Magento API is supposed to ease the development of a new Patment Module but the complete lack of documentation, comments in the code, and any kind of explanation on how the flow works or is intended to work, make the operation a lot harder. This is my humble opinion: its could be the one of a noob Magento developer but believe me its not so verbose
While https://github.com/magento/magento2-samples/tree/master/sample-module-payment-gateway Integrating With cc-form.js , On Credit Card From Year And Month Is Not Listing. Is That An Issue ?
Totally agree here - trying to develop a new payment method and it's not very clear
@rahulvramesh this isn't an issue. Some integrations don't have these fields, for example, Braintree PayPal.
I think magento should improve its documentation, adding a new payment method seems so obvious, dummy and common to implement all over the world but it is so complicated to achieve with the lack of information on it, and what it is worse the lack of info available is not clear at all.
@mariohosmar did you try to use Braintree implementation for reference?
From https://github.com/magento/magento2/issues/7420 it does not look that hard. While not every significant topic is covered in documentation yet there are quite a lot of blog posts in the Web also.
Hi @orlangur @mariohosmar
Have a look at our solution we support many payment methods and implemented against the latest specs of magento2. See https://github.com/adyen/adyen-magento2
Regards, Rik Adyen
Use \Magento\Payment\Model\Method\Adapter
as a base instead of deprecated \Magento\Payment\Model\Method\AbstractMethod
Does this new approach to adding Payment Methods apply to Offline Payment Methods, such as one similar to Purchase Order?
I ask because I've gotten pretty far down the line using the deprecated approach which shows my payment method in the checkout, but after converting it over to the Adapter approach the method no longer shows in checkout.
@floorz new approach should be preferable for both online/offline methods.
after converting it over to the Adapter approach the method no longer shows in checkout
This needs to be tracked down to an exact issue with debugger.
@flancer64 the Adapter seems to not be the right replacement in every caseMagento\Payment\Model\MethodInterface
is. Indeed \Magento\Payment\Model\Method\Adapter
forces one to set a gateway command Pool. It would be nice if @orlangur could confirm this... Also the deprecated AbstractMethod seems to be still predominately present in magento code base so i assume, we still have some months/year before this is definitely gone?
Edit
It seems that one can use \Magento\Payment\Model\Method\Adapter
and through config.xml disable command as follow <can_capture>0</can_capture>
the command execution is still called but the code will exit at
https://github.com/magento/magento2/blob/4dfb6da5408199bf1323fde699af049e1fc99668/app/code/Magento/Payment/Model/Method/Adapter.php#L528
if (!$this->canPerformCommand($commandCode)) {
return null;
}
Does this new approach to adding Payment Methods apply to Offline Payment Methods, such as one similar to Purchase Order?
I ask because I've gotten pretty far down the line using the deprecated approach which shows my payment method in the checkout, but after converting it over to the Adapter approach the method no longer shows in checkout.
@floorz Can you please share how you converted the offline payment method to use the Adapter class?
Does this new approach to adding Payment Methods apply to Offline Payment Methods, such as one similar to Purchase Order? I ask because I've gotten pretty far down the line using the deprecated approach which shows my payment method in the checkout, but after converting it over to the Adapter approach the method no longer shows in checkout.
@floorz Can you please share how you converted the offline payment method to use the Adapter class?
@mmihalev - I just had to go through this, I had to implement the Facade, including the Command and Config pool, I just emptied out the Command pool in di.xml and did this implementation of the getConfig method in the ConfigProviderInterface:
return [
'payment' => [ self::CODE => [] ]
];
Another key was these config values:
<can_capture>0</can_capture>
<can_use_checkout>1</can_use_checkout>
<is_gateway>0</is_gateway>
Hope that helps.
Hi,
I see that the class AbstractMethod in Magento\Payment\Model\Method is going to be deprecated but it is used for all payment methods. This class is even used by native Magento core in Magento\Payment\Model\Method\Cc. What class do you need to use instead ?
Regards, Rik Adyen