Jump to content

How to get a list of the available payment method ?


lem__mel
 Share

Recommended Posts

Hi !

I'm currently coding an application that allows to create order by using the webservice API.

For statistical purposes I need to have the correct payment method registered, but if I assume that payment and module elements allows to specify the payment, I don't know how to list all the payment methods available.

 

Have someone an idea about how to get the payments available ?

 

P.S. : the use of the API call 

/api/orders/?display=full&schema=blank

list all of fields of an order (here I see that there is payment and module elements),

and when I go see the details about webservice permission management, I see nothing of interest (order_payments allows to know what payment was used for a given order).

 

Share this post


Link to post
Share on other sites

  • 1 year later...
  • 3 months later...

you can get list of modules, that handles payment methods
f.e. this way:
 

SELECT m.*, group_concat(iso_code) as currencies  FROM `ps_hook_module` h

join ps_module m on m.id_module=h.id_module
join ps_module_currency mc on mc.id_module=m.id_module
join ps_currency c on c.id_currency=mc.id_currency

WHERE `id_hook` in (select id_hook from ps_hook where name = 'paymentOptions') and m.active=1
group by m.id_module

or you can get the list (include paymentMethod name) :
 

$payment_methods = array();
        foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
            $module = Module::getInstanceByName($payment['name']);
            if (Validate::isLoadedObject($module) && $module->active) {
                $payment_methods[] = $module->displayName;
            }
        }

or you can combine both codes above to get list of { NameOfModule + its PaymentMethods + its allowed currencies }

Share this post


Link to post
Share on other sites

  • 3 weeks later...
On 7/17/2020 at 10:50 AM, EvaF said:

you can get list of modules, that handles payment methods
f.e. this way:
 

SELECT m.*, group_concat(iso_code) as currencies  FROM `ps_hook_module` h

join ps_module m on m.id_module=h.id_module
join ps_module_currency mc on mc.id_module=m.id_module
join ps_currency c on c.id_currency=mc.id_currency

WHERE `id_hook` in (select id_hook from ps_hook where name = 'paymentOptions') and m.active=1
group by m.id_module

or you can get the list (include paymentMethod name) :
 

$payment_methods = array();
        foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
            $module = Module::getInstanceByName($payment['name']);
            if (Validate::isLoadedObject($module) && $module->active) {
                $payment_methods[] = $module->displayName;
            }
        }

or you can combine both codes above to get list of { NameOfModule + its PaymentMethods + its allowed currencies }

I'm building an APP and I need to have the list of payment methods for the cart checkout phase.

I am using the prestashop webservice but cannot find the method related to the payment list.

Can u help me?

thanks

Share this post


Link to post
Share on other sites

  • 5 months later...
On 8/3/2020 at 9:49 AM, maicol.cantagallo said:

I'm building an APP and I need to have the list of payment methods for the cart checkout phase.

I am using the prestashop webservice but cannot find the method related to the payment list.

Can u help me?

thanks

Hi maicol.cantagallo.

I am developing something similar.

It seems that there is no API for the list of payment methods.

From PaymentModule::getInstalledPaymentModules() I got the information (Prestashop 1.7.3):

SELECT
    DISTINCT m.`id_module`,
    h.`id_hook`,
    m.`name`,
    hm.`position`
FROM `ps_module` m
LEFT JOIN `ps_hook_module` hm ON hm.`id_module` = m.`id_module`    AND hm.id_shop IN (1)
LEFT JOIN `ps_hook` h ON hm.`id_hook` = h.`id_hook`
INNER JOIN `ps_module_shop` ms ON (m.`id_module` = ms.`id_module`AND ms.id_shop = 1) -- Enable / disable module
WHERE h.`name` = 'paymentOptions'
;

I hope you find this information useful.

 

Share this post


Link to post
Share on other sites

12 hours ago, Endrigo said:

Hi maicol.cantagallo.

I am developing something similar.

It seems that there is no API for the list of payment methods.

From PaymentModule::getInstalledPaymentModules() I got the information (Prestashop 1.7.3):

SELECT
    DISTINCT m.`id_module`,
    h.`id_hook`,
    m.`name`,
    hm.`position`
FROM `ps_module` m
LEFT JOIN `ps_hook_module` hm ON hm.`id_module` = m.`id_module`    AND hm.id_shop IN (1)
LEFT JOIN `ps_hook` h ON hm.`id_hook` = h.`id_hook`
INNER JOIN `ps_module_shop` ms ON (m.`id_module` = ms.`id_module`AND ms.id_shop = 1) -- Enable / disable module
WHERE h.`name` = 'paymentOptions'
;

I hope you find this information useful.

 

Hi Endrigo,

thanks for reply. yes i used this solution but it is not the best. How can I manage payments from the payplug module? or paypal module?

thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More