贝宝日志:无效或找不到证书颁发机构-使用捆绑的CA证书文件重试

时间:2019-04-27 08:29:30

标签: php api sdk

一切正常,但无效。

我的代码是

parfeval

响应

<?php 
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;

require __DIR__  . '/PayPal/vendor/autoload.php';

$api = new ApiContext(
        new OAuthTokenCredential(
            'ClientID',     // ClientID
            'ClientSecret'      // ClientSecret
        )
);          
//enabled live api
$api->setConfig(
            [
                'mode' => 'live',
                'http.ConnectionTimeOut' => 30,
                'log.LogEnabled' => true,
                'log.FileName' => 'PayPal.log',
                'log.LogLevel' => 'FINE',
                'validation.level' => 'log'

            ]
    );


use PayPal\Api\Payer;
use PayPal\Api\Details;
use PayPal\Api\Amount;
use PayPal\Api\Transaction;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;

$payer = new Payer();
$details = new Details();
$amount = new Amount();
$transaction = new Transaction();
$payment = new Payment();
$redirectUrls = new RedirectUrls();

$payer->setPaymentMethod('paypal');

$details->setShipping('2.00')
        ->setTax('2.00')
        ->setSubtotal('20.00');

$amount->setCurrency('PLN')
        ->setTotal('24.00')
        ->setDetails($details);

$transaction->setAmount($amount)
            ->setDescription("Payment Test");

$payment->setIntent('sale')
        ->setPayer($payer)
        ->setTransactions([$transaction]);

$redirectUrls->setReturnUrl("https://local/paypal?payment=true")
            ->setCancelUrl("https://local/paypal?payment=false");


$payment->setRedirectUrls($redirectUrls);           

// After Step 3
try {
    $payment->create($api);

    $payment_id=$payment->getId();
    $hash=md5($payment->getId());

    echo $payment;
    echo "\n\nRedirect user to approval_url: " . $payment->getApprovalLink() . "\n";



}
catch (\PayPal\Exception\PayPalConnectionException $ex) {
    // This will print the detailed information on the exception.
    //REALLY HELPFUL FOR DEBUGGING
    echo $ex->getData();    
}           
var_dump($payment->getLinks());
echo'<br />';
echo$hash;
echo'<br />';
echo$payment_id;
?>

看起来一切正常,但不起作用。 1.无论我设置实时还是沙箱,日志中都会出现错误。

{ "intent": "sale", "payer": { "payment_method": "paypal" }, "transactions": [ { "amount": { "total": "24.00", "currency": "PLN", "details": { "subtotal": "20.00", "tax": "2.00", "shipping": "2.00" } }, "description": "Payment Test", "related_resources": [] } ], "redirect_urls": { "return_url": "https://local/paypal?payment=true", "cancel_url": "https://local/paypal?payment=false" }, "id": "PAYID-LTCBAJI4S102048F8950560B", "state": "created", "create_time": "2019-04-27T08:17:41Z", "links": [ { "href": "https://api.paypal.com/v1/payments/payment/PAYID-LTCBAJI4S102048F8950560B", "rel": "self", "method": "GET" }, { "href": "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-23G84085D38052944", "rel": "approval_url", "method": "REDIRECT" }, { "href": "https://api.paypal.com/v1/payments/payment/PAYID-LTCBAJI4S102048F8950560B/execute", "rel": "execute", "method": "POST" } ] } Redirect user to approval_url: https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-23G84085D38052944
D:\wamp\www\local\payment-paypal.ocg.php:89:
array (size=3)
  0 => 
    object(PayPal\Api\Links)[27]
      private '_propMap' (PayPal\Common\PayPalModel) => 
        array (size=3)
          'href' => string 'https://api.paypal.com/v1/payments/payment/PAYID-LTCBAJI4S102048F8950560B' (length=73)
          'rel' => string 'self' (length=4)
          'method' => string 'GET' (length=3)
  1 => 
    object(PayPal\Api\Links)[28]
      private '_propMap' (PayPal\Common\PayPalModel) => 
        array (size=3)
          'href' => string 'https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-23G84085D38052944' (length=86)
          'rel' => string 'approval_url' (length=12)
          'method' => string 'REDIRECT' (length=8)
  2 => 
    object(PayPal\Api\Links)[29]
      private '_propMap' (PayPal\Common\PayPalModel) => 
        array (size=3)
          'href' => string 'https://api.paypal.com/v1/payments/payment/PAYID-LTCBAJI4S102048F8950560B/execute' (length=81)
          'rel' => string 'execute' (length=7)
          'method' => string 'POST' (length=4)

f56c3d269cb9187db3cb96d4d2acfd3e
PAYID-LTCBAJI4S102048F8950560B
  1. 交易不存在,不会计入。 3.在开店时看不到产品名称,价格,没什么,只能登录。 有人可以帮我解决这个问题吗?

0 个答案:

没有答案