Create a template for R users to create paid subscription services for Shiny Apps.
An example is deployed to shinyapps.io here:
https://mark.shinyapps.io/r-saas/
Login with one of the providers (more are available), use the coupon code "test123" to test the paid subscription service of Paddle. The paid content is a woeful plot.
This project is derived from:
A diagram on how the app handles payments
.Renviron
or otherwise:FIREBASE_API_KEY=your-api-key
FIREBASE_PROJECT=your-firebase-project
GAR_CLIENT_JSON=file-location-of-client-id
PADDLE_VENDOR=paddle-vendor-id
PADDLE_PRODUCT_ID
global arg.payment_app/fb_functions
in the same Firebase project via the GCP console. This handles communication between Firebase and Paddle webhooks. You can do this via gcloud functions deploy
if you have gcloud
installed or copy-paste into the web UI for Cloud Functions.library(googleAuthR)
# creates firebase-reader-auth-key.json file
gar_service_provision("firebase-reader", "roles/datastore.viewer")
http://localhost:PORT
to test locally (http://127.0.0.1:PORT
doesn't work with Firebase login) - I launch Shiny in Viewer pane then visit http://localhost
in my browsershiny/
with the client auth key and .Renviron
in the same folderglobal.R
for the payment functions that are used in the demo app, and you can adapt to your own use:
fb_document_get()
gets entries to the Firebase database, FirestoreusePaddle()
is placed at the top of pages you want to use Paddle in, and loads the Paddle JS librarypdle_subscribe()
creates a subscription button - you can select which product_id, user_id (the firebaseId is suggested), email to pre-populate in the form and the URL redirect that will be visited after paymentThe Shiny App will offer to link to the payment popup via Paddle after login with Firebase Auth. The firebase auth ID is used to verify if the user has an existing subscription, and if not creates a payment button to do so. If a user does have a subscription, then they see the paid content.
If a subscription fails (the credit card is cacnelled or similar) then Paddle updates.
The Firebase databsae "subscriptions" is used to keep track of whether a user has paid or not. The communication between Firebase and PAddle is done via the Python cloud function in the payment_app/
folder - see its README for details.