Php 使用codeigniter中的cim库授权网络错误39

Php 使用codeigniter中的cim库授权网络错误39,php,mysql,codeigniter,authorize.net,Php,Mysql,Codeigniter,Authorize.net,每次我创建一个客户配置文件id时,我都会从Authorization net获得下面的响应,但没有重复的响应,因为它是新创建的客户配置文件。由于我正在检索用户的电子邮件以创建authorizenet配置文件id,我已经检查了mysql数据库中的重复行,但是没有。我正在使用authorize.net最新的PHPSDK AuthorizeNetCIM_Response Object ( [xml] => SimpleXMLElement Object (

每次我创建一个客户配置文件id时,我都会从Authorization net获得下面的响应,但没有重复的响应,因为它是新创建的客户配置文件。由于我正在检索用户的电子邮件以创建authorizenet配置文件id,我已经检查了mysql数据库中的重复行,但是没有。我正在使用authorize.net最新的PHPSDK

AuthorizeNetCIM_Response Object
(
    [xml] => SimpleXMLElement Object
        (
            [messages] => SimpleXMLElement Object
                (
                    [resultCode] => Error
                    [message] => SimpleXMLElement Object
                        (
                            [code] => E00039
                            [text] => A duplicate record with ID 31985206 already exists.
                        )

            )

        [customerPaymentProfileIdList] => SimpleXMLElement Object
            (
            )

        [customerShippingAddressIdList] => SimpleXMLElement Object
            (
            )

        [validationDirectResponseList] => SimpleXMLElement Object
            (
            )

    )

[response] => 
我正在使用Codeigniter中的电子邮件确认来创建Authorizenet客户id

 public function email_confirmation(){

    //passes the post user id variable to a local variable  
    $username=$this->uri->segment(3);

    //activate user account when confirmed
    $confirmation=$this->register_customer_model->user_confirms_email($username);
    //$confirmation = TRUE;

                         if($confirmation==TRUE){

                                 //load authorizenet model
                                 $this->load->model('authorizenet_model');

                                 //create authorizenet profile id
                                 $response=$this->authorizenet_model->create_authorizenet_profile_id($username);

                                 print_r($response);
}

下面是使用用户用户名创建概要文件id的authorizenet模型

public function create_authorizenet_profile_id($username){

    //get email from username    
    $query=$this->db->query("
    SELECT email
    FROM   users
    WHERE  username='$username'");

   foreach ($query->result() as $row){
    $email                = $row->email;
                                     }

                                  //creates authorizenet profile id                                    
                                  $request                      = new AuthorizeNetCIM;
                                  $customerProfile              = new AuthorizeNetCustomer;
                                  $customerProfile->description = "Bar Express Customer";
                                  $customerProfile->email       = $email;

                                  $response = $request->createCustomerProfile($customerProfile);

                                  return $response;                                
                                                     }

问题在于提出请求的顺序。应该是

// Create new customer profile
$customerProfile                     = new AuthorizeNetCustomer;
$customerProfile->description        = "Description of customer";
$customerProfile->merchantCustomerId = time();
$customerProfile->email              = "test@domain.com";
$response = $request->createCustomerProfile($customerProfile);
if ($response->isOk()) {
    $customerProfileId = $response->getCustomerProfileId();
}