如何停止使用自适应支付对我的 PayPal 帐户进行身份验证?
使用 Pay 方法的自适应支付,我设法让一个脚本工作,用户可以通过 php 将钱从我的帐户存入他们的帐户,但我必须输入我的密码,即使它使用我的 api 凭据。如何阻止它每次都询问我的密码?这是我的代码:
<?php
require_once '../../../lib/AdaptivePayments.php';
require_once 'web_constants.php';
session_start();
try {
$serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT'];
$url=dirname('http://'.$serverName.':'.$serverPort.$_SERVER['REQUEST_URI']);
$returnURL = $url."/PaymentDetails.php";
$cancelURL = $url. "/SetPay.php" ;
$currencyCode="USD"; //$_REQUEST['currencyCode'];
$email="[email protected]";
$preapprovalKey = '';
$requested='';
$receiverEmail='';
$amount='';
$count= count($_POST['receiveremail']);
//pay details//
$payRequest = new PayRequest();
$payRequest->actionType = "PAY";
$payRequest->currencyCode = "USD";
$receiver1 = new receiver();
$receiver1->email = "[email protected]";
$receiver1->amount = "5.00";
$payRequest->receiverList = new ReceiverList();
$payRequest->receiverList = array($receiver1);
$payRequest->returnUrl = $returnURL;
$payRequest->senderEmail = "[email protected]";
$payRequest->feesPayer = "SENDER";
$payRequest->cancelUrl = $cancelURL;
$payRequest->requestEnvelope = new RequestEnvelope();
$payRequest->requestEnvelope->errorLanguage = "en_US";
$payRequest->requestEnvelope->detailLevel = "ReturnAll";
//end pay details//
$ap = new AdaptivePayments();
$response=$ap->Pay($payRequest);
if(strtoupper($ap->isSuccess) == 'FAILURE')
{
$_SESSION['FAULTMSG']=$ap->getLastError();
$location = "APIError.php";
header("Location: $location");
}
else
{
$_SESSION['payKey'] = $response->payKey;
if($response->paymentExecStatus == "COMPLETED")
{
$location = "PaymentDetails.php";
header("Location: $location");
}
else
{
/*$token = $response->payKey;
$payPalURL = PAYPAL_REDIRECT_URL.'_ap-payment&paykey='.$token;
header("Location: ".$payPalURL);*/
echo $response->paymentExecStatus;
}
}
}
catch(Exception $ex) {
$fault = new FaultMessage();
$errorData = new ErrorData();
$errorData->errorId = $ex->getFile() ;
$errorData->message = $ex->getMessage();
$fault->error = $errorData;
$_SESSION['FAULTMSG']=$fault;
$location = "APIError.php";
header("Location: $location");
}
?>
它使用 Adaptive Payments Soap API。凭据位于包含的文件中。
Using the Adaptive Payments with the Pay method I managed to get a script working where a user can deposit money from my account to theirs through php but I have to enter my password even though it is using my api credentials. How can I stop it from asking me for my password every time? This is my code:
<?php
require_once '../../../lib/AdaptivePayments.php';
require_once 'web_constants.php';
session_start();
try {
$serverName = $_SERVER['SERVER_NAME'];
$serverPort = $_SERVER['SERVER_PORT'];
$url=dirname('http://'.$serverName.':'.$serverPort.$_SERVER['REQUEST_URI']);
$returnURL = $url."/PaymentDetails.php";
$cancelURL = $url. "/SetPay.php" ;
$currencyCode="USD"; //$_REQUEST['currencyCode'];
$email="[email protected]";
$preapprovalKey = '';
$requested='';
$receiverEmail='';
$amount='';
$count= count($_POST['receiveremail']);
//pay details//
$payRequest = new PayRequest();
$payRequest->actionType = "PAY";
$payRequest->currencyCode = "USD";
$receiver1 = new receiver();
$receiver1->email = "[email protected]";
$receiver1->amount = "5.00";
$payRequest->receiverList = new ReceiverList();
$payRequest->receiverList = array($receiver1);
$payRequest->returnUrl = $returnURL;
$payRequest->senderEmail = "[email protected]";
$payRequest->feesPayer = "SENDER";
$payRequest->cancelUrl = $cancelURL;
$payRequest->requestEnvelope = new RequestEnvelope();
$payRequest->requestEnvelope->errorLanguage = "en_US";
$payRequest->requestEnvelope->detailLevel = "ReturnAll";
//end pay details//
$ap = new AdaptivePayments();
$response=$ap->Pay($payRequest);
if(strtoupper($ap->isSuccess) == 'FAILURE')
{
$_SESSION['FAULTMSG']=$ap->getLastError();
$location = "APIError.php";
header("Location: $location");
}
else
{
$_SESSION['payKey'] = $response->payKey;
if($response->paymentExecStatus == "COMPLETED")
{
$location = "PaymentDetails.php";
header("Location: $location");
}
else
{
/*$token = $response->payKey;
$payPalURL = PAYPAL_REDIRECT_URL.'_ap-payment&paykey='.$token;
header("Location: ".$payPalURL);*/
echo $response->paymentExecStatus;
}
}
}
catch(Exception $ex) {
$fault = new FaultMessage();
$errorData = new ErrorData();
$errorData->errorId = $ex->getFile() ;
$errorData->message = $ex->getMessage();
$fault->error = $errorData;
$_SESSION['FAULTMSG']=$fault;
$location = "APIError.php";
header("Location: $location");
}
?>
It uses the Adaptive Payments Soap API. The credentials are in the included files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是预期的功能。
由于您使用的是 Pay 方法,它自然会假设这是正常交易而不是“存款”。
您需要查看 PayPal MassPay API。
请参阅 https://www.x.com/developers/paypal/products/mass-支付以及https://www.x.com/developers/paypal/documentation-tools/api/masspay-api-nvp 查看 NVP API 文档。
还有一些示例代码位于 https:// /cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code (此处为 php 示例)
That's intended functionality.
Since you're using the Pay method, it naturally assumes it's a normal transaction rather than a 'deposit'.
You'd want to look at the PayPal MassPay API instead.
See https://www.x.com/developers/paypal/products/mass-pay as well as https://www.x.com/developers/paypal/documentation-tools/api/masspay-api-nvp for the NVP API documentation.
There's also some sample code up at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/library_code (php sample here)