devartis/passbook

How I add currencyCode in primaryFields?

Closed this issue · 2 comments

How can I added currencyCode in addPrimaryField method. I wanna create following json in addPrimaryField method,

  "storeCard" : {
    "primaryFields" : [
      {
        "key" : "balance",
        "label" : "remaining balance",
        "value" : 21.75,
        "currencyCode" : "USD"
      }
    ],

As I check addPrimaryField method there is only 3 parameter are accept.
passfile.passInformation.addPrimaryField('balance', 21.75, 'remaining balance')

I was found CurrencyField Class but I was not understand how to access CurrencyField Class with addAuxiliaryField Class. Thank you.

I have not tested this, but it should be possible to directly append to primaryFields instead of using the helper method addPrimaryField():

balance_field = CurrencyField(
  'balance',
  float(22.00),
  'test label',
  'USD',
)

passfile.passInformation.primaryFields.append(balance_field)

I'm closing this issue due to its age.