• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Credit Card Processing / Validation

I am wondering if anyone has some suggestions on the best way to go about credit card processing/validation on a form. Here is what I have thought about so far...

I want to be able to authorize the transaction before it's converted to a sale; so if the user inputs the wrong CC information, the form will be displayed with everything filled out still and they can make the correction.

Currently, I thought about putting a callback rule on it and setting a session variable to the transaction ID I get from an AUTH_ONLY. However, that causes problems if there is any false validation returns. It will show up on the users CC statement and temporarily take the funds from their account; essentially leaving 5 transactions if they submit the form 5 times with errors.

My next thought would be to just validate the form with the validation class and then validate the card after. (on the TRUE side of form validation) However, I am not really sure how to repopulate the form, etc if their CC is declined for any reason. Can anyone shed some light on this and give some input? Thank you!

[eluser]Pascal Kriete[/eluser]
Something like this might work:
    $rules['username']    = "required";
    //... and any other rules
    $fields['username']    = 'Username';
    //... ditto here


    if($this->validation->run() == TRUE)
        $credit_card_ok = //check the credit card

        if (count($_POST) > 1 && $credit_card_ok)
            //redirect, success message, shutdown site now that you have the money, etc
            // Form was good, but the credit card didn't come back positive.
            $this->validation->error_string = "Credit card invalid."
        // First load, and if the form wasn't good.

This should refill the form and bypass your multiple credit card checks issue. Not the most elegant solution though.

To refill the form just do it the normal way with:
Remember to run set_fields for this to work.

EDIT: The reason why this works is because CI runs set_fields before deciding on true or false. So even if the form validates, the object is already set...or so I hope (didn't test it Smile ).

Thanks for the reply!! I had something like that in-mind, I'm just not sure if it's the 'good' way to do it, but I guess whatever works... lol.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.