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