Yes, I already do this. Create /app/models/credit_card.php;

<?php
class CreditCard extends AppModel {

        var $name = 'CreditCard';
        
        var $useTable = false;
        
        var $validate = array(
                'card_number' => array(
                        'notempty' => array(
                                'rule' => 'notEmpty',
                                'message' => 'Please enter a credit card 
number.',
                                'required' => true,
                                'last' => true
                        ),
                        'maxLength' => array(
                                'rule' => array('maxLength', 20),
                                'message' => 'The credit card number must 20 
characters or less.',
                                'last' => true
                        ),
                        'valid' => array(
                                'rule' => array('cc', 'fast', false, null),
                                'message' => 'The credit card number you 
supplied was invalid.'
                        )
                ),
                'card_type' => array(
                        'rule' => 'notEmpty',
                        'message' => 'Please select a credit card type.',
                        'required' => true
                ),
                'exp_month' => array(
                        'rule' => 'notEmpty',
                        'message' => 'Please select a credit card expiry 
month.',
                        'required' => true
                ),
                'exp_year' => array(
                        'rule' => 'notEmpty',
                        'message' => 'Please select a credit card expiry year.',
                        'required' => true
                ),
                'cardid_number' => array(
                        'rule' => 'notEmpty',
                        'message' => 'Please enter a security code.',
                        'required' => true
                )
        );
}
?>

Then at the right time in the order process:

if (isset($this->data['CreditCard'])):
                        
        $creditCard = ClassRegistry::init('CreditCard');
        
        $creditCard->set( $this->data );
        
        if ($creditCard->validates($this->data['CreditCard'])):
                                
                $this->Session->write('creditCard',
                        array(
                                'card_type' => 
$this->data['CreditCard']['card_type'],
                                'card_number' => 
$this->data['CreditCard']['card_number'],
                                'exp_month' => 
$this->data['CreditCard']['exp_month'],
                                'exp_year' => 
$this->data['CreditCard']['exp_year'],
                                'cardid_number' => 
$this->data['CreditCard']['cardid_number']
                        )
                );
                                        
        else:
                        
                $validationErrors['CreditCard'] = $creditCard->validationErrors;
                                
        endif;
                        
endif;


Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 13 Aug 2010, at 08:55, Wilhelm wrote:

> Hi,
> 
> I am implementing a e-commerce website, in my project for security
> reasons I am not storing the users credit card details in the database
> but rather that is being handled by a third party.
> 
> My question is that I would like to use the cc validation to validate
> the credit card number before sending it off to the third party. Is
> this possible?
> 
> Kind Regards
> Wilhelm
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to