0

我正在尝试将 CI Merchant 库用于 codeignator,这是我的代码:

$this->load->library('merchant');
    $this->merchant->load('paypal_express');
    $settings = array(
        'username' => 'api.sandbox.paypal.com',
        'password' => 'AQHaXxDW3dlKDRDJ7lDtGr4w8-reNNfvPFUKmEr9npMzYjZ2WIbfqqI3VL2C',
        'signature' => 'EMbUfhBCqBZw8hhH6q8VZT_53-xwoOs6_lotS68I7qrY5iyHPLgDitrsAZj5',
        'test_mode' => true);
    $this->merchant->initialize($settings);
    $params = array(
        'amount' => 100.00,
        'currency' => 'USD',
        'return_url' => 'https://www.example.com/checkout/payment_return/123',
        'cancel_url' => 'https://www.example.com/checkout');
    $response = $this->merchant->purchase($params);
    echo '<pre>';
    print_r($response);
    echo '</pre>';

但是当我在本地运行它时,结果是:

    Merchant_response Object
(
[_status:protected] => failed
[_message:protected] => error setting certificate verify locations:
CAfile: C:\xampp\htdocs\egyptianornaments\application\config/cacert.pem
CApath: none
[_reference:protected] => 
[_data:protected] => 
[_redirect_url:protected] => 
[_redirect_method:protected] => GET
[_redirect_message:protected] => 
[_redirect_data:protected] => 
)

当我在服务器上运行时,我得到一个空白页,所以我做错了什么?

4

1 回答 1

0

看起来您的代码设置为使用证书而不是签名方法,但您的服务器没有安装和配置 SSL 证书以与 PayPal 一起使用,无论如何处理这确实有点痛苦。我建议切换到签名方法,然后你就不必再搞砸了。

我不熟悉您正在使用的库,但必须有一些方法来设置它。您可能还想看看我自己的非常流行的 PayPal CodeIgniter 库。

不过,我实际上已经停止了对该 CI 特定库的维护,因为我现在已经为 PHP 5.3+ 更新了用于 PayPal 的通用 PHP 库,并与 Composer / Packagist 一起使用,它允许您在 CodeIgniter 或任何其他框架中使用它。

到今天为止,CI 特定的库也不甘落后,但同样,我不再更新它了。我现在只维护通用版本,因为它可以在任何地方使用。

无论如何,它使每个 PayPal API 调用对您来说都非常简单。

于 2014-04-21T03:19:54.320 回答