0

我正在使用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') 





); 

寶結果:

[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 

回答

0

您可以創建快速結賬定期付款資料時收取初始確認金額。 下面是從PayPal的開發者網站
CreateRecurringPaymentsProfile API調用the documentation,你將需要使用可變INITAMT

下面是來自PayPal的開發者網站的詳細信息:

INITAMT

(可選)在 配置文件創建後立即支付的初始非經常性付款金額。使用初始金額註冊或設置費用。

注意:請求中包含的所有金額必須具有相同的貨幣。

字符長度和限制:

值通常爲正數不能超過10,000.00美元 或每次交易上限爲貨幣。它包括沒有貨幣 的符號。大多數貨幣需要兩位小數;小數點 分隔符必須是句點(。),並且可選千位分隔符 必須是逗號(,)。一些貨幣不允許小數。有關詳細信息,請參閱 貨幣代碼頁。