Saturday, March 24, 2012

Shopping cart product - Expiring links

Hi,

I just finished working on our own shopping cart. Everything is working fine, except for one product. Onlinead. Users can post an ad on our website which will stay there for onemonth. I have this page wantads.aspx which has the input form to submitthe ad. Currently, whoever purchases this product, we manually emailthe page link to the user where they can go in and submit their ad.This url is not protected. Once they find out about the link, they cansubmit as many ads as they want. (Though we have to approve every adthat comes through so we are not losing any money)

Can anyone tell me how this process can be automated? Any way to redirect theuser after the order is placed, to the wantads.aspx page with somequerystring parameters that works only that time. If they bookmark andcomeback later the link will not work. Or how can I include the link tothe wantads.aspx page in the order confirmation email. The link shouldwork for only one ad posting. Any ideas?

Thanks.Hi,

Two simple ways are using session and cache. But each one has a problem:

- If you use cache, links are valid only for a while. It is good for links to be valid until used.
- If you use session, the above problem exists while you cannot send link using email and link is lost if user ends current session.

But there is another way: using database.

I describe the third way:

1) Depending on what information you want to store, different DB tables can be used. For example, you can create a table that only saves link IDs, or you can save one link ID for each purchase in a column in DB table where purchase requests are stored. You can also created a table that stores link IDs with a purchase ID for each record pointing to purchase ID in purchase requests table.
Any other table column with the following specification can be used:

- Is unique in table.
- Is something like GUID, not an integer.
- Is private.(never shown to users)

2) You need to add link ID to DB when purchase takes place.
3) Now, you can generate URL to"wantads.aspx" in the following formatand use in automated email:

"http://[www.domain-name.tld]/wantads.aspx?AdID={0}"

The best way to created ad IDs is using guid.

4) In "wantads.aspx" load event, write a code that:

- Tries to retrieve query string parameter "AdID" and create a guid using its value (Guid id = new Guid(string), generates error when query string is in incorrect format-Use try...catch)
- Redirects to another page if guid is incorrect.
- Checks if link ID exists in DB and is valid.
- Shows form if link ID is valid.
- Notices that ID is invalid if is not valid.
5) Expire link when ad is created successfully.
To expire the link, you need to delete link ID from link IDs table or set the column that shows whether link is used or not, depending on method you have used for storing IDs.

Hope it would be useful to you.

Regards,
Farshid
Thanks for your tip.

0 comments:

Post a Comment