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

时间:2015-03-28 08:22:22

标签: php mysql codeigniter authorize.net

每当我创建客户资料ID时,我都会从授权网获得以下响应,但没有重复,因为它是新创建的客户资料。由于我正在检索用户的电子邮件以创建authorizenet配置文件ID,因此我已经检查了mysql数据库中的重复行,但没有。我正在使用authorize.net的最新php sdk。

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;                                
                                                     }

1 个答案:

答案 0 :(得分:0)

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

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