Last updated:
0 purchases
appstitch stripe
Appstitch Stripe #
Serverless Stripe Integrations for Appstitch
Usage #
Create a customer #
final customerOpts = CreateCustomerOpts(email: "[email protected]");
final _customer = await stripe.createCustomer(customerOpts);
copied to clipboard
Create a Subscription #
final subscriptionItems = [SubscriptionItemOpts(price: "price_abc123")];
final subscriptionOpts = CreateSubscriptionOpts(customer: "cus_abc123", items: subscriptionItems);
subscription = await stripe.createSubscription(subscriptionOpts);
copied to clipboard
Create a PaymentIntent #
final paymentIntentOpts = CreatePaymentIntentOpts(
currency: "usd",
amount: 2500,
confirm: true,
customer: "customerID");
final paymentIntent = await stripe.createPaymentIntent(paymentIntentOpts);
copied to clipboard
With Apple Pay or Android Pay
final paymentIntentOpts = CreatePaymentIntentOpts(
currency: "usd",
amount: 2500,
confirm: true,
paymentMethodData: PaymentMethodData(
card: CreateCardOpts(token: token.tokenId), type: "card"),
);
final paymentIntent = await stripe.createPaymentIntent(paymentIntentOpts);
copied to clipboard
Blueprints #
Blueprints abstract literals away from client side code. Set up blueprints on the dashboard to avoid fetching master data (e.g. Stripe prices). All blueprint properties can overwritten by your flutter client.
It's easier to update blueprints oposed pushing new releases.
An example:
The "pro_tier_sale" blueprint sets the items and coupon for the subscription. The client side is cleaner since you just set the customerID
final subscriptionOpts = CreateSubscriptionOpts(customer: customerID);
subscriptionOpts.blueprintId = "pro_tier_sale";
subscription = await stripe.createSubscription(subscriptionOpts);
copied to clipboard
Best Practice : Start with very broad blueprints and refine them as you go.
Install #
appstitch_core: ^1.0.0
appstitch_stripe: ^1.0.4
copied to clipboard
Initialize #
import 'package:appstitch_core/options.dart';
import 'package:appstitch_core/core.dart';
Core core = Core();
@override
void initState() {
super.initState();
final options = Options(appstitchKey, clientID: clientID);
core.initialize(options);
}
copied to clipboard
Notes #
The foundations for this library is from flutter_stripe_payment and tipsi-stripe
Create a free Appstitch account here
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.