使用付款方式ccsave以编程方式创建订单时出现异常

时间:2011-05-11 07:17:45

标签: php magento

我是magento的新手。 使用付款方式ccsave以编程方式创建订单(用于信用卡付款) 我有以下例外:

  

异常'Mage_Core_Exception',消息'信用卡到期日不正确

可能是我错误的信用卡信息或设置有关信用卡的数据。

$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();

1 个答案:

答案 0 :(得分:1)

我更改了代码,并解决了“Mage_Core_Exception”异常的问题,并显示“信用卡到期日不正确”信息

$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);