English 中文(简体)
信用卡号码与信用卡类型例外不符
原标题:Magento Credit card number mismatch with credit card type exception
  • 时间:2012-04-13 07:40:51
  •  标签:
  • php
  • magento

我正在与Magento Api合作,我已经陷入了建立命令的问题。 我能够尽一切可能建立正确工作的秩序。 我所看到的问题是,当我称之为创建命令的方法时,我总是例外:Credit卡号与信用卡类型不符。

我正在跑Magento ver。 1.6.2.0

我已经核实,我正在通过Magento frontend对卡进行测试。

非常赞赏这方面的任何帮助。

这是我使用的测试法:

<?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);
 ?>
最佳回答

你呼吁支付。 根据您的职位,这一方法正在取得成功,因此,按预期,CCC号码是作为MC卡的。

问题在于,Magento公司由于PCI的关切,在数据库中(大多数情况下)没有中央数据。

因此,正如你在发出付款细节时,以及在一次请求中发出CCC编号和CID,然后在另一个请求中发出命令,国家就失去了,而CCC编号和CID被搁置。

当订单设定时,付款数据第二次验证,一旦发生,它就有一个空洞的CCC号码,有类型的MC,造成你发现的过错。

不幸的是,我看不出一种办法,使顺序接受付款数据为工作。

你可以撰写一个模块,以扩大检查结果,采用一种新方法,既采取单一呼吁的步骤,又有可能解决问题。

问题回答

我也谈到这一问题。 我的解决方案是建立一个习惯性的SOAP终端点,它一度处理所有订单的设定和提交逻辑,而不需要多个APIC电话。

即便如此,我也正在获得卡片类不匹配的例外。

当我确定付款信息、收集总额和免报价时,该骗局即采用进口Data方法,似乎忘记了该卡的胎儿。 值得注意的是(不是最佳处理方式)遵守PCI-DSS。

为了解决该问题,我补充说,另一个是Payment->import。 在提交命令之前,在保留报价后的数据线。

在不改变任何核心档案的情况下实现这一点。

例如:

