stripe_native 1.1.3

  • Readme
  • Changelog
  • Example
  • Installing
  • new81

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.

Apple Pay

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.

Merchant Identifier

Lastly, open the apps' iOS module. Add the newly created identifier to the project's signing capabilities.

Signing Capablities

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");

Set Currency Key #

In order to change the currency, pass in an ISO currency code prior to opening a payment sheet. On iOS it also requires passing in a country code.

StripeNative.setCurrencyKey("EUR");
// Not required on Android
StripeNative.setCountryKey("FR");

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);

0.0.1 #

Apple & Google Pay initial Implementations

Call payment sheets using a Receipt or Order

  • Receipt: A list of items and prices
  • Order: subtotal, tax, and tip
  • Both require a merchant name

0.0.2 #

Add swift version requirements

1.0.0 #

Documentation and release

1.0.1 #

Flutter formatting, and description increase

1.0.2 #

description decrease

1.0.3 #

naming in receipt readme

1.0.4 #

add example readme

1.0.5 #

add dartdoc

1.1.0 #

setCurrencyKey and setCountryKey

1.1.1 #

null currency key fix

1.1.2 #

switch wallet environment using publishable key hint

1.1.3 #

add error to iOS for unsupported country key (pod 1.0.1)

example/README.md

stripe_native example #

  • In main.dart, there exists a minimum implementation using an example publishable key and merchant identifier.
  • The nativePay button will need to conform to Apple and Google's expectations prior to store submissions, in this example it does not.

Prior to opening a payment sheet #

  • Have your publishable key, and merchant identifier linked to a Stripe dashboard.
  • Call setPublishableKey() using the key associated with your Stripe project.
  • Call setMerchantIdentifier() using the merchant identifier associated with the same Stripe project.

Opening a payment sheet #

  • You can either use an Order, or Receipt object to open the payment sheet.
  • An Order is an object with a subtotal, tax, and tip amount.
  • A receipt is an object with a list of item prices.
  • Both helpers will also require a merchant name to display at the bottom of the iOS payment sheet.

Receipt #

  • const itemPrices = <String, double>{"Nice Hat": 5.00, "Used Hat" : 1.50};
  • var receipt = Receipt(itemPrices, "Hat Store");
  • useReceiptNativePay(receipt)

Order #

  • subtotal, tax, tip, merchant name
  • var order = Order(5.50, 1.0, 2.0, "Some Store");
  • useNativePay(order)

Using the token #

  • useNativePay and useReceiptNativePay return a Future
  • You'll need to write your own endpoint that takes this token and the transaction amount as parameters.
  • Have your endpoint come back and tell the client whether the charge was successful or not.
  • On iOS, you'll need to call confirmPayment with a parameter representing the success of the charge.
  • confirmPayment is an iOS only function, but calling it on both platforms does not hurt.
  • The Apple payment sheet has its own animation, confirmPayment helps show the user whether the charge was succesful or not using that animation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stripe_native: ^1.1.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stripe_native/stripe_native.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-1 points)

31 out of 31 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test