Paypal定期付款 - 立即收费?

时间:2016-04-12 17:02:14

标签: paypal paypal-ipn paypal-sandbox paypal-adaptive-payments paypal-subscriptions

我正在使用Paypal API并且我想创建定期付款,应立即收取第一笔金额。我需要知道它是否成功解锁了用户的内容。我怎么能在世界上实现这一目标呢?

$fields = array(




    'USER' => urlencode('email'),

    'PWD' => urlencode('pass'),

    'SIGNATURE' => urlencode('signature'),

    'METHOD' => urlencode('GetExpressCheckoutDetails'),

    'VERSION' => urlencode('86'),

    'TOKEN' => urlencode($_GET['token'])




);


//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');




$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api-3t.sandbox.paypal.com/nvp");
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


$server_output = curl_exec ($ch);

curl_close ($ch);




// Get PAYERID of 1. query

$payerid = parseNVP($server_output);

$payerid = $payerid['PAYERID'];





$fields2 = array(




    'USER' => urlencode('Email'),

    'PWD' => urlencode('Pass'),

    'SIGNATURE' => urlencode('Signature'),

    'METHOD' => urlencode('CreateRecurringPaymentsProfile'),

    'VERSION' => urlencode('86'),

    'TOKEN' => urlencode($_GET['token']),

    'PAYERID' => urlencode($payerid),

'PROFILESTARTDATE' => urlencode(date('Y-m-d').'T'.date('H:i:s', strtotime('-5 minutes')).'Z'),

'DESC' => urlencode('FitnessMembership'),

'BILLINGPERIOD' => urlencode('Day'),

'BILLINGFREQUENCY' => urlencode('1'),

'AMT' => urlencode($price),

'CURRENCYCODE' => urlencode('USD'),

'COUNTRYCODE' => urlencode('US'),

'MAXFAILEDPAYMENTS' => urlencode('3')





);

Paypal结果:

 [2016-04-12 12:50 America/New_York] Verified IPN:cmd=_notify-validate&
payment_cycle=Daily&
txn_type=recurring_payment_profile_created&
last_name=Mustermann&
next_payment_date=03%3A00%3A00+Apr+12%2C+2016+PDT&
residence_country=US&
initial_payment_amount=0.00&
currency_code=USD&
time_created=09%3A49%3A25+Apr+12%2C+2016+PDT&
verify_sign=AJjtUEC2-zvkp.2Yz8a-.FGmZ2b3AoUov3DJ70yddjCmc1KidQVDeZHd&
period_type=+Regular&
payer_status=verified&
test_ipn=1&
tax=0.00&
payer_email=gut%40gut.de&
first_name=Hendrik&
receiver_email=hendrik.tewes-facilitator%40live.de&
payer_id=6AJ2HHWAPZSF6&
product_type=1&shipping=0.00&
amount_per_cycle=119.00&
profile_status=Active&
charset=windows-1252&
notify_version=3.8&
amount=119.00&
outstanding_balance=0.00&
recurring_payment_id=I-8P0534LSX2A3&
product_name=FitnessMembership&
ipn_track_id=59fede576b95c

1 个答案:

答案 0 :(得分:0)

您可以在为快速结账创建定期付款资料时收取初始金额。 以下是PayPal开发者网站的the documentationCreateRecurringPaymentsProfile API调用中,您需要使用变量INITAMT

以下是PayPal开发者网站的更多信息:

  

INITAMT

     

(可选)立即到期的初始非经常性付款金额   档案创作。使用初始金额注册或设置费用。

     

注意:请求中包含的所有金额必须使用相同的货币。

     

字符长度和限制:

     

价值通常为正数,不能超过10,000.00美元   或货币的每笔交易限额。它不包括货币   符号。大多数货币需要两位小数;小数   separator必须是句点(。)和可选的千位分隔符   必须是逗号(,)。某些货币不允许小数。见   货币代码页面了解详情。