Support CVV with leading zeroes

Support CVV with leading zeroes
Trim whitespace from string values
Agree - that client-side validation would best be handled comprehensively
elsewhere. So I'll remove that intent from my patch - it sounds like your
preference is to simply treat CVV as a String and modify
setVerificationValue() to call the existing StringOrNull method.

My patch is meant to fix a real-world defect that affected me "in the wild"
- specifically I had a customer attempting to use a valid CC which had a
CVV starting with a zero. Because the current
BillingInfo's setVerificationValue() calls IntegerOrNull - his valid CC
entry resulted in a NumberFormatException and my store could not process
his card as a result.

Moving to your preferred approach as described above would allow my store
to process his card … so that's good enough. Will submit an update shortly.


On Sun, Aug 17, 2014 at 5:22 PM, Pierre-Alexandre Meyer <
notifications@github.com> wrote:

> In src/main/java/com/ning/billing/recurly/model/RecurlyObject.java:
>
> >
> > +        String value = object.toString().trim();
> > +        return value.matches("[0-9]+") ? value : null;
>
>  All objects have toString() so the use-case doesn’t apply to
> StringOrNull - every Object can be rendered as a String.
>
> StringOrNull is a bit smarter than simply calling toString - it
> understands if the returned XML payload represents a null object in the
> Recurly format.
>
> Note that these methods are not supposed to do any validation, they are
> simply transforming the XML output sent from Recurly to the Java type
> expected by the model (the setters are called during deserialization).
>
> If you would like to add client-side validation, which could be a good
> thing, we should probably do it somewhere else. Maybe RecurlyObject could
> have a validate method that individual models could override (and we
> would do the CVV check there). validate would then be called before
> serialization.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/killbilling/recurly-java-library/pull/44/files#r16332196>
> .
>



-- 
Eric Simmerman
President | Tempest Strings Enterprises, Inc.
ets@tempeststrings.com
US Tollfree: (888) 568-8585