Follow the Getting Started Guide or look at the Sample to help setting up stripe-spring-boot-starter.
implementation("io.hndrs:stripe-spring-boot-starter:1.0.0")
//skip this if you already have the stripe dependency in your project
implementation("com.stripe:stripe-java:<version>")Gradle
hndrs.stripe.signing-secret=whsec_*******************
hndrs.stripe.webhook-path=/stripe-eventsapplication.properties
There are 3 conditional methods that can be used to narrow the execution condition (Note: there is an
internal class conditional that makes sure that the receiver only receives the defined generic type. You can
override any of the following methods (by default they return true)
onCondition(event: Event)- It is recommended to use this conditional to check at least the event type
onReceive(stripeObject: Subscription)- *It is recommended to use this when your condition only needs values from the
stripeObjectfor your business logic
- *It is recommended to use this when your condition only needs values from the
onCondition(previousAttributes: Map<String, Any?>?)- It is recommended to use this conditional when your condition needs only values from
the
previousAttributes
- It is recommended to use this conditional when your condition needs only values from
the
onCondition(previousAttributes: Map<String, Any?>?, stripeObject: Subscription)- It is recommended to use this conditional when your condition needs a combination of the
previousAttributesand the receivedstripeObject
- It is recommended to use this conditional when your condition needs a combination of the
Implementing a StripeEventReceiver looks like the following:
@Component
open class ExampleReceiver : StripeEventReceiver<Subscription>(Subscription::class.java) {
override fun onCondition(event: Event): Boolean {
// conditional based stripe event
return event.type == "customer.subscription.updated"
}
override fun onCondition(stripeObject: Subscription): Boolean {
// conditional based stripe object
return true
}
override fun onCondition(previousAttributes: Map<String, Any>): Boolean {
// conditional based on previousAttributes
return true
}
override fun onCondition(previousAttributes: Map<String, Any>, stripeObject: Subscription): Boolean {
// conditional based previousAttributes and stripe object
return true
}
override fun onReceive(stripeObject: Subscription) {
// do something with the received object
}
}The
StripeEventReceivergeneric needs to be subclass of a StripeObject
To access snapshot builds add the following to your gradle script
maven {
url = uri("https://maven.pkg.github.com/hndrs/stripe-spring-boot-starter")
credentials {
username = "<GITHUB_USERNAME>"
password = "<PERSONAL_ACCESS_TOKEN"
}
}
dependencies {
implementation(group = "io.hndrs", name = "stripe-spring-boot-starter", version = "1.0.0-SNAPSHOT")
}
Your personal access token needs the read:packages scope (Download packages from GitHub Package Registry)