Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions
https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/supabase-community/flutter-stripe-payments-with-supabase-functions
- Owner: supabase-community
- Created: 2022-03-27T14:49:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-27T04:51:42.000Z (7 months ago)
- Last Synced: 2024-11-04T18:51:11.388Z (8 days ago)
- Language: Dart
- Homepage:
- Size: 5.27 MB
- Stars: 74
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-supabase - Flutter, Stripe Payments - ![edge functions](https://img.shields.io/badge/-edge%20functions-darkgreen) (Official Starters)
README
# Flutter Stripe Payments with Supabase Functions
This is a Flutter example app, showing how to process payments with Supabase Functions for authenticated customers.
![Demo gif](./demo.gif)
## Setup
### Create new Supabase project
- [Create a new Supabase project](https://app.supabase.io/)
- Navigate to the [Auth settings](https://app.supabase.io/project/_/auth/settings) and turn off the toggle next to "Enable email confirmations". (Note: this is only for testing. In production please enable this setting!)
- Navigate to the [SQL Editor](https://app.supabase.io/project/_/sql) and run the SQL from the [schema.sql](./schema.sql) file.### Setup env vars
- Set up env vars for Supabase Functions:
- `cp .env.example .env`
- Fill in your Stripe API keys from https://stripe.com/docs/development/quickstart#api-keys
- Set up env vars for the Flutter app:
- open `app/config.dart`
- Fill in your _public_ Supabase keys from https://app.supabase.io/project/_/settings/api
- Fill in your _public_ Stripe keys from https://stripe.com/docs/development/quickstart#api-keys### Supabase Functions
Supabase Functions are written in TypeScript, run via Deno, and deployed with the Supabase CLI. Please [download](https://github.com/supabase/cli#install-the-cli) the latest version of the Supabase CLI, or [upgrade](https://github.com/supabase/cli#install-the-cli) it if you have it already installed.
- Generate access token and log in to CLI
- Navigate to https://app.supabase.io/account/tokens
- Click "Generate New Token"
- Copy newly created token
- run `supabase login`
- Input your token when prompted
- Link your project
- Within your project root run `supabase link --ref your-project-ref`### Develop locally
- Run `supabase start` (make sure your Docker daemon is running.)
- Run `supabase functions serve --env-file .env payment-sheet`
- NOTE: no need to specify `SUPABASE_URL` and `SUPABASE_ANON_KEY` as they are automatically supplied for you from the linked project.
- Run the Flutter app in a separate terminal window:
- `cd app`
- `flutter run`
- Make some test moneys 💰🧧💵
- Stop local development
- Kill the "supabase functions serve watcher" (ctrl + c)
- Run `supabase stop` to stop the Docker containers.### Deploy
- Set up your secrets
- Run `supabase secrets set --from-stdin < .env` to set the env vars from your `.env` file.
- You can run `supabase secrets list` to check that it worked and also to see what other env vars are set by default.
- Deploy the function
- Within your project root run `supabase functions deploy payment-sheet`## 👁⚡️👁
\o/ That's it, you can now invoke your Supabase Function via the [`supabase-js`](https://www.npmjs.com/package/@supabase/supabase-js) and [`supabase-dart`](https://pub.dev/packages/supabase) client libraries. (More client libraries coming soon. Check the [supabase-community](https://github.com/supabase-community#client-libraries) org for details).
For more info on Supabase Functions, check out the [docs](https://supabase.com/docs/guides/functions) and the [examples](https://github.com/supabase/supabase/tree/master/examples/edge-functions).