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)
The current release is distributed for Scala 2.10.0 or later. Add stripe-scala as a dependency in sbt or Maven:
Add the stripe-scala dependency:
val stripeScala = "com.stripe" %% "stripe-scala" % "1.2"
Add the Scala-Tools repository and the stripe-scala dependency to your POM:
<dependencies>
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-scala_2.10.0</artifactId> <!-- replace with your Scala version -->
<version>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>
In the stripe-scala directory, run sbt test, using your stripe test secret key.
import com.stripe.{api, apiKey}
import com.stripe.apache.ApacheHttpClient
import com.stripe.model._
stripe.api = new StripeApi with ApacheHttpClient
stripe.apiKey = "sSs57dBsUSkxo3lQPsNKNDX5H0RAcYsj"
val chargeFuture = Charge.create(
amount = 100,
currency = "usd",
card = Some(ChargeCard(number = "4242424242424242", expMonth = 3, expYear = 2015)
))
// wait for the future to complete.
See src/test/scala/com/stripe/StripeSuite.scala for more examples.
See stripe.com/api for the most up-to-date documentation.