【问题标题】:Paypal Recurring Payment - Charge immediately?Paypal 定期付款 - 立即收费?
【发布时间】:2016-08-03 10:40:17
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    您可以在为快速结账创建定期付款配置文件时收取初始金额。 这是来自 PayPal 开发者网站的the documentation
    CreateRecurringPaymentsProfile API 调用中,您需要使用变量INITAMT

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

    INITAMT

    (可选)初始非经常性付款金额应立即到期 个人资料创建。使用初始金额来支付注册费或设置费。

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

    字符长度和限制:

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

    【讨论】:

      猜你喜欢
      • 2013-09-20
      • 2016-09-03
      • 2019-04-09
      • 2015-02-26
      • 2014-04-06
      • 2012-02-10
      • 2014-02-27
      • 2015-10-04
      • 2012-12-03
      相关资源
      最近更新 更多