2013-03-22 79 views
1

我使用codeigniter的authorize.net my_payment.php庫爲我爲我的客戶之一製作的網站執行authorize.net付款。他們剛剛來找我,要求用authorize.net付款發送他們的發票號碼。我試圖添加'invoice_number' => $orderNumber它發送的參數,但它不工作。Codeigniter My_payment Authorize.net Library。如何發送發票號碼?

關於如何在付款的authorize.net中記錄發票號碼的任何想法?

這裏是my_payment庫:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

    /* 
    |-------------------------------------------------------------------------- 
    | Authorize.net Payment Module 
    |-------------------------------------------------------------------------- 
    | 
    | Just add the following config to your application/config/config.php file 
    | 
    | $config['at_login'] = "xxxxxxxxxx"; //your login 
    | $config['at_password'] = "xxxxxxxxxxxx"; //your transaction key 
    | $config['at_test'] = 1; //Set to 0 for live transactions 
    | $config['at_debug'] = 1; //Set to 0 for live transactions 
    | $config['at_site'] = 'https://test.authorize.net/gateway/transact.dll'; //comment for live trans 
    | //$config['at_site'] = 'https://secure.authorize.net/gateway/transact.dll'; //uncomment for live trans 
    | 
    | Call it by doing this: 
    | 
    |  $this->load->library('my_payment'); 
    |  $params->cc = '1293081309812039812039' ;//etc... you get the idea 
    |  
    |  $result = $this->my_payment->authorize($params); 
    |  print_r($result); //response codes from authorize.net 
    | 
    | 
    | 
    */ 

    class My_payment { 

     public function Authorize($params) 
     { 
      $CI =& get_instance(); 

      $x_Login = $CI->config->item('at_login');  
      $x_Password = $CI->config->item('at_password'); 

      $DEBUGGING     = $CI->config->item('at_debug'); 
      $TESTING     = $CI->config->item('at_test'); 
      $ERROR_RETRIES    = 2; 

      $auth_net_url    = $CI->config->item('at_site'); 

      $authnet_values    = array 
      (
       "x_login"    => $x_Login, 
       "x_version"    => "3.1", 
       "x_delim_char"   => "|", 
       "x_delim_data"   => "TRUE", 
       "x_type"    => "AUTH_CAPTURE", 
       "x_method"    => "CC", 
       "x_tran_key"   => $x_Password, 
       "x_relay_response"  => "FALSE", 
       "x_card_num"   => $params->cc, 
       "x_exp_date"   => $params->exp, 
       "x_description"   => $params->desc, 
       "x_amount"    => $params->amount, 
       "x_first_name"   => $params->firstName, 
       "x_last_name"   => $params->lastName, 
       "x_address"    => $params->address, 
       "x_city"    => $params->city, 
       "x_state"    => $params->state, 
       "x_zip"     => $params->zip, 
       "SpecialCode"   => $params->specialCode, 
      ); 

      $fields = ""; 
      foreach($authnet_values as $key => $value) $fields .= "$key=" . urlencode($value) . "&"; 

      $ch = curl_init($auth_net_url); 

      curl_setopt($ch, CURLOPT_HEADER, 0); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
      curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, "& ")); 

      $result = curl_exec($ch); 

      curl_close ($ch); 

      return $result; 

     } 
    } 
    /* End of file My_payment.php */ 
    /* Location: ./system/application/libraries/My_payment.php */ 

這裏是我的代碼發送支付:

//Process via Authorize.net 
      //Load the authorize.net payment library 
      $this->load->library('my_payment'); 
      $params = new stdClass(); 
      //Process the transaction 
      $params->cc = $_POST['finalCardNumber']; 
      $params->exp = $_POST['finalExpMonth'].'/'.$_POST['finalExpYear']; 
      $params->desc = 'Stoles.com Order'; 
      $params->amount = $_POST['finalGrandTotal']; 
      $params->firstName = $_POST['finalBillingFirstName']; 
      $params->lastName = $_POST['finalBillingLastName']; 
      $params->address = $_POST['finalBillingAddress']; 
      $params->city = $_POST['finalBillingCity']; 
      $params->state = $_POST['finalBillingState']; 
      $params->zip = $_POST['finalBillingZipcode']; 
      $params->specialCode = $_POST['finalCardCode']; 
      $params->invoice_number = $orderNumber; 

      $result = $this->my_payment->authorize($params); 

      $authres = str_split($result); 

回答

1

只是增加了額外的價值params爲不會使請求實際發送該值,因爲班級顯然只發送$authnet_values中指定的參數。

在這種情況下,你需要修改$authnet_values傳遞一個附加參數x_invoice_num在授權請求。