I use a class to charge credit cards; every time a transaction gets processed I just change the properties like the card number and date and submit.
It happened that the properties weren’t set right and the transaction goes through using the old card number. Terrible.
So to prevent this from happening again I want to make sure all the properties in the class are back to default. I’m thinking of something like disposing the created class and recreate it. But I’m not sure how to do it in Delphi.
This is my current code:
if frmPayAware = nil then
Application.CreateForm(TfrmPayAware, frmPayAware);
frmPayAware.ProcessCredit(eExpDate.Text,FTrack,eNameOnCard.Text,eCardNum.Text,0);
You can either create a clear method, that clears all properties. Or you can create the form for each use:
Personally, I prefer the later method because is assures that each time a form is used, it is in the same state (just created).
Free vs Release
Release, posts the message CM_RELEASE to the form. If the message is processed (after all other messages are processed) Free is called.