1

我正在使用my_payment.phpcodeigniter 的 authorize.net 库为我为我的一个客户制作的网站进行 authorize.net 付款。他们刚刚来找我,要求将他们的发票号码与 authorize.net 付款一起发送。我试图添加'invoice_number' => $orderNumber到它发送的参数中,但它不起作用。

关于如何在 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);
4

1 回答 1

1

只是向 params 添加一个额外的值不会使请求实际发送该值,因为该类显然只发送$authnet_values.

在这种情况下,您需要修改以在授权请求中$authnet_values传递一个附加参数。x_invoice_num

于 2013-03-22T22:12:41.933 回答