README.md

Polished Payments

Lifecycle: experimental

R package to easily add a Stripe subscription with multiple price tiers to a Shiny app using the polished R package.

Installation

# Install `polished` if you don't already have it
remotes::install_github("tychobra/polished")

remotes::install_github("tychobra/polishedpayments")

Getting Started

  1. Create a Stripe account

  2. Create a new Stripe "Product".

  1. Create 1 to 4 Stripe "Price"s

  1. Configure your Shiny app with your Stripe information using polished_payments_config in global.R.

    polishedpayments::polished_payments_config( stripe_secret_key = <stripe_secret_key>, stripe_public_key = <stripe_public_key>, stripe_prices = <stripe_price(s)>, trial_period_days = <stripe_trial_period_days>, free_roles = <polished_role_for_free_users> )

  2. Wrap your Shiny server in payments_server(). e.g.

    ``` my_server <- polishedpayments::payments_server(function(input, output, session) (

    # your custom Shiny app's server logic
    

    ))

    ```

  3. Add the "Account" page to your app using app_module_ui in secure_ui & app_module in secure_server

    • NOTE: You must use "account" as the id for app_module_ui

    ```

    Server

    polished::secure_server(my_server, account_module = polishedpayments::app_module)

    UI

    polished::secure_ui( ui, account_module_ui = polishedpayments::app_module_ui("account") ) ```

Your user's subscription status will now be checked before your Shiny app's server logic starts. If the user does not have a subscription, polishedpayments will set them up with the default subscription. If the user has a subscription that is either in it's free trial period, or the user has set up a payment method, then polishedpayments will allow the user to continue to your Shiny app. If your user has a subscription in which the free trial has expired, but they have not yet enabled a payment method, then polishedpayments will redirect them to their account page where they can set up their subscription.

  1. (Optional) Add button or link to redirect user to 'Account' page with go_to_account()

  2. Example app available: https://github.com/Tychobra/polishedpayments/tree/master/inst/examples/polished_payments_min



olb314159/APpayments documentation built on Dec. 22, 2021, 4:19 a.m.