2012-10-26 51 views
0

我已经实施IPN处理程序(copt从代码项目中粘贴它)第一次在其中一个项目中。Paypal IPN处理程序 - 如何知道谁的交易发生

在用户的问题可以注册到我的网站有一些电子邮件地址,然后同时支付他可以用一些不同的电子邮件地址

而且IPN处理程序请求变量给其所支付的电子邮件地址。我应该如何找出哪个用户付了钱。

if (strResponse == "VERIFIED") 
     { 
      //check the payment_status is Completed 
      //check that txn_id has not been previously processed 
      //check that receiver_email is your Primary PayPal email 
      //check that payment_amount/payment_currency are correct 
      //process payment 

      string payerEmail = Request.Form["payer_email"]; 
      string paymentStatus = Request.Form["payment_status"]; 
      string receiverEmail = Request.Form["receiver_email"]; 
      string amount = Request.Form["mc_gross"]; 
     } 

解决方案:

通过一些addiditonal可能是在支付处理页面的用户ID,并假设它会在IPN处理程序返回。

或者要求用户在付款前输入paypal电子邮件地址。 (不是感觉很好)

在这方面的任何帮助表示赞赏

回答

3

我平时POST,车信息,识别我的本地事务,或我的本地车的自定义字段中。 IPN会将该自定义字段发回给您,以便您可以将交易与您的用户进行匹配。或者您可以传递USER_ID,然后无论交易如何都可以取回。

发送贝宝使用此字段中表单自定义数据:在回调

<input type="hidden" name="custom" value="YOUR_CUSTOM_INFO_HERE"> 

手柄IPN:

if (strcmp ($res, "VERIFIED") == 0) { 
    // This is the custom field i posted within the cart form. 
    $cid = $_POST['custom']; 
    $txn_id = $_POST['txn_id']; 
    $cart = load_cart_by_cid($cid); 
    if (!empty($cart)) { 
    // Fetch your user from cart and do things with it, 
    // along with your security checks. 
    $user = $cart->getUser(); 
    // For example, store the transaction. 
    TransactionManager::saveTransaction($user, $txn_id); 
    } 
} 

来源是PHP的,但我认为是冗长足以很容易地转换在java中,或c#,或其他。