Retrieve transaction ID via rest API - paypal

My application uses PayPal java library to make payments. Everything works fine but I can't understand one thing. What exactly is transaction code? Let's say I make a payment and then approve it. As a result I receive the JSON object which has an ID (PAY-*) and transactions->related resources->sale->ID. Both of them I store in the DB in order to show later to user (in case he wants to refund the money). But if I see these payments from PayPal customer portal, in the descriptions of payment I see non of these ID's.. Transaction code is totally different! So which one of them should I store?
Thank you in advance

PayPal generally uses a transaction ID. It's a 16 character alphanumeric string. This will appear in both your API response and the PayPal site. Assuming REST is like Classic, the Transaction ID is how you will reference the payment for any future operations (capture, refund, etc).
Please note that if you're using Express Checkout (where the customer pays via PayPal account) they will have their own transaction ID for the exact same transaction.

Related

Paypal v2 API how to get transaction data and also how to make a refund

My problem is as follows:
I have a business paypal account where I have a list of transactions made by my clients (buying products on my webpage). I store their orders info via paypal IPN which only sends me the transaction ID of the order. So I store this transaction ID on my database among other basic data.
Now I need 2 things:
Retrieve the transaction data via php code.
Make refunds of any transaction also via php code.
I see Paypal API v2 is the recommended as the v1 is gonna be abandoned. I'm using Checkout-PHP-SDK:
https://github.com/paypal/Checkout-PHP-SDK
But I'm facing problems only trying to get any transaction data. I read that in order to get the data i cannot use the transaction ID but the order ID instead. But how can use an order ID that I ignore?, because from paypal IPN I only receive transaction ID and that's only what I have. So how can I get the order id from this transaction id?. I know I'm probably confusing terms so sorry in advance.
When you capture an order, the immediate API response already contains all information about the transaction -- including the transaction ID at purchase_units[0].payments.captures[0].id. There is no need to use the old IPN service. Your integration should not depend on IPN in any way, that is bad design.
For refunds, use that transaction (capture) id with the v2/payments API

Integrating Paypal Payment and Invoicing APIs

I have been manually issuing invoices to charge my clients for services using Paypal.
Now I am creating an interface to allow them to purchase the services automatically on my website.
I also want to show them a history of their purchases. However, I cannot show a history of paid invoices using the Transaction Search API; I need to use the Invoicing > Search Invoices API.
I have used the Paypal Payments API to manage the payment side of new products, which now correctly produces an itemised transaction and allows the customer to checkout. But this does not produce an invoice.
How can I simultaneously produce an invoice (i.e which can be retrieved by the Invoicing API to show previous payments) and allow the customer to pay it? It seems like the Invoicing API works around the idea of sending an invoice to client by email, but this is unnecessary. I want them to pay it immediately (and already have the Payment API setup for this).
So what would a useful workflow be?: Use my Paypal Payment API to receive and authorise the payment, and on authorisation, use the Invoicing API to produce an invoice which reflects this and then updates the invoice status to paid? Or am I missing something easier here?
The Invoicing API is not meant to be mixed or used with any other API. It is for generating invoices to be sent by email or in link form.
General ecommerce payment processing (without invoice links) is entirely separate, there is no crossover. You should ensure you are using the current v2/checkout/orders API to receive new payments, not older v1 APIs.
As far as displaying a list of previous purchases to your customers, you shouldn't reply on PayPal for this (except perhaps in the case of invoices since this is part of the point of offloading invoice management to PayPal). But for normal web purchases, PayPal is not a database -- it is a payment processing service. Keep track of all your own order information, and simply store PayPal transaction IDs when they complete for your own accounting records -- but the ID you reference with the customer should be your own unique order ID, which you can pass to PayPal in your purchase_units[0].invoice_id when you create an order for checkout approval.

PayPal - Pass Customer ID from my website - Receive confirmation with same Customer ID from my website

