Giter Site home page Giter Site logo

stripe-scala's Introduction

Stripe Scala bindings

Quickstart with sbt 0.10

In the stripe-scala directory, run sbt console. You’re now in a Scala REPL where you can import com.stripe. Set your stripe.apiKey and start making API requests. (See the Example section at the end of this file)

Installation

The current release is distributed for Scala 2.9.0 or later. Add stripe-scala as a dependency in sbt or Maven:

sbt

Add the stripe-scala dependency:

val stripeScala = "com.stripe" %% "stripe-scala" % "1.1.2"

Maven

Add the Scala-Tools repository and the stripe-scala dependency to your POM:

<dependencies>
    <dependency>
        <groupId>com.stripe</groupId>
        <artifactId>stripe-scala_2.9.1</artifactId> <!-- replace with your Scala version -->
        <version>1.1.2</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <id>ScalaToolsMaven2Repository</id>
        <name>Scala-Tools Maven2 Repository</name>
        <url>http://scala-tools.org/repo-releases</url>
    </repository>
</repositories>

Run the test suite

In the stripe-scala directory, run sbt test, using your stripe test secret key.

Documentation

Example

import com.stripe
stripe.apiKey = "sSs57dBsUSkxo3lQPsNKNDX5H0RAcYsj"
val charge = stripe.Charge.create(Map(
  "amount" -> 100,
  "currency" -> "usd",
  "card" -> Map("number" -> "4242424242424242", "exp_month" -> 3, "exp_year" -> 2015)
))

See src/test/scala/com/stripe/StripeSuite.scala for more examples.

See stripe.com/api for the most up-to-date documentation.

stripe-scala's People

Contributors

anurag avatar ben-manes avatar farmdawgnation avatar ornicar avatar pc avatar siddarth avatar siddarth-stripe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

stripe-scala's Issues

ScalaTest should not be a compile-time dependency

When trimming down my GAE war, I was surprised to see scalatest_2.9.1-1.6.1.jar in the libs. By running "mvn dependency:tree" I tracked it to this project (see below) and verified in your build file. This is a 2.6mb jar, which increases the load time of a GAE instance.

[INFO] +- com.stripe:stripe-scala_2.9.1:jar:1.0.3:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.1:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.1.2:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] | | - commons-codec:commons-codec:jar:1.4:compile
[INFO] | +- net.liftweb:lift-json_2.9.1:jar:2.4-M4:compile
[INFO] | | +- com.thoughtworks.paranamer:paranamer:jar:2.3:compile
[INFO] | | - org.scala-lang:scalap:jar:2.9.1:compile
[INFO] | - org.scalatest:scalatest_2.9.1:jar:1.6.1:compile

Switch to Bearer auth

With all of our other bindings, we've switched from using HTTP basic auth to using bearer auth, which is specified by the OAuth spec.

Basically, instead of setting the header

Authorization: Basic base64(APIKEY + ":")

you set

Authorization: Bearer APIKEY

Should catch up scala to the other bindings.

Use range syntax in library dependencies

Maven (v3.0.3) does not appear to support Ivy's plus notation for selecting the latest version of a library after a start version. The range notation, e.g. [1.0,), is supported. This causes a Maven build to fail when including the library unless excludes are specified.

[ERROR] Failed to execute goal on project: Could not resolve dependencies for project: The following artifacts could not
be resolved: org.apache.httpcomponents:httpclient:jar:4.1.+, net.liftweb:lift-json_2.9.1:jar:2.+: Could not find artifact org.apache.httpcomponents:httpclient:jar:4.1.+ in scala-tools.org (http://scala-tools.org/repo-releases)

Pluggable HttpClient (AppEngine compatibility)

I think that the current usage of Apache HttpClient is not compatible with Google AppEngine, resulting in the error below. Details of how to make client compatible is described at:
http://code.google.com/p/googleappengine/wiki/WillItPlayInJava

The cleanest approach may be to use the cake pattern to allow changing the default http client. Another approach may be to define a provider, defaulting to the current implementation, that can set. Either would allow the client to swap out the client and provide one configured to work in their environment.

java.lang.NoClassDefFoundError: Could not initialize class com.google.apphosting.runtime.security.shared.stub.javax.net.ssl.KeyManagerFactory
at org.apache.http.conn.ssl.SSLSocketFactory.createSSLContext(SSLSocketFactory.java:221)
at org.apache.http.conn.ssl.SSLSocketFactory.createDefaultSSLContext(SSLSocketFactory.java:359)
at org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(SSLSocketFactory.java:173)
at org.apache.http.impl.conn.SchemeRegistryFactory.createDefault(SchemeRegistryFactory.java:49)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:305)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:467)
at com.stripe.APIResource.rawRequest(Stripe.scala:120)
at com.stripe.APIResource.request(Stripe.scala:125)
at com.stripe.Customer$.create(Stripe.scala:242)

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.