简体   繁体   English

Paypal IPN,在哪里将我的订单ID放入Paypal SDK(Android)中以验证通过我的服务器付款?

[英]Paypal IPN, where to put my order id in paypal sdk (android) to verify payment through my server?

I implemented Paypal payment to my Android App(like here: http://androiddevelopmentanddiscussion.blogspot.de/2014/05/paypal-integration-in-android.html ) . 我在我的Android应用中实现了Paypal付款(例如: http : //androiddevelopmentanddiscussion.blogspot.de/2014/05/paypal-integration-in-android.html )。

First, I contact my server to get an order_id to my Android device. 首先,我联系我的服务器以将order_id发送到我的Android设备。 After that the user is able to make payment with Paypal (sandbox), I can see that the payment was successful and my Android client gets a response back from Paypal("PaymentConfirmation info received from PayPal") together with a paypal "confirm" object. 在用户能够使用Paypal(沙盒)进行付款之后,我可以看到付款成功,并且我的Android客户端从Paypal(“从PayPal收到的PayymentConfirmation信息”)和Paypal“确认”对象返回了响应。

I could then use that confirm object to send it back to my server and mark the payment as succeeded(for that I would use the order_id). 然后,我可以使用该确认对象将其发送回我的服务器,并将付款标记为成功(为此,我将使用order_id)。 But there is a problem. 但有一个问题。

What happens, if the internet connection gets interrupted? 如果互联网连接中断怎么办? I would not be able to mark the payment as succeeded into my server database. 我将无法将付款标记为成功到我的服务器数据库中。 I know, that there is the possibility to get a IPN message from Paypal to my server and could use that to mark payment as succeed. 我知道,可以将来自Paypal的IPN消息发送到我的服务器,并可以使用该消息将付款标记为成功。 But how could I pass the order_id into my payment, so that the IPN message, which is sent by Paypal after successful payment to my server, contains that order_id? 但是,如何将order_id传递到我的付款中,以使Paypal在成功付款到我的服务器后发送的IPN消息包含该order_id?

I need that order_id to identify my customer and the order... I could not find any useful information regarding that topic. 我需要那个order_id来识别我的客户和订单...我找不到有关该主题的任何有用信息。 I do not know how to achieve that. 我不知道该如何实现。 I can only pass following information to my Payment: 我只能将以下信息传递给我的付款:

  if(pressed.getId() == R.id.button1){
   thingToBuy = new PayPalPayment(new BigDecimal("8"), "USD", "Painting 1", PayPalPayment.PAYMENT_INTENT_SALE);

Any tips are much appreciated. 任何提示,不胜感激。 (sorry for my english, I am not a native english speaker) (对不起我的英语,我不是说英语的人)

PayPal's IPN service will continue to re-send IPNs until it gets a 200 OK response back from your server. PayPal的IPN服务将继续重新发送IPN,直到从服务器返回200 OK响应为止。 So the IPNs should catch themselves up once your internet connection is good again after an outage. 因此,一旦您的互联网连接中断后,IPN就会恢复正常。

You can also resend IPNs manually from the IPN History page in your PayPal account. 您也可以从PayPal帐户中的“ IPN历史记录”页面手动重新发送IPN。 If you're talking about hundreds or thousands that probably isn't an option, but it would be if you don't have that many to catch up on. 如果您谈论的是成百上千种,那可能不是一个选择,但是如果您没有那么多,那么您就可以选择。

Another option would be to use the TransactionSearch and GetTransactionDetails APIs to sync any transactions that got missed by IPN. 另一个选择是使用TransactionSearchGetTransactionDetails API来同步IPN错过的任何事务。 This is something some people like to do anyway just to be sure IPN didn't miss anything. 无论如何,这是某些人喜欢执行的操作,只是为了确保IPN不会丢失任何内容。

There is a method called "invoiceNumber" in PaypalPayment class to set the invoice number. PaypalPayment类中有一种称为“ invoiceNumber”的方法来设置发票编号。

You can use it to set the invoice number so the IPN can fire it back to your server. 您可以使用它来设置发票编号,以便IPN可以将其发送回您的服务器。

ie

String yourOrderNumber = "test"; 字符串yourOrderNumber =“ test”; thingToBuy.invoiceNumber(yourOrderNumber); somethingToBuy.invoiceNumber(yourOrderNumber);

BTW, if you pass the result object back to the server, you may need to verify your payment. 顺便说一句,如果将结果对象传递回服务器,则可能需要验证付款。 Things you may consider to avoid fraud (according to the paypal document) 您可能考虑避免欺诈的事情(根据Paypal文件)

  1. Is the proof of payment authentic? 付款证明是真实的吗?
  2. Am I the recipient of the payment? 我是付款的收款人吗?
  3. Are the amount and currency correct? 金额和货币正确吗?
  4. Has the payment been previously used? 付款是否曾经使用过?

In my experience, what I did was to leave the IPN do the confirm payment part. 根据我的经验,我所做的就是让IPN负责确认付款。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM