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

发布于 2024-11-06 12:49:06 字数 1649 浏览 0 评论 0原文

我是 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();

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

铁憨憨 2024-11-13 12:49:06

我将代码更改为,并解决了异常“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);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文