Thursday, May 18, 2017

How to install JCOP tool in Eclipse

This is a quick guide to install NXP JCOP plugin in Eclipse.  Next week, I will tell you how to activate JCOP tool with a commom JCOP card. Stay tuned. BTW, there is an Easter Egg at the end... → →

1. In Eclipse, click Help menu and select "Install New Software".


2. Then click Add button and select the installation program file. Click Next to install the tool.


 Easter Egg: If you want to know activate JCOP tool with a commom JCOP card now, please check this post.


Wednesday, May 3, 2017

Loyalty Card Solution

Loyalty Card is a kind of digital wallet, which is a popular marketing strategy in current commercial activities. It can encourage your customers to keep shopping at your businesses. It is mainly used in large chain stores, supermarkets, hotels, cinemas, KTV, high-level clubs and other consuming places.


 

Major function
Loyalty Card Demo includes Applet on card and outside card application. You can learn the detailed user guide here. The main functions are as belows:
  • Issue Card: Shopping malls, supermarkets and other consuming places will make specific initialization for the card before giving cards to their customers. Here are the main operations at this stage: download and install LoyaltyCardApplet into card and set password for the card.
  • Change PIN: Change password for the card.
  • Credit: Increase the card balance. You can transfer from your main bank account or deposit cash into the card. The money will be stored as digital currency for you to consume.
  • Purchase: After customers complete the payment via Loyalty card, deduct the amount from the balance and accumulate the corresponding points as well.
  • Get Balance: Check balance after consumption.
  • Get Points: Check accumulated points.
Source Code
To view the whole code, please visit JavaCardOS Forum


 1
 2
 3
 4
 5
 6
 7
 8  
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

/**
 * @file  LoyaltyCardApplet.java
 * @Loyalty Card Applet Sample Code
 * @copyright Copyright(C) 2016 JavaCardOS Technologies Co., Ltd. All rights reserved.
 * www.javacardos.com
 */
...
 public void process(APDU apdu) {
  // Good practice: Return 9000 on SELECT
  if (selectingApplet()) {
   return;
  }
  byte[] buf = apdu.getBuffer();
  
  if ((buf[ISO7816.OFFSET_CLA] == Loyalty_CLA) ||
         (buf[ISO7816.OFFSET_CLA] == ISO7816.CLA_ISO7816))
  {
      switch (buf[ISO7816.OFFSET_INS]) 
      {
    case INS_ISSUE_CARD:
     IssueCard(apdu);
     return;
          case INS_CREDIT:
           Credit(apdu);
           return;   
          case INS_VERIFY:
           Verify(apdu);
           return;           
          case INS_PURCHASE :
           Purchase(apdu);
           return;
          case INS_GET_BALANCE:
           GetBalance(apdu);
           return;           
          case INS_GET_POINTS:
           GetPoints(apdu);           
           return;
          case INS_GET_CARDID: 
              GetCardID(apdu);
              return;
    case INS_UPDATE_PIN:
     UpdatePin(apdu);
     return;
       case INS_GET_CHANNEL:
        GetChannel(apdu);
        return;
       case INS_EXTERNAL_AUTH:
     ExternalAuth(apdu);
        return;
       case INS_INTERNAL_AUTH:
        InternalAuth(apdu);
        return;     
       default:
        bRand = false;
        ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
      }
  } else {
   ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
  }
 }
 
 //In issue card process, there contains a PIN, key and the card ID
 private void IssueCard(APDU apdu)
 {
  ... 
 }
 
 ...