Demo applications demonstrating the PurchaseKit integration.
cd rails/pay
bin/setup
bin/devOpen ios/PurchaseKitDemo.xcodeproj in Xcode and run on a simulator (Product → Run).
- Sign in with
user@example.com/password - Tap "View Paid Content" to see the paywall
- Select a plan and tap Subscribe
- Complete the StoreKit test purchase
- See "You have access!" appear
No PurchaseKit account or Apple Developer account required - everything runs locally using StoreKit testing and demo mode.
The Android demo requires a Google Play Console account and an app uploaded to internal testing before you can test purchases.
Android setup instructions
- Android Studio
- Google Play Console account with payments profile set up
- App uploaded to internal testing track
- Open
android/in Android Studio - Sync Gradle files
- Build → Generate Signed App Bundle / APK
- Select the existing keystore at
android/keystore.jks(password:password) - Build the release AAB for upload to Play Console
- Create an app in Google Play Console
- Upload the signed AAB to Testing → Internal testing
- Create subscription products in Monetize → Subscriptions
- Add your Google account to Settings → License testing
- On your device, open the internal testing opt-in link and accept
- Install the app from Play Store (not Android Studio) - billing requires the signed release build
- Run the Rails server accessible from the device (update
baseUrlinMainActivity.kt) - The Google Play billing UI will appear for test purchases
Note: Running from Android Studio uses debug signing which doesn't work for Google Play Billing, even with license testers. Always install from Play Store for purchase testing.
- Reset StoreKit transactions - In Xcode with the app running: Debug → StoreKit → Manage Transactions → Delete All
- Reset the Rails database - Run
bin/rails db:seed:replantto clear subscriptions and reseed users
- Cancel test subscriptions - In Google Play Console: Order management → Find the subscription → Cancel
- Reset the Rails database - Run
bin/rails db:seed:replantto clear subscriptions and reseed users
rails/pay/- Demo Rails app with Pay gem integrationrails/standalone/- Demo Rails app without Pay gem (custom subscription handling)ios/- Demo iOS app using the PurchaseKit Swift packageandroid/- Demo Android app using Google Play Billing
Both demos use the same purchasekit gem. The gem auto-detects whether Pay is present.
| Feature | rails/pay | rails/standalone |
|---|---|---|
| Pay gem | Yes | No |
| Subscription model | Pay::Subscription |
Custom Subscription |
| Webhook handling | Automatic | Event callbacks |
rails/pay: Pay gem handles subscription records automatically. PurchaseKit creates Pay::Subscription from webhooks.
rails/standalone: You handle subscriptions via event callbacks in the initializer:
config.on(:subscription_created) do |event|
user = User.find_by(id: event.customer_id)
user.subscriptions.create!(store: event.store, status: "active", ...)
endBy default, the Rails apps run in demo mode - purchases complete locally without API calls.
To connect to the local SaaS for end-to-end testing:
DEMO=0 bin/devThis requires the SaaS to be running at http://localhost:3000 with seeded data.
| Mode | Command | Description |
|---|---|---|
| Demo (default) | bin/dev |
Local purchases, no API calls |
| SaaS | DEMO=0 bin/dev |
Connects to local SaaS |
- Ruby 3.2+
- SQLite
- Rails 8.1+
| Password | Subscription | |
|---|---|---|
user@example.com |
password |
None |
customer@example.com |
password |
Active |
When you're ready to use PurchaseKit in production, see the documentation for details.