Adam Ri
Adam Ri

Reputation: 517

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) .

First, I contact my server to get an order_id to my Android device. 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.

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). 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. 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?

I need that order_id to identify my customer and the order... I could not find any useful information regarding that topic. 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)

Upvotes: 0

Views: 357

Answers (2)

Guoyu Chen
Guoyu Chen

Reputation: 11

There is a method called "invoiceNumber" in PaypalPayment class to set the invoice number.

You can use it to set the invoice number so the IPN can fire it back to your server.

i.e.

String yourOrderNumber = "test"; thingToBuy.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)

  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.

Hope it helps.

Upvotes: 1

Drew Angell
Drew Angell

Reputation: 26036

PayPal's IPN service will continue to re-send IPNs until it gets a 200 OK response back from your server. So the IPNs should catch themselves up once your internet connection is good again after an outage.

You can also resend IPNs manually from the IPN History page in your PayPal account. 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. This is something some people like to do anyway just to be sure IPN didn't miss anything.

Upvotes: 0

Related Questions