I am working on a software service and am offering a monthly subscription for my software service.
I am currently working on the subscription part - and am wanting to implement a paypal monthly recurring payment solution.
I have spent quite a bit of time looking over PayPal documentation, and trying different buttons, webhooks, IPN methods etc.
The problem is that I am not sure what solution to use - because I am confused by the multiple options.
What is most important to me is - that when the customers fill out the form on my website - and are then directed PayPal to pay - I then want to know that specific Customer ID from my website has successfully paid.
I would like to know:
Which SPECIFIC option(s) PayPal has that I can pass Customer ID from my website of that customer - let's say a subscription ID from my site - and that PayPal will then send the customer back with my subscription ID, that I passed them on to PayPal with.
Which is the easiest option to do that with?
I simply want the customer to:
sign up at my site. (my part)
be issued a unique Customer ID from my website (my part)
click a PayPal payment/subscribe button (my part)
be sent to PayPal to pay for the subscription (paypal's part)
be returned to my site with the unique Customer ID from my website from my site - as well as a confirmation of payment from PayPal (paypal's part)
Please do not simply pass me to the general area of the development sections -
As I said - I have already been through all of that and find there is too much information.
Please direct me to a specific solution, or example, or tutorial that covers a solution that will fit what I need.
I would recommend using the Express Checkout API with Recurring Payments.
The best thing to do would be to create a local invoice record in your system, and then have a related customer ID associated with that invoice.
In the CreateRecurringPaymentsProfile request to PayPal you can include a PROFILEREFERENCE parameter, which would be the invoice ID you generated for that order in your system. Then all future payments related to that profile would include this same reference ID as part of its data, so if you're using IPN, for example, it would be included there.
When working with Express Checkout the user is always guaranteed to end up back on your site to finish the checkout flow, so you can simply save data in sessions during checkout and update things like your database, email receipts, etc. directly in your payment flow. Then you could use IPN to process the recurring payments after that, and again, it would include that same reference ID. In IPN this would come back as rp_invoice_id.

Can i use pre-approval using PayPal website payments pro?

I am making a system in which user permits pre-approval of amount. I've used pre-approval with chained payment. But the problem is that my customer gets redirected to PayPal site and also he/she must have a PayPal account or need to create one. So can i make pre-approval payment using PayPal website payment pro? So my customers will not get redirected to PayPal account. And the process becomes more fast? Note :- I don't want to use authorization and capture method. Thanks.
Edit
One more question :- If i make the website in the UK and the currency in GBP, can I still use the American Paypal account for this?
Auth and Capture is what you're asking for, but then you say you don't want it..?? That's what gives you the functionality you're after, though.
You could do a $0 auth and then run DoReferenceTransaction when you're ready to process the payment as opposed to capturing an actual auth if you want.
Those are your only options when working with Pro, though, and it would give you the same sort of preapproval experience for the buyer.
Here are the steps to accomplish what you're after.
Use DoDirectPayment to run a $0 Authorization (card verification). Users will enter their credit card details directly into a form on your site without any redirection to PayPal (and without any knowledge PayPal is being used at all unless you notify them some way.)
Save the transaction ID that you get form this card verification into your transaction history for the customer in your database. This ID is what will be used to process future payments using that credit card.
When you're ready to process a payment for this customer, pull the ID out of the database and use it with a DoReferenceTransaction request to process any amount you need to.
So the card verification is your preapproval, and then running reference transactions are the same as running Pay requests with a Preapproval key. Both methods accomplish the same thing, but one is with direct credit cards and the other is not.
If you're using PHP you can use this PayPal PHP SDK to make all of the API calls very quick and easy for you. If you're using some other language then there are SDKs available for those as well I'm sure.
Please correct me if i am wrong, #Andrew Angell #Ved Pandya
Auth and Capture or Capture payments later method allows you to do direct payment, but it comes with additional charges, which might not suitable for crowdfunding model as refund/ cancel payment is very frequent
Auth and Capture: You are required to pay $0.30 for each "Card Verification Transactions"
Capture payments later: You are required to pay $0.30 for each "Uncaptured Authorization" that you triggered
https://www.paypal.com/us/webapps/mpp/merchant-fees

Retrieving Paypal transaction fee

Is there any way to retrieve the transaction fee charged by Paypal using the REST API?
I've got a mobile application that makes a charge using the Paypal SDK, and then posts the transaction ID to the server. I'm trying to use this to get the transaction fee from Paypal.
Looking at the documentation, it looks like the fee should be returned as part of the details object, though it's not clear how to get this from the payment.
For example, if I get the payment using the following endpoint:
/v1/payments/payment/PAY-XXXXXXX
The response returns information about the transaction, including the amount and currency, but nothing about the Paypal fee.
I've also tried looking up the sale (/v1/payments/sale/XXXXXXX) but that doesn't return anything about the Paypal fees either.
Interestingly enough, I don't seem to be able to view this information either from the transactions grid in the web interface, but I'm sure this information was definitely available in the old version of the web interface (before the redesign).
Not sure if I'm missing something obvious here.
Unfortunately, despite being documented, it seems this hasn't been implemented. According to PayPal Merchant Technical Support, on 02/16/2015:
"Kindly take note that transaction fees will not be returned in REST APIs response and I am not being able to ensure whether this will be implemented in future."
I learned that fee tracking was a requirement for my company's PayPal implementation, and I ended up switching to SDKs as a result.
The details object of the amount object has a fee field, which when you look up the sale using the URL you mentioned above should be in each transaction in the transactions array.
This should return the value you are looking for.