问题描述
我正在使用magento api,创建订单时遇到了一些问题.我已经能够完成创建订单以正常工作的一切.我看到的问题是,当我调用创建订单的方法时,总是得到异常:Credit card number mismatch with credit card type.
I am working with the magento api and I have run into a bit of an issue with creating an order. I have been able to get everything up to creating the order to work correctly. The issue that I am seeing is when I call the method to create the order I always get the exception: Credit card number mismatch with credit card type.
我正在运行Magento版本. 1.6.2.0
I am running Magento ver. 1.6.2.0
我已经验证了我正在测试的卡是否可以通过magento前端工作.
I have verified that the card I am testing with works via the magento frontend.
在此方面的任何帮助都将不胜感激.
Any help with this is greatly appreciated.
这是我正在使用的测试代码:
This is the test code that I am using:
<?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" => "[email protected]",
//"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的调用已成功,因此,抄送号码正按预期验证为MC卡.
Your call to cart_payment.method is succeeding, according to your post, so the CC number is validating to be a MC card, as expected.
问题在于,由于PCI问题,Magento不会在数据库中保存抄送号码(在大多数情况下).
The problem is that Magento, due to PCI concerns, does NOT save the CC number in the database (in most cases).
因此,当您在一个请求中发送付款明细以及CC号和CID,然后在另一个请求中创建订单时,状态会丢失,并且CC号和CID会被清空.
So, as you are sending payment details, along with CC number and CID, in one request and then creating the order in another, the state is lost and the CC number and CID are blanked out.
创建订单后,付款数据将再次进行验证,当付款数据发生时,它会有一个带有MC类型的空CC编号,从而导致您看到错误.
When the order is created, the payment data is validated a second time and when that happens, it has an empty CC number with a type of MC, causing the fault you see.
不幸的是,我没有一种使cart.order接受付款数据的方法.
Unfortunately, I do not see a way to make cart.order accept payment data as a work around.
您可以编写一个模块,以使用新方法扩展结帐API的新方法,该方法可以在一个调用中完成两个步骤,并且很可能会解决问题.
You could write a module to extend the checkout APIs with a new method that does both steps in a single call and that would likely solve the problem.
这篇关于Magento信用卡号与信用卡类型异常不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!