Public Member Functions | |
| PayPal () | |
| Basic no-arg constructor. | |
| log_file ($filename=FALSE) | |
| Set the log file for output, if you set this, information will be sent to the log file. | |
| logit ($level, $message) | |
| Logs a message. | |
| status_completed () | |
| Transaction/Payment completed. | |
| status_pending () | |
| Pending. | |
| status_cancel_reverse () | |
| Won a dispute. | |
| status_denied () | |
| Merchant denied payment. | |
| status_failed () | |
| Transaction failed. | |
| status_refunded () | |
| Merchant refunded payment. | |
| status_reversed () | |
| Charges reversed. | |
| debug_response ($filename) | |
| Use this to "fake" a VALID/INVALID response from paypal, for debugging purposes. | |
| paypal_host ($timeout=45, $host="www.paypal.com", $port=80) | |
| Set the host that will be contacted for payment corroboration. | |
| connect_paypal () | |
| Perform a connection to paypals website. | |
| test_form ($form_tags=TRUE) | |
| Generate a testing form. | |
| processIPN () | |
| The Grand-Daddy method, this is the actor.. | |
| errstr ($code) | |
| Fetch a string that tells what the returned error code from processIPN means. | |
| check_amount ($item_no, $amount, $currency) | |
| Check that the amount/currency is correct for item_id. | |
| check_txn_id ($id) | |
| Check txn_id has not already been used. | |
| check_email ($email) | |
| Check email address for validity. | |
http://www.geniegate.com/es_contact.php
Friendly -/- Decent Rates -/- Decent Quality
Java -/- Perl -/- PHP -/- XML -/- Databases -/- UNIX
This is a base-class IPN handler for PayPal. It does nothing on it's own except provide a skeleton class to be derived from. It's not GenieGate specific in any way. It provides a more "object oriented" approach to paypal IPN using handlers. This generic approach makes it usable by GenieGate, but can be also used anywhere someone requires paypal support. (Shopping carts, download areas, etc..)
The general idea is to inherit from this class, provide the methods you are interested in. (such as check_txn_id, check_email, check_amount)
Populate your class with configuration, database connections, or other resources/initialization as required in your unique situation.
In general, you shouldn't modify this file. Create your own class file and *inherit* from this one, (using extends)
Call processIPN() to actually process a paypal IPN. This will invoke your custom, application specific methods. The return value from proceessIPN() will < 0 on failure. If it is <0 use the errstr() to report the cause. (and/or override logit() to store the logs)
-/- Testing and debugging -/-
It provides debugging support in which to test your "handler class" by way of a generic form.
The debug support also allows one to use a file in place of the response from paypal's web site. This is useful for running lots of tests that aren't really paypal centric, or testing on an intranet without a public IP number prior to hammering paypals web site. (although you should use paypals web site to do your final testing)
Call the log_file() method with a filename to log diagnostic information. Nothing is logged unless you do this. (and/or override logit() to send this information in email, etc..)
-/- Legal dogma and fine print. -/-
Copyright (C) Jamie Hoglund 2004. All rights reserved.
Feel free to use this file. An advertisement link in the form of User Management is always appreciated, but not required for using this paypal IPN class. (Note that the ad link *IS* required for using free versions of GenieGate, this class is not GeniGate and does not fall under that restriction)
This class may not be used as part of another product which is offered for resale. It is for personal (or single business) use only. Please use the contact form at http://www.geniegate.com/contact.php if there are any questions or comments. (Hint: my main concern is that I don't want a competitor to use it against me.)
** Use at your own risk **
I neither claim nor do I accept any responsibility for any hardships it may cause anyone. There is no warranty expressed or implied. Use at your own risk.
If it should happen to cause hardships or problems, or if you are having difficulty with it, I would appreciate hearing from you. Any contact we may have does NOT constitute, imply or otherwise indicate any acceptance of liability.
-------------------------------------------------------------------
Definition at line 81 of file PayPal.php.
|
|
Basic no-arg constructor.
Definition at line 114 of file PayPal.php. |
|
||||||||||||||||
|
Check that the amount/currency is correct for item_id. You should override this method to ensure the amount is correct.
Definition at line 458 of file PayPal.php. References logit(). Referenced by processIPN(). |
|
|
Check email address for validity. Override this method to make sure you are the one being paid.
Definition at line 482 of file PayPal.php. References logit(). Referenced by processIPN(). |
|
|
Check txn_id has not already been used. Override this method to ensure txn_id is not a duplicate.
Definition at line 470 of file PayPal.php. References logit(). Referenced by processIPN(). |
|
|
Perform a connection to paypals website. Must return a resource pointer to a socket or handle. See debug_response() for a technique to debug using a fake response from paypal, see paypal_host() to set the timeout,host,port details. Definition at line 245 of file PayPal.php. References errstr(), and logit(). Referenced by processIPN(). |
|
|
Use this to "fake" a VALID/INVALID response from paypal, for debugging purposes. Set the filename to be used for debugging, if set, it should be a filename that contains the headers and such that would be returned by paypal's web site. Obvious Note: Don't use this on a production system.. Definition at line 226 of file PayPal.php. |
|
|
Fetch a string that tells what the returned error code from processIPN means. (Use for logging or error reporting)
Definition at line 443 of file PayPal.php. Referenced by connect_paypal(). |
|
|
Set the log file for output, if you set this, information will be sent to the log file.
Definition at line 121 of file PayPal.php. |
|
||||||||||||
|
Logs a message. Override this method to be notified of Errors,Info or Debug messages. (Can also use log_file() to simply store them in a file some place)
Definition at line 137 of file PayPal.php. Referenced by check_amount(), check_email(), check_txn_id(), connect_paypal(), processIPN(), status_cancel_reverse(), status_completed(), status_denied(), status_failed(), status_pending(), status_refunded(), and status_reversed(). |
|
||||||||||||||||
|
Set the host that will be contacted for payment corroboration. Normally, this is 45,www.paypal.com,80 Definition at line 233 of file PayPal.php. |
|
|
The Grand-Daddy method, this is the actor.. returns > -1 on success, or one of the following codes for an error -1 - Socket problem. -2 - check_email() failed. -3 - txn_id is a duplicate. -4 - check_amount() failed. -5 - payment_status not recognized. -6 - INVALID response. -7 - The status_* method. didn't return TRUE. -8 - Neither VERIFIED nor INVALID were found in paypal response. Use errstr() for a brief sentance explaining the error.
Definition at line 353 of file PayPal.php. References check_amount(), check_email(), check_txn_id(), connect_paypal(), and logit(). |
|
|
Won a dispute. return TRUE - All went OK. Definition at line 180 of file PayPal.php. References logit(). |
|
|
Transaction/Payment completed. This is typically the only method you'll need to override to perform some sort of action when a successful transaction has been completed. You could override the other status's (such as reverse or denied) to reverse whatever was done, but that could interfere if you're denying a payment or refunding someone for a good reason. In those cases, it's probably best to simply do whatever steps are required manually.
Definition at line 162 of file PayPal.php. References logit(). |
|
|
Merchant denied payment.
Definition at line 188 of file PayPal.php. References logit(). |
|
|
Transaction failed. return TRUE - All went OK. Definition at line 196 of file PayPal.php. References logit(). |
|
|
Pending. Need to do something else? Look at $_POST[pending_reason].
Definition at line 172 of file PayPal.php. References logit(). |
|
|
Merchant refunded payment.
Definition at line 204 of file PayPal.php. References logit(). |
|
|
Charges reversed.
Definition at line 212 of file PayPal.php. References logit(). |
|
|
Generate a testing form. The form is useful for debugging your handler class. Use test_form(FALSE) to create just the input variables. (this is useful if you are using more than the basics presented here) Definition at line 269 of file PayPal.php. |
Documentation generated by DoxyGen