Php Paypal SDK-返回“;“已批准”;当仪表板显示“时”;“已完成”;付款执行后
我正在使用以下代码执行用户已在Paypal.com上批准的付款:Php Paypal SDK-返回“;“已批准”;当仪表板显示“时”;“已完成”;付款执行后,php,paypal,payment,Php,Paypal,Payment,我正在使用以下代码执行用户已在Paypal.com上批准的付款: // Get the order object $order_object = new Order($_GET["orderid"]); // Complete the payment $payment = Payment::get($order_object->paypal_payment_id, $apiContext); //Set the payer id $order_object->SetPayerI
// Get the order object
$order_object = new Order($_GET["orderid"]);
// Complete the payment
$payment = Payment::get($order_object->paypal_payment_id, $apiContext);
//Set the payer id
$order_object->SetPayerId($_GET["PayerID"]);
try
{
// PaymentExecution object includes information necessary
// to execute a PayPal account payment.
// The payer_id is added to the request query parameters
// when the user is redirected from paypal back to your site
$execution = new PaymentExecution();
$execution->setPayer_id($_GET["PayerID"]);
//Execute the payment
// (See bootstrap.php for more on `ApiContext`)
$finished_payment = $payment->execute($execution, $apiContext);
}
catch(PayPal\Exception\PPConnectionException $e)
{
echo "<p>PPConnectionException - Already executed payment?</p>";
}
echo "Payment state: " . $finished_payment->getState() . '<br/>';
echo "Payment ID:" . $finished_payment->getId() . '<br/>';
//获取订单对象
$order\u object=新订单($\u GET[“orderid”]);
//完成付款
$payment=payment::get($order\u object->paypal\u payment\u id,$apiContext);
//设置付款人id
$order\u object->SetPayerId($\u GET[“PayerID”]);
尝试
{
//PaymentExecution对象包含必要的信息
//执行PayPal帐户付款。
//付款人id将添加到请求查询参数中
//当用户从paypal重定向回您的站点时
$execution=新的PaymentExecution();
$execution->setPayer\u id($\u GET[“PayerID”]);
//执行付款
//(有关“ApiContext”的更多信息,请参见bootstrap.php)
$finished\u payment=$payment->execute($execution,$apiContext);
}
捕获(PayPal\Exception\PPConnectionException$e)
{
echo“PPConnectionException-已执行付款?”;
}
echo“付款状态:”$已完成付款->获取状态()
;
回显“付款ID:”$已完成付款->获取ID()
;
如果我在执行之前获得订单的状态,它将返回created
,这很好,但是在使用此代码执行之后,它返回状态approved
如果approved
意味着事务已完成,那么这将很好,但是在开发人员仪表板上,事务显示为completed
,正如我预期的那样
当代码真正完成时,为什么会返回已批准的
谢谢
更新:我刚刚以我的商户测试帐户和我使用的客户测试帐户的身份进行了检查和登录,并且两者都表示交易已完成。
我可以证明这一点,因为如果我尝试重新执行订单,它将返回500个错误。
这让人很困惑,为什么它会返回不一致的数据…
截图:
从上面的代码返回
查看开发商网站上的订单。。。
批准的是否意味着已完成
?
是的,批准的意思是已完成,通过此处的文档:
回复必须是“状态”:“批准”,如果一切顺利。询问者无法区分付款和销售
“批准”是付款的最终满意状态。
付款批准后,即创建销售。然后,您可以在支付JSON的“事务/相关资源”字段中找到它。
“完成”是一种愉快的销售状态