伙计,我对sdk付款检查程序有疑问,当付款成功后,sdk将付款人重定向到此网址https://mydomain/success?s=true&t=1539681025&paymentId=PAYID-LPC2WAY3PU971582P691553Y&token=EC-2R425444M1727284U&PayerID=HEZISY93F
在此页面中,我使用以下代码检查PaymentId
# page success.php
# payment params
$paymentId = (isset($_GET['paymentId'])) ? trim(filter_var($_GET['paymentId'], FILTER_SANITIZE_STRING)) : null;
$token = (isset($_GET['token'])) ? trim(filter_var($_GET['token'], FILTER_SANITIZE_STRING)) : null;
$payerId = (isset($_GET['PayerID'])) ? trim(filter_var($_GET['PayerID'], FILTER_SANITIZE_STRING)) : null;
# include the paypal-sdk
$payment = \PayPal\Api\Payment::get($paymentId, $apiContext);
$execute = new \PayPal\Api\PaymentExecution();
$execute->setPayerId($payerId);
# payment checker
try {
$result = $payment->execute($execute, $apiContext);
} catch (Exception $e) {
header("Location: $url");
die();
}
echo 'payment was paid successfully';
# my $apiContext config / paypal-sdk config
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'###',
'###'
)
);
$apiContext->setConfig(
array(
'mode' => 'live',
'log.LogEnabled' => true,
'log.FileName' => 'PayPal.log',
'log.LogLevel' => 'INFO', // PLEASE USE `INFO` LEVEL FOR LOGGING IN LIVE ENVIRONMENTS : DEBUG
)
);
当我在沙盒中尝试此代码时,付款成功后我无法刷新成功页面,检查器将我重定向到我的主页,没事。
我的问题是,当我使用实时配置进行尝试时,在重定向到succes.php并支付了款项之后,我可以刷新success.php页面,以便在数据库中添加几笔而不是一笔。
付款后如何付款,并尝试刷新页面,sdk将我重定向到我的主页?