Disambiguate payment acct json form's "country" field

Make it clear the user needs to enter a two letter country code
in json form's "country" field, not a country name.

The json form's field name was not changed to "countryCode" in
this change for the following reason:

The API's payment account forms are dynamically generated using
reflection, and PaymentAccount class hierarchy @Setter methods
determine which form fields are included or excluded.  Reflection
and @Setter methods are also used when reading completed json
forms, to set the field values on a new PaymentAccount instance
before it is persisted.

CountryBasedPaymentAccount subclasses have a country field and a
@Setter, not a countryCode field, hence this shortcut to informing
the user the country field value is a country-code.
This commit is contained in:
ghubstan 2021-03-18 16:14:28 -03:00
parent c8d01a2d4c
commit 67252642c7
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
2 changed files with 8 additions and 2 deletions

View File

@ -129,7 +129,10 @@ public class AbstractPaymentAccountTest extends MethodTest {
assertEquals(paymentMethodId, emptyForm.get(PROPERTY_NAME_PAYMENT_METHOD_ID));
assertEquals("your accountname", emptyForm.get(PROPERTY_NAME_ACCOUNT_NAME));
for (String field : fields) {
assertEquals("your " + field.toLowerCase(), emptyForm.get(field));
if (field.equals("country"))
assertEquals("your two letter country code", emptyForm.get(field));
else
assertEquals("your " + field.toLowerCase(), emptyForm.get(field));
}
}

View File

@ -147,7 +147,10 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
String fieldName = field.getName();
out.name(fieldName);
out.value("your " + fieldName.toLowerCase());
if (fieldName.equals("country"))
out.value("your two letter country code");
else
out.value("your " + fieldName.toLowerCase());
}
} catch (Exception ex) {
String errMsg = format("cannot create a new %s json form",