php - Magento 信用卡号码与信用卡类型异常不匹配

标签 php magento

我正在使用 magento api,但在创建订单时遇到了一些问题。我已经能够完成创建订单以正常工作的一切。我遇到的问题是,当我调用创建订单的方法时,我总是遇到异常:Credit card number mismatch with credit card type.

我正在运行 Magento 版本。 1.6.2.0

我已经验证我正在测试的卡可以通过 magento 前端工作。

非常感谢对此的任何帮助。

这是我正在使用的测试代码:

<?php
$proxy = new SoapClient('http://localhost/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('shopapi', 'test123');

// Create a quote, get quote identifier
$shoppingCartId = $proxy->call( $sessionId, 'cart.create');

// Set customer, for example guest
$customerAsGuest = array(
    "firstname" => "testFirstname",
    "lastname" => "testLastName",
    "email" => "test@test.com",
    //"website_id" => "0",
    //"store_id" => "0",
    "mode" => "guest"
);
$resultCustomerSet = $proxy->call($sessionId, 'cart_customer.set', array( $shoppingCartId, $customerAsGuest) );

// Set customer addresses, for example guest's addresses
$arrAddresses = array(
    array(
        "mode" => "shipping",
        "firstname" => "testFirstname",
        "lastname" => "testLastname",
        "company" => "testCompany",
        "street" => "testStreet",
        "city" => "testCity",
        "region" => "CA",
        "postcode" => "90049",
        "country_id" => "US",
        "telephone" => "0123456789",
        "fax" => "0123456789",
        "is_default_shipping" => 0,
        "is_default_billing" => 0
    ),
    array(
        "mode" => "billing",
        "firstname" => "testFirstname",
        "lastname" => "testLastname",
        "company" => "testCompany",
        "street" => "testStreet",
        "city" => "testCity",
        "region" => "CA",
        "postcode" => "90049",
        "country_id" => "US",
        "telephone" => "0123456789",
        "fax" => "0123456789",
        "is_default_shipping" => 0,
        "is_default_billing" => 0
    )
);
$resultCustomerAddresses = $proxy->call($sessionId, "cart_customer.addresses", array($shoppingCartId, $arrAddresses));

// add products into shopping cart
$arrProducts = array(
    array(
        "product_id" => "1",
        "qty" => 1
    )
);
$resultCartProductAdd = $proxy->call($sessionId, "cart_product.add", array($shoppingCartId, $arrProducts));


// get list of products
$shoppingCartProducts = $proxy->call($sessionId, "cart_product.list", array($shoppingCartId));


// set payment method
$paymentMethod = array(
    "method" => "authorizenet",
    "cc_type" => 'MC',
    "cc_number" =>'5555555555554444' ,
    "cc_exp_month" => 9,
    "cc_exp_year" => 2014,
    "cc_cid" => 123     
);
$resultPaymentMethod = $proxy->call($sessionId, "cart_payment.method", array($shoppingCartId, $paymentMethod));


// create order
$resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId));
var_dump($resultOrderCreation);
 ?>

最佳答案

根据您的帖子,您对 cart_payment.method 的调用是成功的,因此 CC 号码正在验证为 MC 卡,正如预期的那样。

问题是,由于 PCI 问题,Magento 不会将 CC 编号保存在数据库中(在大多数情况下)。

因此,当您在一个请求中发送付款详细信息以及 CC 编号和 CID,然后在另一个请求中创建订单时,状态丢失并且 CC 编号和 CID 被清空。

当订单创建时,支付数据会被第二次验证,当发生这种情况时,它有一个空的 CC 编号和 MC 类型,导致您看到的错误。

不幸的是,我没有找到让 cart.order 接受支付数据的方法。

您可以编写一个模块来使用一种新方法扩展结帐 API,该方法可以在一次调用中完成这两个步骤,这很可能会解决问题。

关于php - Magento 信用卡号码与信用卡类型异常不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10136966/

相关文章:

php - jquery:你可以在$(window).unload()中执行ajax请求吗?

php - 队列 Redis 不会在 Laravel Forge 上被触发

magento - 将链接 rel 添加到 Magento 的头部

magento - magento 中的多个主页在单个安装和单个商店和单个 storeview 中

php - 如何在查询中使用数组中的数据

php - 选择半径内的点

php - 如果 true 使用 foreach 循环,否则使用 while

c# - 如何使用 SOAP V2 为 Magento 设置自定义 api?

php - 如何编辑Magento的API函数 "items()"获取商品的ImageUrl

css - 如何向自定义 magento 主题添加新字体?