سؤال

Here is another question.

My requirement for Track 2 (bit 35) is:

Z (Numeric + X 'D' (BCD, ½ byte representation of D [1101] as a field separator between Primary Account Number and Expiration Date), BCD — When an odd number of digits, pack right-most half byte to '0'. Size: Variable to 37, preceded by a one-byte, BCD length indicator

The default template definition has bit 35 as a 2 byte length Ascii field so I am sure that is not it. I changed it to BcdVar(1, 37, Formatters.Bcd).

Taking a dummy track2 example of:

12345678901234567=9999999999999999999

I replace the '=' separator with the 0x0D integer value which translates to "13" (1101). We now have:

12345678901234567139999999999999999999

Does this make sense? I don't think this is the correct way of doing it.

هل كانت مفيدة؟

المحلول

You've run into a "feature" of OpenIso8583.Net. When you work with the field values using msg[3] = "123456", you must always work with the unpacked values.

For this track2 data, you need to build up the track 2 as 12345678901234567D9999999999999999999. Note the 'D' in the middle of the data as a separator.

Now in your Template set field 35 to have a BCD formatter, essentially.

template[Bit._035_TRACK_2_DATA] = FieldDescriptor.BcdVar(2, 37, FieldValidators.Track2)

نصائح أخرى

I sort of duplicated the question (Track2 in BCD - 'D' character).

Treating the field as Binary (with a BCD-Length-Indicator!!!) is a cute trick, which might do the trick. But, still - there is no method:

  public static FieldDescriptor.BinaryVar(..., ILengthFormatter lengthFormatter)

so instead of adding it (which should be done anyway, for cases of BinaryVar fields), one can add a:

  public static FieldDescriptor.BcdVar(..., IFieldValidator validator)

and call:

  msg[Bit._035_TRACK_2_DATA] = FieldDescriptor.BcdVar(2, 37, FieldValidators.Track2);

the 'D' will be treated as BCD - what do banks know...


Regarding the right-padding - I guess that's where the Adjuster comes handy. Again, we need to add a static method with an Adjuster parameter like this:

  var setAdjuster = new LambdaAdjuster(setLambda: value => value.PadRight(value.length + 1, '0'));

It's true - you can pad the value prior to setting the field, but that's not fun (we're geeks, aren't we?).


Regarding adding static methods to FieldDescriptor - I guess it's possible to use the generic

  public static IFieldDescriptor Create(ILengthFormatter lengthFormatter, IFieldValidator fieldValidator, IFormatter formatter, Adjuster adjuster)

but I'm new to C# and would be glad to get confirmation regarding my theories.

Thanks.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top