Stripe payments; checking status of subscriptions

You will find tutorials here. One of them is a Stripe tutorial. There are other related writings all over this site.

This site’s built-in Search is definitely your friend here, but you may need to do more than skim the titles to find the information you’re looking for. Any time you’re trying to coordinate the activity of two or more programs (e.g., yours and Stripe’s), you get a somewhat intricate topic. The details you want may be buried in code that illustrates a seemingly unrelated Stripe issue.

Anvil’s Stripe integration uses a wrapper around Stripe’s own API. (A wrapper around a wrapper!) Its documentation delegates a lot of detail (implicitly) to Stripe’s documentation, so it is helpful to first understand Stripe’s view of things (through its API).

This is not as straightforward as it it might be.

  1. Anvil’s wrapper is several versions behind Stripe’s latest API.
  2. Stripe’s own API continues to evolve with little notice.
  3. API documentation in general is too low-level. It assumes that you already understand the big picture – the concepts, architecture, constraints, and naming conventions – and just need some specific details. It can take awhile to reverse-engineer the big picture from the small. Patience, and other sources, can really help.

What I remember that may apply:

  1. To give an Anvil App user a Stripe subscription, you must define that user in Stripe as a Stripe Customer, with payment information. This will return a Stripe ID for that Customer, for use in all further Stripe transactions involving that Customer. You’ll need to keep a copy of that Stripe ID, and associate it with your Anvil App user.
  2. Between Anvil and Stripe, Stripe has the better documentation for Stripe’s Subscriptions model, and examples of how to use it.
  3. Be prepared to use the available Stripe API directly, if Anvil’s high-level API does not expose what you need.
  4. When things get really complex, consider using Stripe’s latest Python API in-house, to accomplish any Stripe-specific subtasks by direct communication with Stripe. That way you have the fewest possible middle-men muddying the process.