I have a website that accepts PayPal payments and I need to check old payments (like a week ago) that
appear pending on my server.
Since payments are "pending" on my server I don't have the PayPal transaction id to identify then on PayPal servers so I need another way to search for them, for example, using the "item number" that corresponds to the payment id on my site.
The final idea is to have a cron job that runs every day and checks for pending payments and retrieve their status on PayPal and try to confirm them automatically.
Is there a way to check a payment status using PayPal's api by the item number or other field?
Thanks in advance.
There is a much easier system to check on payments that are made through them and that is the Paypal IPN API.
Paypal IPN API Documentation should get you started and up and running.
Inside of the provided code from the IPN API, they have multiple methods to check for payments and if they are paid, pending, denied, etc.
Hope this helps!
Related
I have a chat site and I am going to make it possible for the users to reserve a nickname for a subscription fee per month. I have been reading up on PayPal documentation and understand how to do such using PHP with the various callbacks from PayPal to check that the initial payment has been confirmed but what I don't understand how to do is how to each month check that the subscription has still been paid/not cancelled, otherwise do something (in this case remove their subscriber account)?
You can use PayPal IPN feature https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/?mark=IPN.
Refer to https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/, there is a "profile_status" variable , PayPal can notify you if profile status is changed.
We have a little problem in our system, we allow customers to pay using PayPal which is great!
But in the following situation we have this issue:
A customer pays us using PayPal.
We send the product to our customer when the transaction has completed.
A few days later, PayPal refuses to pay us because the customer have his PayPal account connected with his bank account. And the funds on that bank account is too low.
So, is there a way to let PayPal know us when this happens through API/URL call to our server ?
As Dagon mentioned, IPN is the best way to handle this.
You'll setup a listener script on your server, and every time a transaction happens on your PayPal account, the PayPal server will POST data about that account to your listener script. You'll get different parameters depending on the type of transaction that occurs. You can see a list of the types and parameters here.
You can build your email notifications, database updates, etc. into your IPN script to fully automate post-payment processing tasks.
So, in the example you've provided, what would happen is when the transaction first takes place the IPN would be triggered with a payment_status of Pending, and then you'd also see a parameter called pending_reason with a value of echeck. This tells you the payment was made, but it's an echeck which takes time to clear, so the status again is Pending instead of Completed.
A few days later when that payment does clear (or fails) you'd get another IPN with an updated payment_status. Only upon receiving an actual COMPLETED payment_status would you then would you deliver the order.
Again, this can all be automated within your IPN script.
I have a subscription plan ie $30 for every month and first month is free. but I am not getting any response from Paypal when somebody subscribes however I get response after one month for the first payment. Paypal does not send any response back if the first month is free ? How can I find out somebody subscribed successfully ?
Are you using standard subscription buttons or Express Checkout with Recurring Payments?
Either way, you'll get IPN's when a new subscription profile is created as well as when each payment comes through. If you're not seeing that I would check your IPN history in your PayPal account to see if you're finding errors there, and also check your web logs to see if you're finding errors there.
I'm guessing that your IPN script is failing for some reason when it gets hit for the new profile IPN's.
The txn_type value would be either subscr_signup or recurring_payment_profile_created depending on which method you're using.
I'm just starting out with Paypal, so this is a newbie question.
I've been going through the instructions for setting up Paypal subscription service, but I think I'm looking at the wrong thing.
What I want to acheive is to get back some kind of response from Paypal so that I can update the database on my web site to mark a registered user as having paid. Basically I have a flag in the database that says if the user is subscribed or not. I want to ensure that the user is marked as paid so long as their Paypal subscription is maintained.
While the instructions linked above do say how to set up a button to receive a payment, there's nothing there about getting any data back from Paypal.
I know there are terms like IPN and sandbox that are related to what I'm trying to do, but I can't find clear instructions for how to get started on this process. I'm just circling around and not getting anywhere.
Where do I start on setting this up? Where is there a clear beginner's tutorial?
Also, I'm using PHP/Javascript/MySQL on my website.
PayPal's IPN service is what you want to use. I've used it myself to do just what you're looking to do.
Instant Payment Notification (IPN) is PayPal's message service that
sends a notification when a transaction is affected. Once IPN is
integrated, sellers can automate their back office so they don’t have
to wait for payments to come in to trigger order fulfillment. IPN can
send notifications for these transactions:
Instant payments, including Express Checkout and direct credit card payments
eCheck payments and pending, completed, or denied status payments
Pending payments
Recurring payments and subscriptions
Authorizations
Disputes, chargebacks, reversals, and refunds
You can also view notifications on PayPal’s IPN History page and
resend them if you need to. As PayPal’s interface for handling
purchase confirmation and server-to-server communications, IPN can
also be used to manage and customize a variety of APIs and
communications, including:
Customize your website's response to customer purchases in seconds
Track customers via IPN "pass-through" variables
Notify sellers who deal mostly in software downloads and other digital, online goods
Track affiliate sales and commissions
Store transaction information in your own database
For more about IPN:
Technical Overview (link to new html version of docs on developer central)
Instant Payment Notification Guide (PDF)
Code Samples
I'm not sure if its the same thing, but I just setup my friends website with Express Checkout, and I wanted to add all paid orders to an orders table in my database.
After I call SetExpressCheckout, and the user is returned to my site after going through the purchase flow on Paypal's side,
I used the information from GetExpressCheckoutDetails.
Then, if DoExpressCheckoutPayment
is successful (also called from the "callback" page) I then do the appropriate work in my database as far as logging the order details. For you in this case, it could be updating a record for the user in the database.
Hope that helps a little.
I need to setup paypal auto renewal for my customers in website.
actually customer will get 30 days website access on every month payment.
if the monthly auto payment is ok we can increase "website access" days by 30.
if no it will not add any more days to customers account.
that means i need to RUN a SCRIPT from my own website to check and increase or stop customers "website access" days after each auto payment.
can we set up paypal auto renewal like this?
is there any method to run a script (mywebsite.com/renewalscript.php?customerid=123&payment=ok) after every auto renewal ?
or do you have any other idea to overcome this ?
A simple way could be to have a valid_until date column or something. When a user tries to view content, just check that field and see if they should be able to or not. Then in the IPN listener, you could push that date forward 30 days when a good payment comes in.
If you need help with creating the IPN listener, you might find my tutorial helpful.
PayPal Instant Payment Notification (IPN)
You can do this by listening to the IPN for when the txn_type is subscr_eot. When the subscription fails or is cancelled, you can disallow access.
This question explains a bit more about subscr_eot:
Subscriptions with Paypal IPN
I use this class: PHP Paypal IPN Integration Class
and check:
if($p->ipn_data['txn_type'] == 'subscr_eot')
then set their status to 0 to disallow access.
AFAIK, on every sucessfully debted subscription fee, you get an information via IPN. The "script you need to run" is the IPN script. If PayPal notifies you via IPN, your IPN script needs to handle the request/response and if valid, sets your parameters in your database. This is all done in your IPN handler script on your website.
(Remember to first answer the paypal request in this script before doing any local updates to your tables etc. if you send the request too late, paypal doesn't accept it and sends a new one later).
See https://cms.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=developer/library_code_ipn_code_samples for sample code