Re: RFC: Credit card processing
| From: | Mike | Date: | Sat, 13 Dec 2003 14:00:19 +0000 |
| Subject: | Re: RFC: Credit card processing | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-24386@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
$ret = CreditCard::validate($ccno); if (CreditCard::isError($ret)) {this doesnt solve the problem of having a true response + a very important message (eg payment deferred)... It also means that CreditCard needs to extend PEARdie ($ret->getMessage());}
Please have a look at PEAR_Error, IMO that's the way to go for your class. Besides, I don't think it should be integrated into the Validate package directly. It should live on its own, in whatever category you want.I agree, validate belongs inside this one if anything. I am only making references to validate because it is similar in that a true can be partly false
Then Validate can integrate a function to make a request to your package and return true/false. If you use PEAR::raiseError, then the error can probably be caught by some other script somewhere else during the validation process in order to get the corresponding error message. Or have a singleton with a static property that stores the last error message so that other classes like QuickForm can use it later on.This was my original suggestion, if you have this, then there is no need to use PEAR_Error, just true and false with an extra getStatusCode() method for the additional information
$ret = Validate::creditCard($ccno);
if ($ret === false) {
$ccObj =& CreditCard::singleton();
die($ccObj->getLastErrorCode());
}
Bertrand Mansion
Mamasam