简体   繁体   English

贝宝API定期付款余额

[英]Paypal API Recurring Payments Balance

Sure it's just something I'm missing. 当然,这只是我所缺少的。 Fairly new to the Paypal API, especially the classic one! Paypal API相当新,尤其是经典的API! Basically, I'm using the following code to generate a subscription to my site at £2.50 per month. 基本上,我正在使用以下代码以每月2.50英镑的价格生成对我的网站的订阅。 I can get the subscription to appear in the Recurring Payments Dashboard on Paypal Sandbox, but it doesn't change the balance and seems to be missing things to do with the initial payment. 我可以使订阅显示在Paypal沙盒上的“定期付款”仪表板上,但它不会更改余额,并且似乎缺少与初始付款有关的内容。 I tried INITAMT too, which filled in some fields, but still doesn't change the Sandbox balance of my account. 我也尝试了INITAMT,它填充了一些字段,但仍然没有更改我帐户的沙盒余额。 Any ideas guys? 有想法吗? Here's the code: 这是代码:

    <?php
// Set PayPal API version and credentials.
$api_version = '85.0';
$api_endpoint = 'https://api-3t.sandbox.paypal.com/nvp';
$api_username = 'MY_SANDBOX_USERNAME';
$api_password = 'MY_SANDBOX_PASSWORD';
$api_signature = 'MY_SANDBOX_SIGNATURE';

$startdate = gmdate('Y-m-d')."T00:00:00Z";
$request_params = array
               (
'USER' => $api_username, 
'PWD' => $api_password, 
'SIGNATURE' => $api_signature, 
'VERSION' => $api_version, 
'METHOD' => 'CreateRecurringPaymentsProfile',
'PROFILESTARTDATE' => $startdate,
'DESC' => 'Membership',
'BILLINGPERIOD' => 'Month',
'BILLINGFREQUENCY' => '1',
'TOTALBILLINGCYCLES' => '0',
'AMT' => '2.50',
'MAXFAILEDPAYMENTS' => '12',
'ACCT' => '4641631486853053',
'CREDITCARDTYPE' => 'VISA',
'CVV2' => '123',
'FIRSTNAME' => 'James',
'LASTNAME' => 'Smith',
'STREET' => 'FirstStreet',
'CITY' => 'London',
'STATE' => 'G London',
'ZIP' => 'W2 1NE',
'COUNTRYCODE' => 'GB',
'CURRENCYCODE' => 'GBP',
'EXPDATE' => '052015'
               );

// Loop through $request_params array to generate the NVP string.
$nvp_string = '';
foreach($request_params as $var=>$val)
{
   $nvp_string .= '&'.$var.'='.urlencode($val);   
}
// Send NVP string to PayPal and store response
$curl = curl_init();
      curl_setopt($curl, CURLOPT_VERBOSE, 1);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt($curl, CURLOPT_TIMEOUT, 30);
      curl_setopt($curl, CURLOPT_URL, $api_endpoint);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);

$result = curl_exec($curl);      
curl_close($curl);
$nvp_response_array = parse_str($result);
print_r($result);
?>

I took your code and used my own sandbox credentials. 我获取了您的代码,并使用了自己的沙盒凭据。 It seems to have worked just fine for me. 这似乎对我来说很好。

在此处输入图片说明

It came through as unclaimed since my account is USD, but you can see it did work just fine. 由于我的帐户是美元,因此它没有人认领,但是您可以看到它确实正常工作。 Are you sure you're checking the correct sandbox account after you run it yourself? 自己运行沙箱帐户后,确定要检查正确的帐户吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM