paymill / paymill-java

Java wrapper for Paymill API
http://paymill.github.io
MIT License
26 stars 22 forks source link

Creating a new Preauthorization gives no reference to the transaction #24

Closed PerWiklander closed 11 years ago

PerWiklander commented 11 years ago

When using PreauthorizationService#create the method can only return a Preauthorization (by design, it extends AbstractService<Preauthorization>). Although it actually has an instance of Transaction there at the end, there is no vay of getting the transaction id from the returned Preauthorization. Could we add a Transaction field to the Preauthorization class?

stoilkov commented 11 years ago

I think a better approach will be to change the return type of the create method. The "create" action for preauthorizations actually returns a transaction, the preauthorization is a field (that already exists in the transaction object).

PerWiklander commented 11 years ago

That would be great, but then It would also have to take a Transaction as input, since the generics require it to return the same type as it takes in. Since it is just moving values to a map and the Transaction type has the same fields I guess it would work with minimal changes to that code. But I guess it would break the API and everyones code.

stoilkov commented 11 years ago

We can simply include an additional method that still takes a Preauthorization object as parameter but returns a Transaction. About the map conversion: it might not be a bad idea to change the way it's done right now, I am thinking about annotations in the model classes.