0
votes

I have following design problem: In my website you post a thread and then checkout with the paypal button. The paypal button sends costum data like thread.content and regular fields like payerID, paymentID, ... to proceed the payment. The payment finally gets executed via

request.post(PAYPAL_API + '/v1/payments/payment/' + paymentID +
        '/execute', ...,
            function(err, response){
        //here I insert into Database a new thread with costum data
});

Now after payment gets finally executed Webhook fires up, and triggers my IPN Listener. I want to confirm and update the database with status "completed" "pending" "mc_gross-mc_fee" ect..., but here I have a problem to identify the current IPN Event with the Database row. While inserting INTO database I could also insert "paypal-debug-id" which I also can find in the IPN "ipn_track_id", but I don't know if this is a good way to identify my database element.

1

1 Answers

1
votes

Some notes:

  • There is a newer v2/checkout/orders API, which replaces the v1/payments API.
  • v1/payments/../execute and v2/checkout/orders/../capture already give you an authoritative 'COMPLETED' response. There is no need to wait for an IPN to know that a transaction has completed.
  • IPN is an ancient service anyway , replaced by the current webhooks

Anyway, if you wish to reconcile asynchronous messages from IPN/webhooks with your orders, you can use the invoice field or equivalent (which must be unique for every transaction), or custom / custom_id (which may contain anything). The custom field is not displayed to the payer in their transaction details, while the invoice field is.

Another method is to simply store the sale id (v1) or capture id (v2) from the execute/capture API call, since at that point the transaction has already completed. This will let you reconcile with the IPN or webhook's transaction ID, for whatever reason you're bothering to do that.