Coder Social home page Coder Social logo

stripe-java's Introduction

Stripe Java Bindings Build Status

You can sign up for a Stripe account at https://stripe.com.

Requirements

Java 1.6 and later.

Installation

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>com.stripe</groupId>
  <artifactId>stripe-java</artifactId>
  <version>1.27.1</version>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.stripe:stripe-java:1.27.1"

Others

You'll need to manually install the following JARs:

If you're planning on using ProGuard, make sure that you exclude the Stripe bindings. You can do this by adding the following to your proguard.cfg file:

-keep class com.stripe.** { *; }

Usage

StripeExample.java

import java.util.HashMap;
import java.util.Map;

import com.stripe.Stripe;
import com.stripe.exception.StripeException;
import com.stripe.model.Charge;
import com.stripe.net.RequestOptions;

public class StripeExample {

    public static void main(String[] args) {
        RequestOptions requestOptions = (new RequestOptionsBuilder()).setApiKey("YOUR-SECRET-KEY").build();
        Map<String, Object> chargeMap = new HashMap<String, Object>();
        chargeMap.put("amount", 100);
        chargeMap.put("currency", "usd");
        Map<String, Object> cardMap = new HashMap<String, Object>();
        cardMap.put("number", "4242424242424242");
        cardMap.put("exp_month", 12);
        cardMap.put("exp_year", 2020);
        chargeMap.put("card", cardMap);
        try {
            Charge charge = Charge.create(chargeMap, requestOptions);
            System.out.println(charge);
        } catch (StripeException e) {
            e.printStackTrace();
        }
    }
}

See StripeTest.java for more examples.

Testing

You must have Maven installed. To run the tests, simply run mvn test. You can run particular tests by passing -D test=Class#method -- for example, -D test=StripeTest#testPlanCreate.

stripe-java's People

Contributors

amber-stripe avatar andrew-stripe avatar andrewpthorp avatar anurag avatar bill2004158 avatar boucher avatar cosn avatar danwang avatar danwang-stripe avatar ebroder avatar evan-stripe avatar jed204 avatar jim-stripe avatar jimdanz avatar kjc-stripe avatar kyleconroy avatar lachy-stripe avatar michaelklishin avatar michelle avatar michelle-stripe avatar mlahey-stripe avatar mlm-stripe avatar pc avatar pmantrao-manta avatar shale-stripe avatar shalecraig avatar siddarth avatar spakanati avatar stephen avatar wangjohn avatar

Watchers

 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.