public function customCheckout($checkoutData=false)
  {
    if(!$checkoutData){
      Mage::throwException("No checkout data received.");
    }
    if(!json_decode($checkoutData)){
      Mage::throwException("Bad checkout data received.");
    }

    $data = json_decode($checkoutData);

    $email =  [email protected] ;

    // get the basic store info to associate with order
    $websiteId  = Mage::app()->getWebsite()->getId();
    $store      = Mage::app()->getStore();

    // begin checkout with a quote
    $quote    = Mage::getModel( sales/quote )->setStoreId($store->getId());

    // set customer by email
    $customer = Mage::getModel( customer/customer )
                  ->setWebsiteId($websiteId)
                  ->loadByEmail($email);

    // handle customer not exists by creating a new customer
    if($customer->getId() ==   ){
      $customer = Mage::getModel( customer/customer );
      $customer->setWebsiteId($websiteId)
               ->setStore($store)
               ->setFirstName("Bob")
               ->setLastName("Loblaw")
               ->setEmail($email)
               ->setPassword( password );
      $customer->save();
    }

    // assign customer to SO quote
    $quote->assignCustomer($customer);

    // do we want to send a confirmation email to the customer?
    // my guess is we would handle that in a separate service.
    $quote->setSendConfirmation(0);

    // add products to quote
    foreach($data->products as $item){
      $product = Mage::getModel( catalog/product )->load($item->id);
      $quote->addProduct($product,new Varien_Object(array( qty =>$item->qty)));
    }

    // set SO billing address
    $billingAddress = $quote->getBillingAddress()->addData(array(
       customer_address_id  =>   ,
       prefix  =>   ,
       firstname  => $data->customer->firstName,
       middlename  =>   ,
       lastname  => $data->customer->lastName,
       suffix  =>   ,
       company  =>   ,
       street  => array(
         0  =>  street1 ,
         1  =>  street2 
      ),
       city => city ,
       country_id => US ,
       region => WA ,
       postcode => 98101 ,
       telephone  =>  425-425-4254 ,
       fax  =>  789-789-7897 ,
       vat_id  =>   ,
       save_in_address_book  => 0
    ));

    // set SO shipping address, this will probably be the location of sale, on-site
    $shippingAddress = $quote->getShippingAddress()->addData(array(
       customer_address_id  =>   ,
       prefix  =>   ,
       firstname  => $data->customer->firstName,
       middlename  =>  middle ,
       lastname  => $data->customer->lastName,
       suffix  =>   ,
       company  =>   ,
       street  => array(
         0  =>  street1 ,
         1  =>  street2 
      ),
       city => city ,
       country_id => US ,
       region => WA ,
       postcode => 98201 ,
       telephone  =>  425-425-4254 ,
       fax  =>  789-789-7897 ,
       vat_id  =>   ,
       save_in_address_book  => 0
    ));

    // set shipping method, if it s sold on site we aren t charging for delivery
    $shipMethod= freeshipping_freeshipping ;

    $shippingAddress->setCollectShippingRates(true)
                    ->collectShippingRates()
                    ->setShippingMethod($shipMethod)
                    ->setPaymentMethod($data->payment->method);

    // set payment method
    $quote->getPayment()->importData(array(
       method       =>$data->payment->method,
       cc_type      =>$data->payment->type,
       cc_number    =>$data->payment->number,
       cc_exp_year  =>$data->payment->expYear,
       cc_exp_month =>$data->payment->expMonth,
    ));

    // collect totals, save quote
    $quote->collectTotals()->save();

    // turn the quote into an order
    $service = Mage::getModel( sales/service_quote ,$quote);

    // set payment method A SECOND TIME!!!!!!!!!!!!!
    $quote->getPayment()->importData(array(
       method       =>$data->payment->method,
       cc_type      =>$data->payment->type,
       cc_number    =>$data->payment->number,
       cc_exp_year  =>$data->payment->expYear,
       cc_exp_month =>$data->payment->expMonth,
    ));

    $service->submitAll();
    $increment_id = $service->getOrder()->getRealOrderId();

    $quote = $customer = $service = null;

    $retval = new stdClass;
    $retval->orderId = $increment_id;

    return json_encode($retval);
  }

我从未对付款法文本(authorizenet)进行过成功的APIC交易。 这总是通过前线成功,而不是确定原因,我也没有时间调查原因。 虽然我一直这样做的是使用<代码>授权网-直接<>/代码>员额。 我在此背后的推理/我如何对此 st淡,这就是说,这也适用于佩帕尔付款方法。 仅凭<代码>付费/直接-burpaluk_direct。 !! 它应当发挥作用。 至少,这为我工作。

$paymentMethod = array(
    "method" => "authorizenet_directpost",
    "cc_type" =>  MC ,
    "cc_number" => 5555555555554444  ,
    "cc_exp_month" => 9,
    "cc_exp_year" => 2014,
    "cc_cid" => 123     
);

实际上,我刚刚找到了通过APICA获得授权的途径。

首先,在应用/应用/编码/核心/工资/工资/工资/工资/工资/工资/标准/质量/Cc.php中,没有计算酸液的线,因此这一功能与第65条相同。

public function prepareSave()
{
    $info = $this->getInfoInstance();
    if ($this->_canSaveCc) {
        $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
    }
    $info->setCcCidEnc($info->encrypt($info->getCcCid()));
    $info->setCcNumber(null)
        ->setCcCid(null);
    return $this;
}

之后,在贵付方法的主要示范档案中,确保这些变量能够:

    protected $_canSaveCc = true;

现在,我通过APIC测试了2种支付方法,同时通过APIC测试两种工作罚款。

this is my solution: goto /app/code/core/Mage/Payment/Model/Method/Cc.php and see function :

public function prepareSave()
{
    $info = $this->getInfoInstance();
    if ($this->_canSaveCc) {
        $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
    }
    //$info->setCcCidEnc($info->encrypt($info->getCcCid()));
    $info->setCcNumber(null)
        ->setCcCid(null);
    return $this;
}

仅评论一行:

$info->setCcNumber(null)
 ->setCcCid(null);




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签