我可以创建并执行付款。我可以使用IPN模拟器来模拟Express Checkout,并且可以正常工作。我无法连接2。我认为这是我在执行付款代码中正在执行或未执行的操作。这是代码:
<?php
require "vendor/autoload.php";
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
use PayPal\Api\Transaction;
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'(*ClientID*)',
'(*ClientSecret*)'
)
);
$paymentId = $_GET['paymentId'];
$payment = Payment::get($paymentId, $apiContext);
$execution = new PaymentExecution();
$execution->setPayerId($_GET['PayerID']);
$transaction = new Transaction();
$amount = new Amount();
$details = new Details();
$details->setShipping(0)
->setTax(0)
->setSubtotal(10);
$amount->setCurrency('USD');
$amount->setTotal(10);
$amount->setDetails($details);
$transaction->setAmount($amount);
$execution->addTransaction($transaction);
try {
$result = $payment->execute($execution, $apiContext);
return $result;
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
// This will print the detailed information on the exception.
//REALLY HELPFUL FOR DEBUGGING
echo $ex->getData();
}
?>
我已经遍历了很多次。所有默认设置等都是正确的。我没办法尝试了。