我是PayPal php SDK 的新手,这是我使用的代码
$RPProfileDetails = new RecurringPaymentsProfileDetailsType();
$RPProfileDetails->SubscriberName = 'Test Customer';
$RPProfileDetails->BillingStartDate = '29/5/2016';
$activationDetails = new ActivationDetailsType();
$activationDetails->InitialAmount = new BasicAmountType($currencyCode, 10);
$activationDetails->FailedInitialAmountAction = 'ContinueOnFailure';//$_REQUEST['failedInitialAmountAction'];
$paymentBillingPeriod = new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = 365;//$_REQUEST['billingFrequency'];
$paymentBillingPeriod->BillingPeriod = 'Day';//$_REQUEST['billingPeriod'];
$paymentBillingPeriod->TotalBillingCycles = 365;//$_REQUEST['totalBillingCycles'];
$paymentBillingPeriod->Amount = new BasicAmountType($currencyCode, 10);//$_REQUEST['paymentAmount']
$scheduleDetails = new ScheduleDetailsType();
$scheduleDetails->Description = 'Artist Access amount';//$_REQUEST['profileDescription'];
$scheduleDetails->PaymentPeriod = $paymentBillingPeriod;
$createRPProfileRequestDetail = new CreateRecurringPaymentsProfileRequestDetailsType();
$_REQUEST['token'] ='';
if(trim($_REQUEST['token']) != "") {
$createRPProfileRequestDetail->Token = $_REQUEST['token'];
} else {
$creditCard = new CreditCardDetailsType();
$creditCard->CreditCardNumber = '41111111111111111';//$_REQUEST['creditCardNumber'];
$creditCard->CreditCardType = 'Visa';//$_REQUEST['creditCardType'];
$creditCard->CVV2 = '111';//$_REQUEST['cvv'];
$creditCard->ExpMonth = '9';//$_REQUEST['expMonth'];
$creditCard->ExpYear = '2022';//$_REQUEST['expYear'];
$createRPProfileRequestDetail->CreditCard = $creditCard;
}
$createRPProfileRequestDetail->ScheduleDetails = $scheduleDetails;
$createRPProfileRequestDetail->RecurringPaymentsProfileDetails = $RPProfileDetails;
$createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
$createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetail;
$createRPProfileReq = new CreateRecurringPaymentsProfileReq();
$createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;
$config = array(
// values: 'sandbox' for testing
// 'live' for production
"mode" => "sandbox",
'log.LogEnabled' => true,
'log.FileName' => '../PayPal.log',
'log.LogLevel' => 'FINE',
// These values are defaulted in SDK. If you want to override default values, uncomment it and add your value.
// "http.ConnectionTimeOut" => "5000",
// "http.Retry" => "2",
// Signature Credential
"acct1.UserName" => "asp.mobileappz_api1.gmail.com",
"acct1.Password" => "TR2R87Q3W7XT7UJQ",
"acct1.Signature" => "AFcWxV21C7fd0v3bYYYRCpSSRl31Abq4txmPS2AOjtNVgh-ZRkhGwY3D",
// Subject is optional and is required only in case of third party authorization
// "acct1.Subject" => "",
// Sample Certificate Credential
// "acct1.UserName" => "certuser_biz_api1.paypal.com",
// "acct1.Password" => "D6JNKKULHN3G5B8A",
// Certificate path relative to config folder or absolute path in file system
// "acct1.CertPath" => "cert_key.pem",
// Subject is optional and is required only in case of third party authorization
// "acct1.Subject" => "",
);
$paypalService = new PayPalAPIInterfaceServiceService($config);
try {
/* wrap API method calls on the service object with a try catch */
$createRPProfileResponse = $paypalService->CreateRecurringPaymentsProfile($createRPProfileReq);
} catch (Exception $ex) {
echo '<pre>';
PRINT_r($ex);
//include_once("../Error.php");
exit;
}
if(isset($createRPProfileResponse)) {
echo "<table>";
echo "<tr><td>Ack :</td><td><div id='Ack'>$createRPProfileResponse->Ack</div> </td></tr>";
echo "<tr><td>ProfileID :</td><td><div id='ProfileID'>".$createRPProfileResponse->CreateRecurringPaymentsProfileResponseDetails->ProfileID ."</div> </td></tr>";
echo "</table>";
echo "<pre>";
print_r($createRPProfileResponse);
echo "</pre>";
}
}
Ack :
Failure
ProfileID :
PayPalPayPalAPICreateRecurringPaymentsProfileResponseType Object
(
[CreateRecurringPaymentsProfileResponseDetails] => PayPalEBLBaseComponentsCreateRecurringPaymentsProfileResponseDetailsType Object
(
[ProfileID] =>
[ProfileStatus] =>
[TransactionID] =>
[DCCProcessorResponse] =>
[DCCReturnCode] =>
)
[Timestamp] => 2016-06-07T03:29:31Z
[Ack] => Failure
[CorrelationID] => 9c2a8533bb7f5
[Errors] => Array
(
[0] => PayPalEBLBaseComponentsErrorType Object
(
[ShortMessage] => Security error
[LongMessage] => Security header is not valid
[ErrorCode] => 10002
[SeverityCode] => Error
[ErrorParameters] =>
)
)
[Version] => 106.0
[Build] => 22204133
)
我已经交叉检查它不是因为错误的信誉,我已经设置了一个沙盒帐户 developer.paypal.com 网址是 sdk 创建也是沙盒,但显示它如何不起作用,请帮助。 我完全没有头绪。 这也是 SDK 本身PayPal标准示例。 请指出我错在哪里。
> 10002 是指不正确的 API 凭据,您使用的是实时PayPal帐户凭据,并且代码设置为沙盒
"mode" => "sandbox",
将其更改为实时环境,然后重试。