GET transaction information from a specific PayPal transaction using Webhooks and PayPal API in Zapier - paypal

UPDATE: After troubleshooting on postman, I've found that start_date and end_date are nessesary fields. Everything now works fine on postman with 200 code. However I am still getting a 400 error on zapier...
I've managed to POST my API credentials and generate an access-token from the previous step in my zap sequence using a Webhook. I then used this token in a GET Webhook in the next step to try and retrieve transaction information (PayPal processing fee, etc...) using transaction_id and fields queries. The transaction ID I am using is being pulled from an actual Woocommerce order on our store, where the customer decided to use PayPal (I've also searched the ID in paypal and it is valid).
The reason I'm doing this is to try and pull extra information from PayPal- Such as payment processing fees about the transaction that Woocommerce does not provide through their app on Zapier.
Unfortunately I am seeing the following error 'The app returned "Invalid request - see details."'
I suspect it is because I am calling for the information incorrectly. In my mind, I am using transaction_id as the unique identifier for the specific transaction, and fields to retrieve all information regarding the transaction.
Error code in Zapier: "Status Code 400 Bad Request" - PayPal docs state: "INVALID_REQUEST. Request is not well-formed, syntactically incorrect, or violates schema"

Update: If you use this method to pull transaction information, you will need to set a delay long enough where the activity time on your paypal dashboard switches from a time to a date (meaning it is the next day). If you don't do this, no important information will be pulled.
I've figured it out. If anyone has a similar issue, set it up like this (probably use more dynamic dates though):

Related

PayPal Subscriptions: validating success on a server

I apologize in advance for this question, as its probably rather silly, but I really can not find any answers elsewhere.
My current goal is to integrate a subscription to my website, that allows for a user to have access to certain parts of the site.
I've watched a few videos on it, but it leaves me open ended with some questions.
PayPal allows you to manually create a subscription plan at https://www.paypal.com/billing/plans. When you create a plan here, it gives you the code you need to get the pay pal sub buttons to display on the page. Users can then use them to create the subscription. This is great. However, I have found now way to validate the results of the transaction. My goal would be that if the user was successful, I would be able to retrieve data via the API, that says it was successful, and I could then store than information in my database, and grant them access. Does anyone know how to get the data from the manually created facebook plans?
I did watch a video that had you do everything from your website (you create it all within your own code), the end result however sent everything through $_GET variables in the url. I feel like having this data exposed could result in the manipulation of the subscription, and grant it to users who were unsuccessful in creating a subscription.
I have no problem doing all of the coding to make this work, but I really want to make sure I do it the best possible way.
There is a few way to do it. By setting up a webhook and listen to paypal success notification and react to it. By using the Paypal Subscription API. Or a combination of both.
As you are using the paypal button you will have the onApprove function which will trigger upon user confirming the subscription. You can query the subscription data with:
onApprove={async (data: any, actions: any) => {
const detailedSubscriptionData = await actions.subscription.get()
// activate subscription on your side by sending it to your backend
...
// etc.
}}
Inside the data you have queried above, there will be a paypal transaction id (I-....) that is unique for each transaction, as well as your product id (plan_id). You can now do the following for verification on your backend:
Check if there is already a subscription (from another customer) on your side with that paypal transaction id
Check for the plan_id
Queried the API Subscription Details with the paypal transaction id and check for status, etc. as well as matching of plan_id
Keep in mind that for using the API you will have to queried for an access-token which in turn required you to have Developer App Setup following these steps.

Paypal - Get the order identifier out of transaction identifier

I could not find info in the documentation on how to grab an order id out of the capture id that I receive from the daily transaction detail report. The only way I found was to check the links field in the capture after the capture gets the request, however, that does not seem like the best way to do it.
Does anyone know how to achieve it directly?
If you are using the Orders V2 API, the Order ID is only used during checkout approval. It is not persisted after transaction creation, and looking up captured payment details with the transaction/capture id: https://developer.paypal.com/docs/api/payments/v2/#captures_get , will not return the Order ID used during checkout, since it is not useful for anything at that point.

PayPal Express Checkout Error 10623

