【问题标题】:Codeigniter My_payment Authorize.net Library. How to send invoice number?Codeigniter My_payment Authorize.net 库。如何发送发票号码?
【发布时间】:2013-03-12 21:53:02
【问题描述】:

我正在使用 codeigniter 的 authorize.net my_payment.php 库为我为我的一个客户制作的网站进行 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);

【问题讨论】:

    标签: php codeigniter e-commerce authorize.net


    【解决方案1】:

    只是向 params 添加一个额外的值不会使请求真正发送该值,因为该类显然只发送$authnet_values 中指定的参数。

    此时需要修改$authnet_values,在授权请求中额外传递一个参数x_invoice_num

    【讨论】:

      猜你喜欢
      • 2016-06-29
      • 1970-01-01
      • 2021-02-18
      • 2013-05-31
      • 2014-02-20
      • 1970-01-01
      • 2011-03-22
      • 2012-11-16
      • 1970-01-01
      相关资源
      最近更新 更多