Paypal payouts tracking - paypal

I use paypal REST api (sanbdbox). I need to make automatic payouts, track it, get the list of all payments (including created payout via REST api). I managed creating single batch payout and get status for it. But I can't get list of all payments (income and outcome) and match my payouts.

When you create a payout store the sender_batch_id you use, and when you get a response store the payout_batch_id / payout_item_id then update poll the status using
/v1/payments/payouts/payout_batch_id
or
/v1/payments/payouts-item/payout_item_id
Preferably instead use the webhooks API to get a notification when the status changes, then update the status accordingly.
Either of these approaches requires you to somehow keep track of your own payouts. I do not see a way to list previously submitted payouts in the REST API. There are of course many ways you could organize and track your requests.

Related

API callback from Paypal when there is dispute or refund

I am trying to setup a website with a backend to capture papal orders and payments using their orders API.
Everything is expected to be controlled using code so is there any way paypal will send a callback when there is a dispute or customer asks for a refund ? i.e. if there are many orders it would be hard to keep track of disputes by reading emails.
Yes, check out the PayPal API documentation. The Disputes API is what you are looking for.
Set up a webhook listener on the REST app for the events you want to listen to (specify * for all). There are events for disputes and refunds; see the list in the PayPal documentation

Automatically capture a order in PayPal

I'm integrating my application with PayPal and i found a problem.
I use PayPal REST API with intent: "CAPTURE".
After I create an order in paypal via /v2/checkout/orders POST endpoint and client pay for this order in https://www.sandbox.paypal.com/checkoutnow?token={TOKEN} website I don't receive any money or transaction on my PayPal business account.
When I check this order status it says that it is APPROVED but not COMPLETED, so i need to capture this order via v2/checkout/orders/{TOKEN}/capture POST endpoint. After capturing this order is has status: COMPLETED and i receive money.
Is It possible to automatically capture an order without any additional request to capture it?
Because when I use PayPal button It works automatically and I want to have the same result using REST API.
No, it's not possible. The capture step is required.
Whether you use a client-side integration: https://developer.paypal.com/demo/checkout/#/pattern/client
Or a front-end UI that calls server-side routes of yours: https://developer.paypal.com/demo/checkout/#/pattern/server
The capture step after approval (within onApprove) is always required.

Is IPN required to detect cancellation of REST created Subscriptions?

I have REST API created Payment Plans and agreements and would like to be able to detect when a user cancel an agreement. My original take on this was that the cancel_url on the merchant_preferences object for billing_plan would be used if a users canceled the agreement through the PayPal API, but I am not seeing any callbacks coming in so perhaps this is incorrect?
I have seen plenty on information on IPN processing cancellations and I would love to know if that is the only way to receive a cancellation notification or should I be using another field in the REST API to set this up?
I'm not against using IPN (hey whatever gets the job done!), but it seems to me that the REST API should have its own capabilities for achieving this as well.
Hey this is Avi from PayPal. Refer to this github issue for information about getting IPN notifications for subscription events.
The REST API does have webhooks, and work is in progress to support subscription events for webhooks as well.

GET list of billing agreements using Paypal REST api

I am working with the relatively new Paypal REST api and have successfully been able to create billing plans, approve billing plans, get a list of my billing plans, create billing-agreements (subscriptions), execute billing-agreements, and find specific billing-agreements.
I would like to be able to retrieve (GET) a list of billing-agreements, similar to how I can get a lit of billing-plans. This is not shown in the documentation as being available. Does anyone know of a way of doing this? Since there is no webHook available for subscription cancellations (or any subscription events) and no way to get a list of agreements, this leaves developers with no efficient way to handle cancellations (especially since users can cancel via Paypal without visiting the site). My current method/plan to handle this is to loop through all subscriptions that I have stored in my MongoDB (I store them when they are executed successfully), and send a request to Paypal for that specific agreement. I check its 'state' and update my MongoDB if they don't match.
There must be a better way.
I had the same problem, my first solution was almost identical to yours: I query the state of agreement upon user login and update the state in my db accordingly.
Later, I start to use IPN as my solution as suggested in this github comment by Tony: https://github.com/paypal/PayPal-Python-SDK/issues/69#issuecomment-69647946

Paypal REST API and Chargebacks/Cancellations

I have been working paypal integration to an existing system of ours and successfully done tests on sandbox by using rest api and express checkouts.
Although documentation is detailed, I couldnt see anything about chargeback (i.e reverse transactions) and cancellations on rest api documentation page http://developer.paypal.com/docs/api/
So in case a user buys something successfully and the payment status becomes "completed", then there is a reverse transaction like chargeback, paypal will send a request to the return and cancel urls which are predefined while creating the related payment, or the client application has to check the payment statuses manually by rest calls? Or are there any other configs that I need to send while triggering the very first payment request?
You'll need to setup Instant Payment Notification (IPN) to handle that sort of thing.
IPN will automatically POST data about all transactions that hit your PayPal account to a URL you specify. This URL (a script) can receive the data and update your database, generate email notifications, or anything else you might want to automate based on the transactions.
You can handle all sorts of things with IPN. For chargebacks specifically, you would receive an IPN with the following params...
txn_type=new_case
case_type=chargeback
Of course, you'll get a bunch more parameters, too, but those would be how you can pick out the chargebacks and processing them accordingly.