CodeIgniter、CI-Merchant 和 Paypal 沙盒

标签 codeigniter paypal-sandbox ci-merchant

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

$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = array(
    'username' => '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97e3f2e4e3d7e3f2e4e3b9f4f8fa" rel="noreferrer noopener nofollow">[email protected]</a>',
    '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');

我知道这段代码不能做太多事情,但它什么也没做。只是加载 View ,什么也没有发生,我不明白。所以,我的问题是,你知道教程或者知道如何让 CI Merchant 与 Paypal Sandbox 一起使用吗?感谢您的帮助。

最佳答案

艾斯的评论很到位。您的代码没有任何问题,但您需要检查 $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;

关于CodeIgniter、CI-Merchant 和 Paypal 沙盒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13224575/

相关文章:

javascript - Codeigniter 中带或不带斜线的 Ajax 数据调用出现错误

javascript - 按钮需要点击两次才能工作,我希望只点击一次

php - WAMP 和 mysqli::real_connect(): (HY000/2002)?

paypal - Sandbox api curl (5) SSL 连接错误

paypal - CI-Merchant 中的自定义付款值

paypal - 每件商品的详细信息 ci-merchant 和 PayPalExpress

php - Codeigniter 替换上传的图片

ssl - 对 Paypal 沙箱的 HTTPS 请求失败

asp.net - 使用信用卡 PayPal 定期付款

codeigniter - 安全 header 在 ci-merchant 中无效