Stripe Native
Create chargeable stripe tokens using Apple and Google Pay.
This plugin will give you easy access to the Apple and Google Pay payment sheets. And provide one-time source tokens that are used to create a Stripe Charge.
Setup
Both (Required)
To begin one will need a Stripe project, from there collect a publishable key.
iOS (Required)
On the Apple Developer portal, one will need to create a merchant identifier. Then connect that identifier to the Stripe project.
From the Stripe dashboard, create a signing certificate to share with Apple, then upload the signed certificate to Stripe.
Lastly, open the apps' iOS module. Add the newly created identifier to the project's signing capabilities.
Android (Optional)
On the Google Play console, add the merchant identifier to the app capabilites. This makes the merchant known to Google Pay. With it, users will not see a warning saying this app is an unidentified merchant.
Functions
Set Publishable Key
Prior to calling native pay, set the publishable key.
StripeNative.setPublishableKey("pk_test_yZuUz6Sqm83H4lA7SrlAvYCh003MvJiJlR");
Set Merchant Identifier
Prior to calling native pay, set the merchant identifier.
StripeNative.setMerchantIdentifier("merchant.rbii.stripe-example");
Native-Pay
There are two ways to create a payment sheet. With a list of items and prices, or with some subtotal, tax and tip.
Both methods require a merchant name to display at the bottom of the sheet.
// subtotal, tax, tip, merchant name
var order = Order(5.50, 1.0, 2.0, "Some Store");
var token = await StripeNative.useNativePay(order);
const itemPrices = <String, double>{"Nice Hat": 5.00, "Used Hat" : 1.50};
var receipt = Receipt(itemPrices, "Hat Store");
var token = await StripeNative.useReceiptNativePay(receipt);
Confirm Payment (iOS)
On iOS the payment sheet spins and ends with a check or X depending on the result passed in. During the spinning, query an endpoint for a charge using the token. This function does not affect Android.
// call charge endpoint w/ token
const wasCharged = await AppAPI.charge(token, amount);
// then show success or failure
StripeNative.confirmPayment(wasCharged);
Libraries
Dart
- dart:ui
- Built-in types and core primitives for a Flutter application. [...]
- dart:async
- Support for asynchronous programming, with classes such as Future and Stream. [...]
- dart:collection
- Classes and utilities that supplement the collection support in dart:core. [...]
- dart:convert
- Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
- dart:core
- Built-in types, collections, and other core functionality for every Dart program. [...]
- dart:developer
- Interact with developer tools such as the debugger and inspector. [...]
- dart:math
- Mathematical constants and functions, plus a random number generator. [...]
- dart:typed_data
- Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]
- dart:io
- File, socket, HTTP, and other I/O support for non-web applications. [...]
- dart:isolate
- Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]