43
gitpush
7y

Going through Master Card API docs to see how to integrate it, saw that they have sample code, checked Java sample code and found this:

String data = MessageFormat.format(
"'{'\"apiOperation\":{0},"
+ "\"sourceOfFunds\":'{'\"type\":{1},\"provided\":'{'\"card\":'{'\"numbe\":{2},"
+ "\"expiry\":'{'\"month\":{3}, \"year\":{4}'}',\"securityCode\":{5}'}}}',"
+ "\"order\":'{'\"reference\":{6}'}',"
+ "\"transaction\":'{'\"amount\":{7},\"currency\":{8},\"reference\":{9},\"targetTransactionId\":{10}'}'," + "\"customer\":'{'\"ipAddress\":{11}'}}'",
apiOperation,
sourceOfFundsType,
cardNumber,
cardExpiryMonth,
cardExpiryYear,
cardSecurityCode,
orderReference,
transactionAmount,
transactionCurrency,
transactionReference,
targetTransactionId,
customerIpAddress );

FOR FUCK SAKE what happened to JSONObject (for Android) class, I'm sure it is a waaaay better solution than that mess ...
And from Oracle:
JsonObject value = Json.createObjectBuilder()
.add("firstName", "John")
.add("lastName", "Smith")
.add("age", 25)
.build();

I guess that is a cleaner understandable solution than what master card has.

Comments
  • 6
    Holy crap, what is this mess? :O
  • 5
    Saw rant thought: oh that doesn't look so bad.
    Clicked on more: the fuuuck?
  • 0
    Are you sure it's not a bug in the syntax highlighting of their API docs (presuming there are highlighting)
  • 0
    Notice this bit: {3}

    I don't think this is even valid JSON. Probably some proprietary garbage
  • 1
    @uberblah i think These Numbers are replaced by the values.

    But "Numbe" as the Key for number ... rly?
  • 1
    @ebroda yep, I see that now. that's pretty funky
  • 0
    @Kushtrim what's Gson?
  • 1
    @juneeighteen a library for Java made by Google it is the best thing happened to JSON it's easy to parse and convert to JSON
    @ebroda good point, I honestly didn't bother reading the code until I reach implementation part after reading docs, those {x} will make me blind trying to follow
Add Comment