Previous Table of Contents Next


The Scrivener’s Corner Application Program

Scrivener’s Corner provides pointers from its Web site to the Smart Commerce Solutions site to enable its customers to edit and update the information in the Scrivener’s Corner directory. The only application that Scrivener’s maintains is one that reads the want list from the customer’s card and prepares and transmits the form that matches the customer’s want list against Scrivener’s inventory.

The Scrivener’s want list application uses the general-purpose Smart Shopper Java applet provided by Smart Commerce Solutions to communicate with the customer’s Smart Shopper card. First, it sends a command to read and return the customer’s book want list in the Scrivener’s directory on the Smart Shopper card. Upon receiving the list, the Scrivener’s application matches items on the list against current inventory and prepares a standard HTML form page of hits that it returns to the customer browser. This page allows the customer to check off the books he wants to purchase and offers the option of buying with the frequent buyer points stored on the card.

If the customer does not elect to use frequent buyer points for this purchase, a commercial “shopping cart” Web purchasing application is activated to complete the transaction. At the end of the transaction, the Smart Commerce Solutions applet is commanded to increase the frequent buyer points total in the Scrivener’s directory by the amount of the purchase. If the customer elects to pay with existing frequent buying points, the Smart Commerce Solutions applet is instructed to decrease the frequent buying point total on the card by the amount of the purchase. Figure 10.4 is a flowchart for the Scrivener’s Corner Smart Shopper application.


Figure 10.4.  The process of making a Smart Shopper purchase on the Web.

The Smart Commerce Solutions Smart Shopper Card Management Utility

The Smart Commerce Solutions Smart Shopper card Management Utility is a Windows program that Smart Commerce Solutions gives away on disks and makes available for free downloading from its Web site. The program lets customers update the personal profile data on their Smart Shopper cards and review the frequent buyer points they’ve received from merchants who have elected to include frequent buyer points schemes in their loyalty programs. The human interface to the Card Management Utility is shown in Figure 10.5.


Figure 10.5.  The human interface for Smart Commerce Solutions’s Smart Shopper card Management Utility.

The Smart Shopper card Management Utility is an MFC Visual C++ program that was written against the Multiflex application programming interface described in Chapter 5.

The connection to the Smart Shopper card is established in the OnStart routine and the card’s master file is selected. The Card Management Utility displays the card’s ATR as acknowledgment that the initialization was successful:

void CSmartShopperDlg::OnStart()
{
    char atr[20];
    CListBox *pBox;

    CDialog::OnInitDialog();

    pBox = (CListBox *)GetDlgItem(IDC_ATR);

    Initialize("PSCR_0");
    sprintf(atr, "%02x %02x %02x %02x ",
        scardIoResponse[0],scardIoResponse[1],
            scardIoResponse[2],scardIoResponse[3]);
    pBox->AddString(atr);
    SelectFile(0x3F00);
}

When the user selects the Enter PIN button, the Card Management Utility picks up the text in the PIN edit box, pads it with 0xFFs, and uses it to call VerifyCHV on the card. The Card Management Utility displays the status code returned from the card; 9000 means the PIN was accepted. This will obviously be changed to something a little more intuitive in the next release of the Card Management Utility. Here is the Enter Pin button handler:

void CSmartShopperDlg::OnEnterpin()
{
    CListBox *pBox;
    BYTE pin[20];
    char sw[10];
    WORD length, i;

    pBox = (CListBox *)GetDlgItem(IDC_PINOK);

    *(WORD *)pin = sizeof(pin);
    length = (WORD)SendDlgItemMessage(IDC_PIN, EM_GETLINE, 0,
        (DWORD)(LPSTR)pin);
    for(i = length; i < 8; i++) pin[i] = 0xff;
    VerifyCHV(pin);
    sprintf(sw, "%04x", SW);
    pBox->ResetContent();
    pBox->AddString(sw);
}

When the user selects the Get Personal Profile button, the Card Management Utility selects the card file that contains the personal profile data, 0x0100, and writes each record from this file into a listbox. The program uses the data word associated with each entry in the listbox to flag when an entry has been changed so it has to write back to the card only the records that are actually changed. Here is the Personal Profile button handler:

void CSmartShopperDlg::OnGetpp()
{
    CListBox *pBox;
    char item[25];
    BYTE i;

    pBox = (CListBox *)GetDlgItem(IDC_PP);
    SelectFile(0x0100);
    for(i = 0; i < 10; i++) {
        ReadRecord(i+1, 4, 24);
        memcpy(item, DATA, DATALENGTH);
        item[DATALENGTH] = '\0';
        pBox->InsertString(i,item);
        pBox->SetItemData(i, 0);
    }
}

Double-clicking a line in the personal profile data display copies the line to the edit window below the display, where it can be changed and updated. Here is the selected line handler:

int selitem;
char seltext[30];

void CSmartShopperDlg::OnDblclkPp()
{
    CListBox *pBox;
    CEdit *eBox;

    pBox = (CListBox *)GetDlgItem(IDC_PP);
    eBox = (CEdit *)GetDlgItem(IDC_EDITPP);
    selitem = pBox->GetCurSel();
    if(selitem != LB_ERR)
        pBox->GetText(selitem, seltext);
    eBox->SetWindowText(seltext);
}


Previous Table of Contents Next