miit
miit

Reputation: 31

exception while creating order programmatically with payment method ccsave

I am new to magento. while creating order programmatically with payment method ccsave (for credit card payment) I got following exception:

exception 'Mage_Core_Exception' with message 'Incorrect credit card expiration date

may be I am wrong with credit card information or set data about credit card.

$quote->addProduct($product, new Varien_Object(10));
$addressData = array(
                     'firstname' => $data[2],

                     'lastname' => $data[3],
                     'street' => $data[4],
                     'city' => $data[6],
                     'postcode' =>$data[8],
                     'telephone' => $data[9],
                     'country_id' => 'US',
                     'region_id' => $data[7]
                );

$billingAddress = $quote->getBillingAddress()->addData($addressData);

$shippingAddress = $quote->getShippingAddress()->addData($addressData);

$payment= array(
    'cc_owner' => 'ffffffffff',
                'cc_type' => 'VI',
                'cc_number' => 1234567890123456,
                'cc_exp_month' => 11,
                'cc_exp_year' => 2015,
                'cc_cid' => 123
                );
$quote->getPayment()->addData($payment);
$quote->setPaymentData($payment);

$shippingAddress->setBaseShippingAmount(100);
$shippingAddress->setShippingMethod('customshippingrate');
$shippingAddress->setShippingDescription('abcd');
$quote->getPayment()->importData(array('method' => 'ccsave'));
$quote->collectTotals()->save();
Mage::app()->getStore()->setConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, "0"); 
$service = Mage::getModel('sales/service_quote', $quote);
$service->submitAll();

Upvotes: 2

Views: 3188

Answers (1)

miit
miit

Reputation: 31

I changed code to and I have solved problem of exception 'Mage_Core_Exception' with message 'Incorrect credit card expiration date'

$billingAddress = $quote->getBillingAddress()->addData($addressData);

$shippingAddress = $quote->getShippingAddress()->addData($addressData);

$quote->getPayment()->importData(array('method' => 'ccsave',

                'cc_owner' => 'ffffffffff',
                'cc_type' => 'VI',
                'cc_number' => "1234567890123456",
                'cc_exp_month' => 11,
                'cc_exp_year' => 2015,
                'cc_cid' => 123));
$quote->collectTotals()->save();

Mage::app()->getStore()->setConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_ENABLED, "0"); 

$service = Mage::getModel('sales/service_quote', $quote);

Upvotes: 1

Related Questions