我有这段代码
<?php
require '..\..\vendor\autoload.php';
define('SITE_URL','https://www.historietas.mx');
$paypal = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'my_redential',
'my_secret'
)
);
?>
这段代码
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
$payment = new Payment();
$payment->setIntent('sale')
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions([$transaction]);
try{
$payment->create($paypal);
}
catch(PayPal\Exception\PayPalConnectionException $e){
echo $e->getCode();
echo $e->getData();
die($e);
}
echo $approvalUrl = $payment->getApprovalLink();
我有这个错误:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'ReturnUrl is not a fully qualified URL'
我不知道什么是hapenning我没有在网址中使用任何特殊字符,为什么给我这个错误?请帮忙,这是非常令人沮丧的......
答案 0 :(得分:0)
从您的网址中删除网址中的空格
include 'vendor/autoload.php';
$checkUrl = 'https://yourdomein.org/user/registration/paypaypal-ch?approval=true&plan=single&email=dghdg@dfgsdh.com&firstname=dshdh0d&lastname=dhdas';
try {
\PayPal\Validation\UrlValidator::validate($checkUrl);
echo "Validated\n";
} catch (InvalidArgumentException $ex) {
echo $ex->getMessage() . "\n";
}
答案 1 :(得分:0)
Remove ?success=true
和
Remove ?success=false
来自
$redirectUrls->setReturnUrl(SITE_URL.'\controladores\pagos\pay.php?success=true')
->setCancelUrl(SITE_URL.'\controladores\pagos\pay.php?success=false');
它肯定会起作用。
答案 2 :(得分:0)
我遇到了同样的问题,通过使用解决了
route('your route name '['parameter 1','parameter2'])
$redirectUrls->setReturnUrl(route('your route name '['parameter 1','parameter2']));