Use this template to create a community-contributed payment provider for PayCraft.
- Copy this directory as your new module
- Rename the package from
com.example.paycraftto your own - Implement
ProviderPlugininterface - Create a webhook Edge Function
- Publish to Maven Central
your-plugin/
├── build.gradle.kts ← KMP library config
├── src/commonMain/kotlin/
│ └── YourGatewayPlugin.kt ← ProviderPlugin implementation
└── webhook/
└── index.ts ← Supabase Edge Function
class YourGatewayPlugin : ProviderPlugin {
override val id = "yourgateway"
override val displayName = "YourGateway"
override val version = "1.0.0"
override fun createProvider(config: PluginConfig): PaymentProvider {
val serverUrl = config.requireExtra("server_url")
return CustomProvider(
name = "yourgateway",
webhookFunctionName = "yourgateway-webhook",
checkoutUrlBuilder = { plan, email ->
config.paymentLinks[plan.id]
?: error("No payment link for ${plan.id}")
},
)
}
}// build.gradle.kts
implementation("com.example:paycraft-yourgateway:1.0.0")
// App init
PayCraft.configure {
supabase(url = "...", anonKey = "...")
provider(YourGatewayPlugin().createProvider(
PluginConfig.builder()
.paymentLink("pro", "https://yourgateway.com/pay/pro")
.testMode(true)
.extra("server_url", "https://yourgateway.com")
.build()
))
}Your webhook Edge Function should use the shared handleSubscriptionEvent():
import { handleSubscriptionEvent } from "../_shared/subscription-handler.ts";
// Map your gateway's events to PayCraft's SubscriptionEvent format
await handleSubscriptionEvent({
email: "user@example.com",
provider: "yourgateway",
subscriptionId: "sub_123",
status: "active",
// ... see subscription-handler.ts for full interface
});- Configure Maven Central credentials
- Run
./gradlew publishAllPublicationsToMavenCentralRepository - Add your plugin to the PayCraft Plugin Directory