How do I stop authentication of my paypal account using adaptive payments?
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="qwom_1315508825_biz@btinternet.com";
$preapprovalKey = '';
$requested='';
$receiverEmail='';
$amount='';
$count= count($_POST['receiveremail']);
//pay details//
$payRequest = new PayRequest();
$payRequest->actionType = "PAY";
$payRequest->currencyCode = "USD";
$receiver1 = new receiver();
$receiver1->email = "cam_1315509411_per@btinternet.com";
$receiver1->amount = "5.00";
$payRequest->receiverList = new ReceiverList();
$payRequest->receiverList = array($receiver1);
$payRequest->returnUrl = $returnURL;
$payRequest->senderEmail = "qwom_1315508825_biz@btinternet.com";
$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";
h开发者_C百科eader("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.
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)
精彩评论