【问题标题】:CodeIgniter, CI-Merchant and Paypal SandboxCodeIgniter、CI-Merchant 和 Paypal 沙盒
【发布时间】:2012-11-05 00:43:55
【问题描述】:

我正在尝试使用 CodeIgniter 制作一个小购物车,我发现 CI-Merchant 可以通过本指南 http://ci-merchant.org/ 与支付网关一起使用,但我真的不明白如何让它与 Paypal Sandbox 一起使用。

$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = array(
    'username' => 'test@test.com',
    'password' => '********',
    'signature' => 'Test Store',
    'test_mode' => true);

$this->merchant->initialize($settings);
$params = array(
    'amount' => 12.00,
    'currency' => 'CAD',
    'return_url' => 'http://payment.test.com',
    'cancel_url' => 'http://payment.test.com/cancel');

$response = $this->merchant->purchase($params);
$this->load->view('welcome_message');

我知道这段代码不能做很多事情,但它什么也不做。只是加载视图,没有任何反应,我不明白。所以,我的问题是,你知道教程还是只是如何让 CI Merchant 与 Paypal Sandbox 一起工作?感谢您的帮助。

【问题讨论】:

  • 尝试在$this->load-view('welcome_message); 之前打印$response 这样的print "<pre>"; var_dump($response); print "</pre>"; 以查看结果。
  • 所以我在$this->load-view('welcome_message); 之前添加了print "<pre>"; var_dump($response); print "</pre>";,然后我得到了object(Merchant_response)[17] protected '_status' => string 'failed' (length=6) protected '_message' => string 'Security header is not valid' (length=28) ...,然后我意识到我们需要使用“API 和支付卡凭据”而不是卖家账户的凭据。所以现在它可以工作了,我可以继续编码!

标签: codeigniter paypal-sandbox ci-merchant


【解决方案1】:

Ace 的评论很到位。您的代码没有任何问题,但您需要检查 $response 对象以查看结果(或错误消息)是什么。

$response = $this->merchant->purchase($params);
if ($response->success())
{
    // mark order as complete
    $gateway_reference = $response->reference();
}
else
{
    $message = $response->message();
    echo('Error processing payment: ' . $message);
    exit;
}

你也可以简单地试试这个来检查对象:

$response = $this->merchant->purchase($params);
echo '<pre>';
print_r($response);
exit;

【讨论】:

猜你喜欢
  • 2015-08-25
  • 2014-08-28
  • 2016-05-23
  • 2014-10-03
  • 2016-11-17
  • 2011-09-11
  • 2013-02-28
  • 2013-01-10
  • 2015-11-25
相关资源
最近更新 更多