How to get paypal sale transactions - php

I'm trying to pull in orders from paypal into my database. When I say orders, I mean orders from paypal buttons we have in various places.
I've dove into the REST API, but I don't see any API for searching for / listing transactions. I see a list of payment Resources, but that comes back with count 0.
I also see Sale Transactions in the API but that asks for a single transaction ID.
Is there a way I can periodically get transactions? I know this is possible because we use a tool called Shipstation that grabs new orders from Paypal and brings them into their system.
Thanks!

You can use REST APIs to do what you are wanting to do. You can use
GetPaymentList to do this. This is sample code from the PayPal Github PHP homepage. You will need to install and use the PayPal PHP SDK.

Related

What PayPal PHP-API functions to use as replacement for subscription-buttons?

I have a website coded in PHP that uses paypal buttons/IPN for subscriptions.
The method is limited and I need to replace it with the REST-API.
What the system needs to do:
Accept new user recurring-payment subscriptions
Be able to change plan pricing for new users
Be able to change plan pricing for existing users
Change subscription plans mid-subscription(If a user upgrades from pro to master the price goes up, and the opposite way it goes down).
The price difference between packages is 5$
Give periodic discounts for a limited amount of months.
The questions:
1.) What is the equivalent of recurring-payments in the PHP-API or REST-API? (I'd rather it auto-charges and notifies my IPN if possible)
2.) How can I automatically refund/charge an additional amount when the user upgrades/downgrades in the middle of a month?
3.) Is there a standalone PHP control-panel that can connect to the paypal API to manage the subscription packages + sales?
Thanks in advance!
If you are looking to use REST APIs, the best place to start is going to be at the REST API docs. For your situation, you can use the vault to set up a recurring payment system. You could also use the future payments API, but you will need to make sure you buy DPRP for your account. Contact PayPal Customer Support to enable DPRP.
With the Vault API, you can just create one time payments over and over with the token you get when storing a credit card.
There is an in-depth walkthrough using the SDK on the PayPal PHP SDK Wiki.
To do refunds, you can use the Refund REST API. All this assuming that you would be writing scripts to detect your user downgrading/upgrading. You would just need to store the amount they are paying each month in your DB.
There are some shopping carts out there that are implementing REST APIs. You might need to google search for something like that.
Hope that helps and gets you started in the right direction!

PayPal Express Checkout Capture Funds

I have written and successfully processed paypal functions on my clients site. They just want to be able to finalize the bill after they have shipped the product as the cost is very hard to calculate as products vary in size, quantity, ect. I currently have it set up so that they authorize a payment after using express checkout API as I have set $paymentType = "Authorization"; in stead of sale as the paymentType. All orders are tracked and logged in the database of the clients site they get a list of what the customer ordered, shipping info, ect on the admin side of the site. Only problem is once they have completed the order they mark it done on their site they must log into paypal and finalize the order by capturing the funds. How would I go about to capture funds using the classic API? I have found how to do it using the rest api, but I'm not going to rewrite my site to do it.
From the research I have done I have found that you can do it as I stated with the rest api and nvp or merchant api, but I'm using Express Checkout in PHP. I haven't been able to find how to use PHP and capture the funds.
My current code set up looks like this
//Orders are listed out using an array of mysql databases
......
**Where I need assistance**
//Capture funds from Paypal here
//return status of successful via self posting form
....
//And then I have
//a get function that marks the order as completed in the database
To summarize my question is how would(if possible) using the classic api and express checkout capture funds from paypal? As you can see I have given some thought to this I'm just stuck and can't figure it out.
The DoCapture API is what you're looking for. You'll pass in the transaction ID you got back from the Express Checkout Authorization along with the amount you're capturing.

is it possible to refund a transaction using paypal

In my website ,i need to refund a successful transaction. I have stored the transaction ID in my database.when clicking on the particular transaction ID ,i wish to go to the detail page of the transaction .Is it possible with PHP.
You can use the GetTransactionDetails API to pull details about a particular transaction and generate/display a nice detail page that includes a refund link/button of some sort.
Then you can use the RefundTransaction API to actually process the refund when that gets triggered.
If you're working with PHP I'd recommend taking a look at my class library for PayPal. It will make these API calls very simple for you, and you could have it done within a matter of minutes.

Paypal NVP API - Narrowing Transaction Search Results

I'm currently building a simple ecommerce site for a client that will use solely Paypal to take payments. I want to display orders in the CMS I'm building for them, but only transactions that are made on the site I'm building.
I have achieved this so far by using the Paypal IPN to add transactions from the site into a database table (just the transaction id) and then borrowing heavily from the TransactionSearch.php file that Paypal supply with the API.
My concern is that at the moment, I'm fetching every transaction from the account (even ones not attributed to this site) and then filtering them by matching them against an array and only displaying the ones that are stored in the DB. It would be better if I could send the array I have through to Paypal and just receive those transactions - does any body know if that is possible?
The system works as is but I would prefer to make it more efficient if possible.
Thanks
I'd say a foreach with the GetTransactionDetails API should do the trick?
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails

How do I identify orders with the Google Checkout Notification API (using PHP)?

I am using the Google Checkout API to code a simple store. I have gotten as far as letting the user select items, edit the cart, and checkout/pay with Google Checkout. The notification API (with XML) is being used to read notifications sent by Google after receiving orders. How can I connect the order notifications with the orders information in my SQL database? Can I send an "order ID" or something like that to Google with the initial order? I have coded that portion (ordering) with the HTML API.
Thanks in advance!
When an order is placed, a notification is made giving you a serial number for the order. You need to store this serial number in your database against whatever internal order number you have, so that you can use the serial number to refer to the order with Google Checkout via the Notification API.
No. Notification and Polling are two separate concepts.
Notification is when Google Checkout sends you info as it occurs, and Polling is when you send a request for sale details at some time in the future.
Documentation for Polling is lacking on-line. That is why you - and I - have not found the answer.
Google sends an e-mail when a sale is made (or when something goes wrong with a payment), and it stores some detail in your dashboard. You can use the date or the number to Poll for the rest of the details. Exactly how to do that is lacking in the on-line documentation.
Use the merchant-private-data field to pass any custom data about your order.
When you get back the notification, read the custom info from the merchant-private-data field.
See this answer for a solution to a similar issue.

Categories