0

Where do I find the valid parameter for setPaymentMethod()?

$quote = Mage::getModel('sales/quote');
$quote->setPaymentMethod('adyen_hpp');

setPaymentMethod('checkmo') did work find but I disabled this option and replaced it with the adyen module. Where do I find the correct parameter now?

I tried adyen_hpp because of

class Madia_Adyen_Model_Adyen_Hpp extends Madia_Adyen_Model_Adyen_Abstract {

    protected $_code = 'adyen_hpp';

Also there is a config.xml that might be involved?

<default>
    <payment>
        <adyen_hpp>
            <customer_id backend_model="adminhtml/system_config_backend_encrypted"/>
            <currency>EUR</currency>
            <model>adyen/adyen_hpp</model>
            <title>Adyen HPP</title>
            <logofilename></logofilename>
            <secret_wordt></secret_wordt>
            <secret_wordp></secret_wordp>
            <delivery_days>14</delivery_days>
            <ws_username_test></ws_username_test>
            <ws_password_test></ws_password_test>
            <ws_username_live></ws_username_live>
            <ws_password_live></ws_password_live>
            <order_status>processing</order_status>
            <payment_pending>pending</payment_pending>
            <payment_authorized>processing</payment_authorized>
            <allowspecific>0</allowspecific>
            <disable_hpptypes>0</disable_hpptypes>
        </adyen_hpp>
2
  • What type is the object you called setPaymentMethod on?
    – Marius
    Sep 16, 2013 at 13:40
  • @Marius on sales/quote I added object creation. I am generation an order based on this. Sep 16, 2013 at 13:45

2 Answers 2

0

Based on what I found int Mage_Checkout_Model_Type_Onepage::savePayment:

    if ($quote->isVirtual()) {
        $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
    } else {
        $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
    }

I can conclude that the setPaymentMethod call should be made to an address object (shipping or billing if the order is virtual). The value of the parameter should be the payment method code (just like you suspected). Maybe it doesn't work because you are calling it directly on the quote.


Edit by OP

The above is correct and actually I was calling setPaymentMethod() at $quote->getShippingAddress() just missed it:

$quote->getShippingAddress()
    ->addData($billingAddress)
    ->setShippingMethod('flatrate_flatrate')
    ->setPaymentMethod('adyen_hpp')
    ->setCollectShippingRates(true)
    ->collectTotals();

Problem was that I needed to change payment method here to:

 $quote->getPayment()->importData( array('method' => 'adyen_hpp'));

Now it's still not working because of a new error but that is another problem.

0

Generally the setPaymentMethod() depends on the address object of shipping or billing method.

As you are using directly quote object is wrong method. First of all, get the Shipping Address by using quote and assign it to the address object.

$session = Mage::getSingleton('checkout/session');
$quote = $session->getQuote();
$address = $quote->getShippingAddress();
$address->setShippingMethod('freeshipping_freeshipping');

Hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.