Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Paypal 我如何创建一个IPN,当用户购买会员资格、取消会员资格等时更新我的数据库?_Paypal_Paypal Ipn - Fatal编程技术网

Paypal 我如何创建一个IPN,当用户购买会员资格、取消会员资格等时更新我的数据库?

Paypal 我如何创建一个IPN,当用户购买会员资格、取消会员资格等时更新我的数据库?,paypal,paypal-ipn,Paypal,Paypal Ipn,我如何创建一个IPN,当用户购买会员资格、取消会员资格等时更新我的数据库 还希望确保我已将需要的信息安全地传递到我的数据库并进行相应更新。要创建定期付款,请使用此html表单: <form method="post" name="formName" id="submitThisForm" action="https://www.paypal.com/cgi-bin/webscr" > <input type="hidden" name="cmd" value="_xclick-

我如何创建一个IPN,当用户购买会员资格、取消会员资格等时更新我的数据库


还希望确保我已将需要的信息安全地传递到我的数据库并进行相应更新。

要创建定期付款,请使用此html表单:

<form method="post" name="formName" id="submitThisForm" action="https://www.paypal.com/cgi-bin/webscr" >
<input type="hidden" name="cmd" value="_xclick-subscriptions">
<input type="hidden" name="business" value="your@papypamail.com" />
<input type="hidden" name="item_name" value="Your Membership" />
<input type="hidden" name="a3" value="0.01">
<input type="hidden" name="p3" value="1"> 
<input type="hidden" name="t3" value="M">
<input type="hidden" name="src" value="1">
<input type="hidden" name="sra" value="1">
<input type="hidden" name="item_number" value="2" />
<input type="hidden" name="custom" value="SECURITYCODE" />
<input type="hidden" name="currency_code" value="USD" />
<input type="hidden" name="quantity" value="1" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="return" value="page going after payment" />
<input type="hidden" name="cancel_return" value="" />
<input type="hidden" name="cbt" value="ITEM DESCRIPTION" />
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="notify_url" value="your_listener_file.php" />
  • 第二个-检查是否使用唯一键在数据库中存在事务。您必须使用Paypal POST变量“custom”

  • 如果事务存在,只需进行一些简单的检查:

    if( !empty($_POST['txn_type']) && $_POST['txn_type'] == 'subscr_cancel' )
        $paypalData['approved'] = 0;
    

  • 为什么我必须使用Paypal POST变量“custom”?我想我可以对照我的DB检查txn_id以查看事务是否存在?我想您应该使用自定义变量将事务分配给某个用户或其他用户。通常我使用这个“自定义”变量。设置一些唯一的代码以提高安全性。查看上面的html表单最重要的是设置您的paypal IPN url,例如notify_url表单中的your_listener_file.php-
    if( !empty($_POST['txn_type']) && $_POST['txn_type'] == 'subscr_cancel' )
        $paypalData['approved'] = 0;