Paypal REST API错误SSL证书错误:无法获得本地颁发者证书

时间:2015-06-26 12:43:05

标签: php ssl paypal certificate

我正在Windows 8上的Wamp Server上运行PHP,而我在laravel上使用了包PayPal-PHP-SDK,每当我尝试创建付款时,都会收到错误

SSL certificate problem: unable to get local issuer certificate

我的__construct功能:

public function __construct()
{

    $this->ClientId = '..';
    $this->ClientSecret = '..';

    $OAuthTokenCredential = new OAuthTokenCredential($this->ClientId, $this->ClientSecret);
    $this->apiContext = new ApiContext($OAuthTokenCredential, 'Request ' . time());
    $this->apiContext->setConfig(
        array(
            'mode'          => ($this->sandbox) ? 'sandbox' : 'live',
            'log.LogEnabled' => true,
            'log.FileName' => __DIR__ . '/../../../logs/PayPal.log',
            'log.LogLevel' => 'FINE'
        )
    );

}

makePayment()函数:

/**
 * Makes the payment
 *
 * @return mixed
 */
public function makePayment()
{
    $Payer = new Payer();
    $Payer->setPaymentMethod('paypal');

    $Item = new Item();
    $Item->setName('Name') // TODO
        ->setCurrency('EUR')
        ->setQuantity(1)
        ->setPrice(1); // TODO

    $Items = new ItemList();
    $Items->setItems([$Item]);

    $Details = new Details();
    $Details->setSubtotal(1);

    $Amount = new Amount();
    $Amount->setCurrency('EUR')
        ->setTotal(1);

    $Transaction = new Transaction();
    $Transaction->setAmount($Amount)
        ->setItemList($Items)
        ->setDescription('...')
        ->setInvoiceNumber(uniqid());

    $RedirectUrls = new RedirectUrls();
    $RedirectUrls->setReturnUrl(url() . '/payment/success')
                 ->setCancelUrl(url() . '/payment/cancel');

    $Payment = new PPPayment();
    $Payment->setIntent('sale')
        ->setPayer($Payer)
        ->setRedirectUrls($RedirectUrls)
        ->setTransactions([$Transaction]);

    try {
        $Payment->create($this->apiContext);
    } catch (\Exception $ex) {
        return $ex->getMessage();
    }

    return $Payment->getApprovalLink();

}

我该如何解决这个问题?

0 个答案:

没有答案