serialize payment account form lists to comma delimited string
Some checks are pending
CI / build (macos-13) (push) Waiting to run
CI / build (ubuntu-22.04) (push) Waiting to run
CI / build (windows-latest) (push) Waiting to run
Codacy Coverage Reporter / Publish coverage (push) Waiting to run
CodeQL / Analyze (push) Waiting to run

This commit is contained in:
woodser 2025-01-17 07:28:27 -05:00
parent b571b39790
commit 130a45c99a

View file

@ -378,6 +378,7 @@ public abstract class PaymentAccount implements PersistablePayload {
@NonNull
public abstract List<PaymentAccountFormField.FieldId> getInputFieldIds();
@SuppressWarnings("unchecked")
public PaymentAccountForm toForm() {
// convert to json map
@ -387,7 +388,12 @@ public abstract class PaymentAccount implements PersistablePayload {
PaymentAccountForm form = new PaymentAccountForm(PaymentAccountForm.FormId.valueOf(paymentMethod.getId()));
for (PaymentAccountFormField.FieldId fieldId : getInputFieldIds()) {
PaymentAccountFormField field = getEmptyFormField(fieldId);
field.setValue((String) jsonMap.get(HavenoUtils.toCamelCase(field.getId().toString())));
Object value = jsonMap.get(HavenoUtils.toCamelCase(field.getId().toString()));
if (value instanceof List) { // TODO: list should already be serialized to comma delimited string in PaymentAccount.toJson() (PaymentAccountTypeAdapter?)
field.setValue(String.join(",", (List<String>) value));
} else {
field.setValue((String) value);
}
form.getFields().add(field);
}
return form;