verygoodsecurity / vgs-collect-js

VGS Collect.js script loading module
https://www.verygoodsecurity.com/
7 stars 14 forks source link

Date Format #79

Open emetcalf-leadventure opened 2 months ago

emetcalf-leadventure commented 2 months ago

Expected Behavior

https://www.verygoodsecurity.com/docs/api/collect/#api-formfield I would like to be able to change the format of the date that is redacted so that when I send it to a 3rd party I can reveal it in the format they are expecting. I would expect to set this in the serializer option.

Current Behavior

The date is always redacted and reveal in the "yyyy-mm-dd" format.

Possible Solution

To workaround I need to create custom Larky code in my outbound route:

def process(input, ctx):
    body = json.loads(str(input.body))

    applicantDob = vault.reveal(body['primaryApplicant']['dateOfBirth'])
    body['primaryApplicant']['dateOfBirth'] = reformatDate(applicantDob)

    input.body = builtins.bytes(json.dumps(body))
    return input

def reformatDate(date):
    return '/'.join((date[5:7], date[8:], date[:4]))

Steps to Reproduce (for bugs)

form.field('#space-for-my-field', {
  type: 'date',
  name: 'date-of-birth',
  validations: ['required'],
});

Context

I have 3rd party clients whose API only accepts date of birth in the format of 'mm/dd/yyyy'.

Your Environment