Coder Social home page Coder Social logo

paymill-java's Introduction

Paymill-Java

Build Status

Initialize the library by setting your api key:

Paymill.setApiKey("<YOUR API KEY>");

You may provide the api key and api url through command line args by using the -D arg of the jvm.

java -DapiKey=<YOUR_API_KEY> -DapiUrl=<API_URL>

The api url defaults to https://api.paymill.de/v2

Using services

In most cases, you'll use the predefined service classes to access the paymill api.

To fetch a service instance, call Paymill.getService(), like

ClientService clients = Paymill.getService(ClientService.class);

Every service instance provides basic methods for CRUD functionality.

Retrieving objects

You retrieve an object by using the get() method with an object id.

Client client = clients.get("client_12345");

This method throws an ApiException if there is no client under the given id.

Retrieving lists

To retrieve a list you may simply use the list() method:

List<Client> clientList = clients.list();

This will, however, be rather inefficient because it loads all clients without a limit or filter.

You may provide a limit to only retrieve a defined amount of objects:

List<Client> clientList = clients.list(10, 5);

This will load 5 clients, starting at the tenth client.

You can also filter a list by providing filter criteria:

Filter filter = new Filter();
filter.add("amount", ">100");
List<Transaction> txList = transactions.list(filter);

This will return a list of all transactions having an amount of more than 1 Euros.

You may also combine the two calls:

Filter filter = new Filter();
filter.add("amount", ">100");
List<Transaction> txList = transactions.list(10, 5, filter);

Updating objects

In order to update an object simply call a service's update() method:

Client client = clients.get("client_12345");
// do stuff
clients.update(client);

You may also update an object without loading it first:

Client client = new Client();
client.setId("client_12345");
client.setEmail("[email protected]");
clients.update(client);

Deleting objects

You may delete objects by calling the service's delete() method with an object instance or object id.

clients.delete("client_12345");

Further info

See our api reference for more examples: https://www.paymill.com/en-gb/documentation-3/reference/api-reference/index.html

paymill-java's People

Contributors

doublemalt avatar awhido avatar justinholmes avatar

Watchers

James Cloos avatar  avatar  avatar

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.