Code Monkey home page Code Monkey logo

balanced-java's People

Contributors

cieplak avatar dcheckoway avatar mahmoudimus avatar matthewfl avatar mjallday avatar pnegahdar avatar remear avatar rloomba avatar rserna2010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

balanced-java's Issues

Add support for Account update

Add API call to update users Account information (e-mail, postal_code, etc.) via PUT request..

I may get to this myself but wanted to capture the request

Operate on FundingInstruments

Operate on generic FundingInstrument instances instead of on specific subclasses. For example, allow crediting to a FundingInstrument instead of only to a BankAccount. See here for context.

Debit object missing appears_on_statement_as field (but Hold has it and shouldn't)

Currently in balanced-java, the Hold object has an appears_on_statement_as field. Unless I've been misinformed, that field only applies to a hold when it gets captured as a debit. And it's not technically a field on hold at all...it's a parameter in the capture/debit creation payload.

And it is a field on Debit, which is currently lacking that field in balanced-java.

I suggest that we remove Hold.appears_on_statement_as, and instead make it an optional argument to Hold.capture().

And regardless, we should add the Debit.appears_on_statement_as field.

I'm volunteering to do this work...I'm not, however, aware of how extensively the community is already using Hold.appears_on_statement_as. But to be honest, I can't see how it ever functioned in a useful way, so something tells me we could deprecate it for a version and then yank it. :-)

NullPointerException when CardHold.capture gets error response with no "errors" in payload

This is happening intermittently. When we try to capture a previously created hold (created a few minutes prior to the capture attempt), we're getting this NullPointerException.

java.lang.NullPointerException
        at com.balancedpayments.core.Client.error(Client.java:205)
        at com.balancedpayments.core.Client.op(Client.java:181)
        at com.balancedpayments.core.Client.post(Client.java:102)
        at com.balancedpayments.core.ResourcePagination.create(ResourcePagination.java:93)
        at com.balancedpayments.CardHold.capture(CardHold.java:77)

The line of code is in Client.java:

    Map<String, Object> entity = (Map<String, Object>)((ArrayList)payload.get("errors")).get(0);

The problem appears to be that there is no "errors" array in the payload.

balanced-java should probably handle this more gracefully.

And the Balanced API obviously has some sort of bug, which I'll address separately.

Client VERSION is outdated

src/main/java/com/balancedpayments/core/Client.java
44: private static final String VERSION = "0.10";

Store Payload Map in Resources (Suggested Enhancement)

Currently, the payload map is just discarded after being used to deserialize an object. I think there are huge benefits to storing it within the object it was used to deserialize.

It would allow access to fields not explicitly exposed by the version of the Java API being used. For example, as of 0.10-SNAPSHOT, we cannot yet determine the type of a FundingInstrument. However, with the payload map, we can do the following:

String debitUri = "...";
Debit debit = new Debit(debitUri);
FundingInstrument source = debit.source;
// Presuming the payload map will be stored as a _payload field
String type = (String) source._payload.get("_type");
switch (type) {
    case "bank_account":
        break;
    case "card":
        break;
}

Accounts.java misnamed param

Accounts.java has several places 1, 2 where it references the source_uri param as source which will result in the param being ignored.

We should

  1. Fix these.
  2. Write test cases to ensure that the server is receiving the expected result and honoring it.

Implement the Customer resource

We have a new Customer resource.

With a customer you should be able to debit, credit, as well as add_card and add_bank_account. A customer should be able to tell you their active_card and active_bank_account.

customer/accounts related errors

Results :

Tests in error: 
  testDebitCredit(com.balancedpayments.CustomerTest)
  testDebitSourceCreditDestination(com.balancedpayments.CustomerTest)

Tests run: 43, Failures: 0, Errors: 2, Skipped: 0

HTTPError and APIError are not logging friendly

None of those exceptions implements message, so logging the exception as is provides no useful information as a default.

It forces to wrap all calls and log + convert the exception into something more abstracted that is logging friendly (for example the list of the important attribute concatenated into a readable string to be used as the message).

Write a test for sideloading

Given the payload

{
    "debits": [
        {
            "amount": 5000, 
            "appears_on_statement_as": "BAL*Statement text", 
            "created_at": "2014-02-27T20:03:06.176697Z", 
            "currency": "USD", 
            "description": "Some descriptive text for the debit in the dashboard", 
            "failure_reason": null, 
            "failure_reason_code": null, 
            "href": "/debits/WD1l5vYA21ZP24LMQMqHizea", 
            "id": "WD1l5vYA21ZP24LMQMqHizea", 
            "links": {
                "customer": null, 
                "dispute": null, 
                "order": null, 
                "source": "CC1diaA1Lunr4RlelwKQ8C4v"
            }, 
            "meta": {}, 
            "status": "succeeded", 
            "transaction_number": "W347-910-8642", 
            "updated_at": "2014-02-27T20:03:07.629780Z"
        }
    ], 
    "foos": [
        {
        }
    ], 
    "links": {
        "debits.customer": "/customers/{debits.customer}", 
        "debits.dispute": "/disputes/{debits.dispute}", 
        "debits.events": "/debits/{debits.id}/events", 
        "debits.order": "/orders/{debits.order}", 
        "debits.refunds": "/debits/{debits.id}/refunds", 
        "debits.source": "/resources/{debits.source}"
    }
}

Make sure that this client library does not choke and return the wrong object.

Java Play Framework 2.0 Support

The Java library (v0.10) currently doesn't support the Play framework.

When attempting to use it as a Play plugin, simple calling "new Marketplace()" returns an APIError from Client.java without making a network request. I suspect that the networking client you're using is incompatible with Play's web service interface.

Please advise if the Play Framework is on the roadmap.

Smarter object creation / deserialization

In #36 a bug was uncovered where we return a generic FundingInstrument object instead of creating a BankAccount or Card object based on the type of payload.

If we inspected the payload's _type property when it's available we could construct the correct object rather than using the generic type.

Client's version is null

From nginx's access logs:

"POST /v1/marketplaces HTTP/1.1" 201 2191 "-" "balanced-java/null" 0.503 "OHM96798f327a0211e2ba86026ba7f8ec28"

Missing BIN in card attributes

For additional fraud risk analysis it is customary to use the BIN of the credit card for analysis. Right now the BIN is not provided by the API when fetching the card information and it prevents us to provide this information to additional third party.

Unit tests misusing assertEquals, values passed in reverse

This is incredibly low priority, but it stuck out to me as a common misunderstanding of how org.junit.Assert.assertEquals is supposed to be used. The "expected" value is supposed to be passed as the first argument, but the balanced-java unit tests consistently reverse the args. This means when a unit test fails, you will actually see a misleading error message.

I'm volunteering to fix this...

Hold lacks a "source" field

Unless I'm misreading the API docs, Hold needs a "source" field. Looks like we can probably do what Debit does, which is:

@ResourceField(required=false)
public FundingInstrument source;

I'm not sure about required=false or true...somebody in the know should probably confirm.

Missing bank name in card attributes

The bank name is being sent back in the json response, but it is not exposed in the current Java 1.1 API. It would be great to expose this information so that it can be captured and used either for statistical analysis or for customer support.

Include dependencies into jar with custom namespace

It would be suitable to include and repackage the dependencies (aka relocating classes) that the client depends (gson, commons httpclient/codec/lang, joda) to avoid clashing with the versions the application may use. (eg. our application may use a version that is incompatible with the balanced one and vice-versa)

This can be achieved with the maven shade plugin.

Severe: Use of SimpleDateFormat in Resource.java not safe for multi-threaded environment

Just ran across this while testing my app. It appears there is a single static SimpleDateFormat member variable of the Resource class. Unfortunately, SimpleDateFormat is not thread safe. Specifically, if you have two Resources being deserialized on two concurrent threads, they will clash over that SimpleDateFormat instance, and both threads are gonna have a bad time. In other words, this library will currently not work at all in a multi-threaded environment. The exception that brought it to my attention during testing was:

Caused by: java.lang.NumberFormatException: multiple points

This is just one of a few types of exceptions that can occur from this issue. I took the liberty of finding a good StackOverflow answer that explains it further for your reference:

http://stackoverflow.com/questions/4021151/java-dateformat-is-not-threadsafe-what-does-this-leads-to

Your best bet for correcting this is probably going to be the use of a ThreadLocal as seen in the third ConcurrentDateFormatAccessExample here:

http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html

EDIT: The issue appears to exist also in ResourceQuery.

Improve order_by

The order_by method should take an enum instead of a boolean.

e.g.

collection.query.order_by('created_at', SortOrder.Descending);

Delete Customer

The API allows for the deletion of Customers "so long as there has been no activity associated with it such as creating a hold, credit, or debit"

This ability needs to be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.