1

I am using magento api and i want to retrieve all payment methods which are enabled. When i am using cart_payment.list API, it's giving me only one method for quote id but in my back end there are four enabled methods. How can i get all payment methods?

  • Not all payment methods are available for each quote. I would suggest the best way to debug what is going on is to recreate the quote you send via the api in the shop to see what methods can be accessed. – David Manners Nov 20 '14 at 8:37
1

magento provide List of payment according to it quote item and business logic.AS you said all four payment is not coming that means

There are setting issue in admin
There are some business logic behind it

If you want to list of payment method then get all store payment from store config using below code:This code only provide current store active payment.

   Mage::getModel('payment/config')->getActiveMethods($storeId=null);

If want to store wise check then put store id

But want list of all payment then try this

 Mage::getModel('payment/config')->getAllMethods($storeid=null).

let me know if any issue.

  • thanks for replying. but i want solution in soap v1. i am making api for android app and i am using magento api v1 for making this app. that's why i need solution in only soap v1. if you can help me then it would be great. thank u once agiain. – Lokesh Jain Sep 16 '14 at 12:55
  • are you want list payment using api v1? which will comes not depends on quote? – Amit Bera Sep 16 '14 at 12:58
  • if want to checkout using this payment then you need quote object. – Amit Bera Sep 16 '14 at 13:04
  • actually i want to set payment method using "cart_payment.method" and it only accepts what "cart_payment.list" gives. "cart_payment.method" is not allowing other payment methods. it's giving fetal error. i have quote id if u are asking about it. – Lokesh Jain Sep 16 '14 at 13:04
  • 2
    cart_payment.list give list of payment basis of current Quote object object. You could not add any other payment methods accept cart_payment.list give list. It is magento methodology. – Amit Bera Sep 16 '14 at 13:08
1

When using the Magento API, not all payment methods that are enabled for your store are returned when calling cart_payment.list.

For example, payment methods that redirect the user to an external gateway (e.g. Paypal), cannot function with an API client and are therefore excluded, for obvious reasons.

If you have built your own custom payment method and you want to make it available in your API client, you should set $_canUseInternal = true; in your payment method model.

To understand how Magento decides if a particular payment method is available or not, take a look at app/code/core/Mage/Checkout/Model/Cart/Payment/Api.php:

protected function _canUsePaymentMethod($method, $quote)
{   
    if (!($method->isGateway() || $method->canUseInternal())) {
        return false;
    }

    if (!$method->canUseForCountry($quote->getBillingAddress()->getCountry())) {
        return false;
    }

    if (!$method->canUseForCurrency(Mage::app()->getStore($quote->getStoreId())->getBaseCurrencyCode())) {
        return false;
    }

    /**
     * Checking for min/max order total for assigned payment method
     */
    $total = $quote->getBaseGrandTotal();
    $minTotal = $method->getConfigData('min_order_total');
    $maxTotal = $method->getConfigData('max_order_total');

    if ((!empty($minTotal) && ($total < $minTotal)) || (!empty($maxTotal) && ($total > $maxTotal))) {
        return false;
    }

    return true;
}

So for example the free payment method (Zero Subtotal Checkout) is only available if the order total is zero.

1

Try this

<?php

class Excellence_Paymentfee_Model_Active_Payment

{
public function toOptionArray()

  {

$payments = Mage::getSingleton('payment/config')->getActiveMethods();

$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));

foreach ($payments as $paymentCode=>$paymentModel) {

$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');

$methods[$paymentCode] = array(

'label' => $paymentTitle,
'value' => $paymentCode,
);
}
return $methods;
}
}
1

You can get all default Magento payment methods by this code

$allPaymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();

or if you need only active methods

$allActivePaymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();

But if you have some custom module with oher payment methods they not will be there. In this case you need some function to get additional payments

function getAdditionalActivePayments() {
  $methods = array();
  $config = Mage::getStoreConfig('custopayments_custopayments');
  foreach ($config as $code => $methodConfig) {
    if (Mage::getStoreConfigFlag('custopayments_custopayments/' . $code . '/active')) {
      $methods[$code] = $methodConfig['title'];
     // or var_dump it to see what data it has
    }
  }
  return $methods;
}

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.