CI-Merchant与Sagepay

时间:2013-01-29 14:15:04

标签: codeigniter-2 ci-merchant

有没有人有幸使用SagePay Direct和CI-Merchant?到目前为止,我得到的唯一回应是:

Merchant_response Object
(
    [_status:protected] => failed
    [_message:protected] => 
    [_reference:protected] => 
    [_data:protected] => 
    [_redirect_url:protected] => 
    [_redirect_method:protected] => GET
    [_redirect_message:protected] => 
    [_redirect_data:protected] => 
)

我以前没有使用过SagePay,需要紧急开展这项工作。我已将我的IP地址添加到SagePay测试区域,但我目前没有在https上测试,因为我只是在我的本地主机上。

我的代码如下:

public function process_payment()
    {

        $settings = array (
            'vendor' => 'XXX',
            'test_mode' => TRUE,
            'simulator_mode' => FALSE,
        );

        $this->merchant->initialize($settings);

        //get customer details
        $this->load->library('custom_cart');
        $customer = $this->custom_cart->get_customer_invoice_info();
        $customer_name = '';
            if ( ! empty($customer['title'])) $customer_name .= $customer['title'] .' ';
        $customer_name .= $customer['forename'];
        $customer_name .= $customer['surname'];

        $customer_street = $customer['address1'];
        $customer_street2 = $customer['address2'];
            if ( ! empty($customer['address3'])) $customer_street2 .= $customer['address3'];

        //order details
        $amt = $this->custom_cart->order_total();

        $get_curr = $this->custom_cart->get_currency();
        $currencycode = $get_curr['name'];

        $shippingamt = $this->custom_cart->shipping_cost();

        $itemamt = $this->custom_cart->order_subtotal();
        $taxamt = '0';
        $invnum = $this->custom_cart->customer_order_no();

         $params = array(
            'description'=> 'Online order',
            'currency'=> $currencycode,
            'transaction_id'=> $invnum,
            'email'=> $customer['email_address'],
            'first_name'=> $customer['forename'],
            'last_name'=> $customer['surname'],
            'address1'=> $customer_street,
            'address2'=> $customer_street2,
            'city'=> $customer['town_city'],
            'postcode'=> $customer['postcode'],
            'country'=> $customer['country'],
            'region'=> $customer['county'],
            'phone'=> $customer['phone'],

            'Amount'=> $amt,
            'card_no'=> $this->input->post('creditcard'), 
            'name'=> $customer_name, 
            'card_type' => $this->input->post('creditcardtype'), 
            'exp_month'=> $this->input->post('cardmonth'),
            'exp_year' => $this->input->post('cardyear'), 
            'csc'=> $this->input->post('cardsecurecode')
        );


        $response = $this->merchant->purchase($params);

        echo '<pre>';
        print_r($response);


    }

(参数的所有值都是有效的,我已经检查了正确的值是否传递给它们。供应商名称在这里被屏蔽了)

1 个答案:

答案 0 :(得分:1)

最后追踪到了问题 - 这一年我经历了两位数,这就是失败的地方(我忘记了我以前的商家,我在20前缀中加入)!谢谢您的帮助。 (如果有人遇到类似问题,我会通过回显函数路径中每个函数的响应来跟踪它)