Skip to content

Commit

Permalink
Disambiguate payment acct json form's "country" field
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ghubstan committed Mar 18, 2021
1 parent c8d01a2 commit 6725264
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ protected final void verifyEmptyForm(File jsonForm, String paymentMethodId, Stri
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));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ private void writeInnerMutableFields(JsonWriter out, PaymentAccount account) {

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",
Expand Down

0 comments on commit 6725264

Please sign in to comment.