【发布时间】:2013-01-29 14:15:03
【问题描述】:
有没有人通过 CI-Merchant 使用 SagePay Direct?到目前为止,我得到的唯一回应是:
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);
}
(参数的所有值都是有效的,我已经检查了正确的值是否传递给它们。供应商名称在这里被屏蔽)
【问题讨论】:
-
作为更新,我已将代码移动到具有完整 SSL 证书的服务器上,因此我正在从 https 运行我的测试。我也切换到使用模拟器 (test.sagepay.com/Simulator),但仍然收到相同的响应消息,也看不到我的交易,所以甚至不确定它是否到达 SagePay 服务器?
-
它根本没有返回任何错误,这很奇怪。这可能不是问题,但您可以尝试将
Amount参数更改为小写吗?如果这不起作用,您可能需要向merchant_sagepay_base.php添加一些调试,例如在$this->post_request()之后的第 148 行添加print_r($response)以查看原始响应。 -
我已经尝试了这两种方法,甚至使用
print_r($response);我没有得到任何其他东西?我想我一定在这里错过了一个技巧!我应该指出我在 __construct 函数中调用了该库,例如,public function __construct() { parent::__construct(); $this->load->helper('language'); $this->load->library('merchant'); $this->merchant->load('sagepay_direct'); }我也没有收到任何其他错误! -
我也尝试使用 SagePay Direct 集成工具包中的代码示例,这似乎工作得很好!