package ttk.commands;

import device.Pinpad;
import tlv.TlvItem;
import ttk.Util;

public class Cancel extends CommandBase {
    private int amount;

    public Cancel(Pinpad pinpad, int amount){
        super(pinpad);
        this.amount = amount;
    }

    public void setRrn(byte[] rrn){
        try {
            context.add(new TlvItem(tlv.Tag.findTag("TAG_TTK_CLIENT_RRN"), rrn));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void prepare(){
        try {
            context.add(new TlvItem(tlv.Tag.findTag("TAG_TTK_CLIENT_AMT"), Util.intToString(amount, 12)));
            context.add(new TlvItem(tlv.Tag.findTag("TAG_TTK_CLIENT_MID"), "VOI"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