(All sensitive information will be replaced by *'s)
I'm having issues doing multiple authorizations on my order transaction through the paypal Express checkout. My order transaction looks as such:
PARTNER=*****&VENDOR=*****&USER=*****&PWD=*****&TENDER=P&TRXTYPE=O&ACTION=D&AMT=186.76&PAYERID[13]=*************&TOKEN=************&COMMENT1=w2279400&COMMENT2=
Which is approved:
RESULT=0&PNREF=B7PP7D067BC7&RESPMSG=Approved&AVSADDR=Y&AVSZIP=Y&TOKEN=*****&PAYERID=****&PPREF=*****&CORRELATIONID=ebf6245de4f4e&PAYMENTTYPE=None&PENDINGREASON=order
I then do my first authorization, followed by a delayed capture:
PARTNER=*****&VENDOR=*****&USER=*****&PWD=*****&TENDER=P&TRXTYPE=A&ORIGID=B7PP7D067BC7&AMT=92.32&COMMENT1=I2279400&COMMENT2=
PARTNER=*****&VENDOR=*****&USER=*****&PWD=*****&TENDER=P&TRXTYPE=D&ORIGID=*****&AMT=92.32&CAPTURECOMPLETE=N&COMMENT1=I2279400&COMMENT2=
These return approved. I then try an do my second authorization:
PARTNER=*****&VENDOR=*****&USER=*****&PWD=*****&TENDER=P&TRXTYPE=A&ORIGID=B7PP7D067BC7&AMT=94.44&COMMENT1=M2279400&COMMENT2=
However, this one fails with the following:
RESULT=12&PNREF=B7PP7D067BE3&RESPMSG=Declined: 10623-Maximum number of authorization allowed for the order is reached.
I can't seem to find anything really related to this message, other than it can be prompted by providing an amount of 106.23(which I'm clearly not doing)
Any help would be appreciated.
Thanks

Payments Callback URL not being call after new local currency changes

After switching to the new Facebook local currency API the process is working, but
my server is not involve in the process so i really don't know if the user bought coins cause the payment callback URL is not being called now (using static payment).
I tried to use real time update to get Facebook data but can make it work, what is the best practice to involve the server in the process so it will be aware of the purchase?
I prefer for security reasons to get the update from Facebook and not from my client.
Ok after searching a log i found the solution
There are two primary methods through which you are notified of the outcome of the purchase, and a further method by which you can verify any payment information.
Firstly, Facebook will return details of the order via a JavaScript callback. The data sent to this callback includes:
payment_id, which uniquely identifies the transaction.
quantity, which indicates the amount of the item which was sold.
request_id, optionally, the developer can provide their own unique identification for the transaction when calling our Javascript SDK to render the payment dialog. This value is then returned upon purchase completion.
status, which indicates the current state of the transaction, i.e. 'pending', 'completed', 'failed' etc.
Secondly, Facebook will issue a realtime update notifying the developer that a new order has completed. The developer can subscribe to the payment_object callback to track order completions, using the payment_id as the unique identity parameter for each transaction.
Thirdly, at any time, the payment_id can be used to verify details of a transaction via the Graph API. Details such as the associated user_id, updated_time and amount can be queried, using the payment_id. The Graph API will also allow you to access further details including any refunds or disputes associated with the transaction.
If for some reason both the JavaScript callback and the realtime update fail and you do not receive the payment_id, we also allow you to query the Graph API using the optional request_id parameter, which can be specified by the developer when invoking the Facebook payment dialog.
please refer to:
https://developers.facebook.com/docs/concepts/payments/
and to:
https://developers.facebook.com/docs/howtos/payments/fulfillment/#rtu

paypal ipn notification twice

My notification script is launched twice first is VERIFIED and second INVALID.
I've tried different ipn validation scripts and always get it twice.
I'm using sandbox maybe seller account settings are not right? I've set IPN on with notify url and auto return. Also in form there is return and notify_url set
I remember in the documentation it states that duplicates are possible -- that's just the nature of the internet. That's why it gives you a unique transaction ID. You're supposed to use that to prevent bad things from happening if you get notified twice.
A better question might be: why does it say Verified and then Invalid? Or is that ok?
EDIT
The docs say "PayPal sends a single word back, which is either VERIFIED if the message originated with PayPal or INVALID if there is any discrepancy with what was originally sent". I'm going to guess that YOUR code accidentally sends the "echo" back to PayPak twice and one of them is malformed. Maybe they're both identical but PayPal responds with INVALID if it gets it twice. But no matter, for a particular transaction Id, once you get VERIFIED, you're good. Simply ignore all subsequent responses.
EDIT 2
The return url is simply used by PayPal to redirect the user back to your site. Use this page to thank them for their purchase and inform them they will be notified once processing is complete. You can even set this to an empty string if you don't want this feature. When Payment is actually complete (or some problem was identified), PayPal will invoke the script referenced by the notify url. This is where you make sure everything looks right, handle duplicate notifications, update your database, send an email to the user saying their payment was processed, etc.
before inserting or updating your mysql query Check if the returned Transaction id '$_POST['txn_id']' already exists in your db table, if it doesnt exists so insert it with other $_POST data, because paypal calls the notify url many times.