Appstitch Stripe
Serverless Stripe Integrations for Appstitch
Platforms
- iOS
- Android
Usage
Create a customer
final customerOpts = CreateCustomerOpts(email: "test@example.com");
final _customer = await stripe.createCustomer(customerOpts);
Create a Subscription
final subscriptionItems = [SubscriptionItemOpts(price: "price_abc123")];
final subscriptionOpts = CreateSubscriptionOpts(customer: "cus_abc123", items: subscriptionItems);
subscription = await stripe.createSubscription(subscriptionOpts);
Create a PaymentIntent
final paymentIntentOpts = CreatePaymentIntentOpts(
currency: "usd",
amount: 2500,
confirm: true,
customer: "customerID");
final paymentIntent = await stripe.createPaymentIntent(paymentIntentOpts);
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);
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);
Best Practice : Start with very broad blueprints and refine them as you go.
Update Podfile
platform
platform :ios, '10.0'
Install
appstitch_core: ^2.0.1-nullsafety.1
appstitch_stripe: ^2.0.1-nullsafety.1
Initialize
import 'package:appstitch_core/core.dart';
import 'package:appstitch_stripe/stripe.dart';
Core core = Core();
@override
void initState() {
super.initState();
final options = Options(appstitchKey, clientID: clientID);
core.initialize(options);
}
Notes
The foundations for this library is from flutter_stripe_payment and tipsi-stripe
Create a free Appstitch account here
View walkthrough here
Libraries
- types/address
- native_stripe/android_pay_payment_request
- types/androidPayLineItem
- types/androidPayOpts
- native_stripe/apple_pay_payment_request
- types/applePayLineItem
- types/applePayOpts
- types/subscriptionItemOpts
- types/updateCustomerOpts
- types/retrieveOpts
- types/createPaymentIntentOpts
- types/subscriptionItemList
- types/createSubscriptionOpts
- types/subscription
- types/subscriptionItem
- stripe
- types/createCustomerOpts
- types/billingThresholdsOpts
- types/attachPaymentMethodOpts
- types/bankAccount
- types/base
- types/cancellationReason
- types/cancelPaymentIntentOpts
- types/capturePaymentIntentOpts
- types/card
- native_stripe/card_form_payment_request
- types/cardFormPaymentRequest
- types/confirmPaymentIntentOpts
- types/connectOptions
- types/createCardOpts
- types/createPaymentMethodOpts
- types/createSourceOpts
- types/customer
- types/discount
- native_stripe/error_codes
- types/interval
- types/invoiceItem
- types/method
- native_stripe
- native_stripe/payment_intent
- types/paymentBehaviour
- types/paymentIntent
- types/paymentMethod
- types/paymentMethodData
- types/paymentMethodResult
- types/price
- types/shippingMethod
- types/source
- types/stripeOptions
- types/token
- types/transferData
- types
- types/updatePaymentIntentOpts
- types/updateSubscriptionOpts