[ic] How do I handle a "checksum" like field?

interchange-users@interchange.redhat.com interchange-users@interchange.redhat.com
Mon Nov 5 18:05:01 2001


On Mon, Nov 05, 2001 at 05:10:03PM -0500, Jay Flaherty wrote:
> On Monday 05 November 2001 12:09 pm, Christopher Miller wrote:
> >> On Sun, Nov 04, 2001 at 01:18:37PM -0500, Jay Flaherty wrote:
> >>?Hello everyone;
> >>I have added a field to the checkout page (CD key) that requires a checksum
> >>?run against it to check for a valid CD key and if it passes the checksum,
> >>?return an unlock code. I have successfully created a UserTag that does this
> >>?and returns the unlock code back to the user via the receipt.html page as
> >>?well as via email and finally adds it to the database once the credit card
> >>?is validated and charged. My problem is how to handle a CD key entered in
> >>?the CD key field that does not pass the checksum. I would like it to work
> >>?the same way an invalid credit card does not pass the CC checksum, i.e.
> >>?reload the checkout page with the error message "Invalid CD Key. Please try
> >>?again" prominently displayed in red above the CD key field. I have poured
> >>?over all the IC files and can't figure out how the checksum on the CC
> >> works.
> >>?Actually, I can't figure out exactly how the whole checkout process works
> >>?though I have sucessfully implemented it via PGP email and Authorizenet :-)
> >>? I would appreciate anyone who can point me in the right direction or give
> >>?me some example code.
> >
> > Do it in the profile for the checkout page. ?Return a different successpage
> > depending on success or failure (or it sounds like you would prefer to loop 
> > back to checkout). ?Look up profiles, successpage, failpage in docs.
> 
> Thanks for the reply Chris,
> 
> That is my problem. I don't know how to set up etc/profiles.order to check 
> for a valid CD key. Do I put it in a perl block like this:
> [perl]
> my $cd_key = $Values->{cd_key};
> my $unlock = $Tag->unlock_me($cd_key);
> if ($unlock eq "") {
> return  "mv_cdkey_valid=required CD key fails tests.";
> }
> [/perl]

pretty much.  I (personally) don't like to use "" but would
rather return 1 if success, undef otherwise.  If the tag is supposed
to unlock, then it should fail or work, not "".  :-)

# where success is 1
return "mv_cdkey_valid=required CD key fails tests." unless($Tag->unlock_me($cd_key));

YMMV

-- 

Christopher F. Miller, Publisher                               cfm@maine.com
MaineStreet Communications, Inc           208 Portland Road, Gray, ME  04039
1.207.657.5078                                         http://www.maine.com/
Content/site management, online commerce, internet integration, Debian linux