Skip to content

Commit

Permalink
Stripe React Native sync v0.2.2 (#357)
Browse files Browse the repository at this point in the history
* sync with Stripe React Native v0.2.2

* adjust Card Form Field parameters to match the available options

* Update iOS binding to RN 0.2.2

* Focus fix (#366)

* apply change from flutter/flutter#86480 (comment)

* remove unnecessary focus workarounds

* Fix issue #14

* revert pubspec change

* prepare next release

* BREAKING: disable wechat pay as of https://github.com/stripe/stripe-ios/blob/master/CHANGELOG.md#2181-2021-08-10

* add openApplePaySetup

* remove beta references and bump to 2.0.0

Co-authored-by: Jaime Blasco <[email protected]>
Co-authored-by: Remon <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2021
1 parent 3081e07 commit 8e48dbb
Show file tree
Hide file tree
Showing 46 changed files with 684 additions and 752 deletions.
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@

[![pub package](https://img.shields.io/pub/v/flutter_stripe.svg)](https://pub.dev/packages/flutter_stripe) ![build](https://img.shields.io/github/workflow/status/flutter-stripe/flutter_stripe/all_plugins?logo=github)

> 🚨 flutter_stripe is in beta - please provide feedback (and/or contribute) if you find issues 💙️

The Stripe Flutter SDK allows you to build delightful payment experiences in your native Android and iOS apps using Flutter. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details.


Expand Down Expand Up @@ -171,11 +168,6 @@ Future<void> onGooglePayResult(paymentResult) async {
- [Install the `stripe-cli`](https://stripe.com/docs/stripe-cli)
- Run `stripe listen --forward-to localhost:4242/webhook`

## Known issues

- The Card field on Android has focus issues on older Flutter versions - it has been fixed by the Flutter framework in
the master branch. The issue is being tracked in [#14](https://github.com/flutter-stripe/flutter_stripe/issues/14).

## Contributing

You can help us make this project better, feel free to open an new issue or a pull request.
Expand Down
3 changes: 0 additions & 3 deletions docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ description: Flutter library for Stripe.

<img src="https://user-images.githubusercontent.com/19904063/116995247-20519e80-acda-11eb-8e1b-7d0efbd193ad.png" height="36" />

:::note
🚨 flutter_stripe is in beta - please provide feedback (and/or contribute) if you find issues 💙️
:::

# Flutter Stripe

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
22 changes: 11 additions & 11 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ PODS:
- Flutter (1.0.0)
- pay_ios (0.0.1):
- Flutter
- Stripe (21.7.0):
- Stripe/Stripe3DS2 (= 21.7.0)
- StripeCore (= 21.7.0)
- Stripe/Stripe3DS2 (21.7.0):
- StripeCore (= 21.7.0)
- Stripe (21.8.1):
- Stripe/Stripe3DS2 (= 21.8.1)
- StripeCore (= 21.8.1)
- Stripe/Stripe3DS2 (21.8.1):
- StripeCore (= 21.8.1)
- stripe_ios (0.0.1):
- Flutter
- Stripe (~> 21.7.0)
- StripeCore (21.7.0)
- Stripe (~> 21.8.1)
- StripeCore (21.8.1)

DEPENDENCIES:
- Flutter (from `Flutter`)
Expand All @@ -31,11 +31,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/stripe_ios/ios"

SPEC CHECKSUMS:
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
pay_ios: 8c7beb9c61d885f3f51b61f75f8793023fc8843a
Stripe: 90596971ef49bade169f68bc59369a796b30a045
stripe_ios: 669a91fd06d17954dedeaebec35c56bf1c72a602
StripeCore: c09b492efc3b269a6ff875ad738ca366db97e03b
Stripe: 57c6997c64042a3f5aedae9b76e331942f8b75d2
stripe_ios: a47cfc31126ca3f0c47a9c60c0bd4be110d14aea
StripeCore: a6e50d58119a0c7601773b56f274db2d394dcdac

PODFILE CHECKSUM: 4e8f8b2be68aeea4c0d5beb6ff1e79fface1d048

Expand Down
4 changes: 2 additions & 2 deletions example/lib/config.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:flutter/foundation.dart';

// If you are using a real device to test the integration replace this url
// If you are using a real device to test the integration replace this url
// with the endpoint of your test server (it usually should be the IP of your computer)
final kApiUrl = defaultTargetPlatform == TargetPlatform.android
? 'http://10.0.2.2:4242'
? 'http://192.168.0.92:4242'
: 'http://localhost:4242';
47 changes: 23 additions & 24 deletions example/lib/screens/regional_payment_methods/wechat_pay_screen.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:http/http.dart' as http;
import 'package:stripe_example/widgets/example_scaffold.dart';
import 'package:stripe_example/widgets/loading_button.dart';

import '../../config.dart';

class WeChatPayScreen extends StatelessWidget {
const WeChatPayScreen({Key? key}) : super(key: key);

Future<Map<String, dynamic>> _createPaymentIntent() async {
final url = Uri.parse('$kApiUrl/create-payment-intent');
final response = await http.post(
url,
headers: {
'Content-Type': 'application/json',
},
body: json.encode({
'currency': 'cny',
'payment_method_types': ['wechat_pay'],
'amount': 1099
}),
);
// Future<Map<String, dynamic>> _createPaymentIntent() async {
// final url = Uri.parse('$kApiUrl/create-payment-intent');
// final response = await http.post(
// url,
// headers: {
// 'Content-Type': 'application/json',
// },
// body: json.encode({
// 'currency': 'cny',
// 'payment_method_types': ['wechat_pay'],
// 'amount': 1099
// }),
// );

return json.decode(response.body);
}
// return json.decode(response.body);
// }

Future<void> _pay(BuildContext context) async {
// Precondition:
Expand All @@ -41,15 +38,17 @@ class WeChatPayScreen extends StatelessWidget {
// 2. on the backend create a payment intent for payment method and save the
// client secret.
try {
final result = await _createPaymentIntent();
final clientSecret = await result['clientSecret'];
// final result = await _createPaymentIntent();
// final clientSecret = await result['clientSecret'];

// 3. use the client secret to confirm the payment and handle the result.

// TODO: uncomment when wechat is enabled again

await Stripe.instance.confirmPayment(
clientSecret,
PaymentMethodParams.weChatPay(appId: 'com.flutter.stripe.example'),
);
// await Stripe.instance.confirmPayment(
// clientSecret,
// PaymentMethodParams.weChatPay(appId: 'com.flutter.stripe.example'),
// );

ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
Expand Down
90 changes: 51 additions & 39 deletions example/lib/screens/screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import 'package:stripe_example/screens/payment_sheet/payment_sheet_screen.dart';
import 'package:stripe_example/screens/payment_sheet/payment_sheet_screen_custom_flow.dart';
import 'package:stripe_example/screens/regional_payment_methods/ali_pay_screen.dart';
import 'package:stripe_example/screens/regional_payment_methods/ideal_screen.dart';
import 'package:stripe_example/screens/regional_payment_methods/wechat_pay_screen.dart';
import 'package:stripe_example/screens/wallets/apple_pay_screen.dart';
import 'package:stripe_example/screens/wallets/apple_pay_screen_plugin.dart';
import 'package:stripe_example/screens/wallets/google_pay_screen.dart';
import 'package:stripe_example/screens/wallets/google_pay_stripe_screen.dart';
import 'package:stripe_example/screens/wallets/open_apple_pay_setup_screen.dart';

import 'card_payments/custom_card_payment_screen.dart';
import 'card_payments/no_webhook_payment_cardform_screen.dart';
Expand Down Expand Up @@ -113,40 +113,51 @@ class Example extends StatelessWidget {
),
],
),
ExampleSection(title: 'Wallets', children: [
Example(
title: 'Apple Pay (iOS)',
leading: Image.asset(
'assets/apple_pay.png',
width: 48,
ExampleSection(
title: 'Wallets',
children: [
Example(
title: 'Apple Pay (iOS)',
leading: Image.asset(
'assets/apple_pay.png',
width: 48,
),
builder: (c) => ApplePayScreen(),
),
builder: (c) => ApplePayScreen(),
),
Example(
leading: Image.asset(
'assets/google_play.png',
width: 48,
Example(
leading: Image.asset(
'assets/google_play.png',
width: 48,
),
title: 'Google Pay (Android)',
builder: (c) => GooglePayStripeScreen(),
),
title: 'Google Pay (Android)',
builder: (c) => GooglePayStripeScreen(),
),
Example(
title: 'Apple Pay (iOS) - Pay Plugin',
leading: Image.asset(
'assets/apple_pay.png',
width: 48,
Example(
title: 'Apple Pay (iOS) - Pay Plugin',
leading: Image.asset(
'assets/apple_pay.png',
width: 48,
),
builder: (c) => ApplePayExternalPluginScreen(),
),
builder: (c) => ApplePayExternalPluginScreen(),
),
Example(
leading: Image.asset(
'assets/google_play.png',
width: 48,
Example(
leading: Image.asset(
'assets/google_play.png',
width: 48,
),
title: 'Google Pay (Android) - Pay Plugin',
builder: (c) => GooglePayScreen(),
),
title: 'Google Pay (Android) - Pay Plugin',
builder: (c) => GooglePayScreen(),
),
]),
Example(
title: 'Open Apple Pay setup (iOS)',
leading: Image.asset(
'assets/apple_pay.png',
width: 48,
),
builder: (c) => OpenApplePaySetup(),
),
],
),
ExampleSection(title: 'Regional Payment Methods', children: [
Example(
title: 'Ali Pay',
Expand All @@ -164,14 +175,15 @@ class Example extends StatelessWidget {
),
builder: (context) => IdealScreen(),
),
Example(
title: 'WeChat Pay',
leading: Image.asset(
'assets/wechat_pay.png',
width: 48,
),
builder: (context) => WeChatPayScreen(),
),
// TODO: uncomment when we can re-enable wechat pay
// Example(
// title: 'WeChat Pay',
// leading: Image.asset(
// 'assets/wechat_pay.png',
// width: 48,
// ),
// builder: (context) => WeChatPayScreen(),
// ),
]),
ExampleSection(title: 'Others', children: [
Example(
Expand Down
35 changes: 35 additions & 0 deletions example/lib/screens/wallets/open_apple_pay_setup_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:stripe_example/widgets/example_scaffold.dart';

class OpenApplePaySetup extends StatefulWidget {
const OpenApplePaySetup({Key? key}) : super(key: key);

@override
_OpenApplePaySetupState createState() => _OpenApplePaySetupState();
}

class _OpenApplePaySetupState extends State<OpenApplePaySetup> {
Future<void> openApplePaySetup() async {
await Stripe.instance.openApplePaySetup();
}

@override
Widget build(BuildContext context) {
return ExampleScaffold(
title: 'Open Apple pay Setup',
tags: ['iOS'],
padding: EdgeInsets.all(16),
children: [
Center(
child: ElevatedButton(
onPressed: () {
openApplePaySetup();
},
child: Text('Open apple pay setup')),
)
],
);
}
}
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_stripe: ^1.3.0
flutter_stripe: ^2.0.0
pay: ^1.0.5
http: ^0.13.3

Expand All @@ -27,4 +27,4 @@ flutter:
fonts:
- family: OtomanopeeOne
fonts:
- asset: fonts/OtomanopeeOne.ttf
- asset: fonts/OtomanopeeOne.ttf
11 changes: 11 additions & 0 deletions packages/stripe/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 2.0.0
** First stable release **

** Breaking changes **
- Temporarily disable Wechat

Other changes
- add openApplePaySetup method
- several fixes by Stripe SDK ([v0.2.1](https://github.com/stripe/stripe-react-native/releases/tag/v0.2.1), [v0.2.2](https://github.com/stripe/stripe-react-native/releases/tag/v0.2.2))
- Focus issues on Android #14 are fixed

## 1.3.0

** BREAKING CHANGES **
Expand Down
2 changes: 0 additions & 2 deletions packages/stripe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

[![pub package](https://img.shields.io/pub/v/flutter_stripe.svg)](https://pub.dev/packages/flutter_stripe) ![build](https://img.shields.io/github/workflow/status/flutter-stripe/flutter_stripe/all_plugins?logo=github)

> 🚨 flutter_stripe is in beta - please provide feedback (and/or contribute) if you find issues 💙️

The Stripe Flutter SDK allows you to build delightful payment experiences in your native Android and iOS apps using Flutter. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details.

Expand Down
11 changes: 8 additions & 3 deletions packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ class Stripe {
}

/// Creates a single-use token that represents an Apple Pay credit card’s details.
///
/// The [payment] param should be the data response from the `pay` plugin. It can
/// be used both with the callback `onPaymentResult` from `pay.ApplePayButton` or
///
/// The [payment] param should be the data response from the `pay` plugin. It can
/// be used both with the callback `onPaymentResult` from `pay.ApplePayButton` or
/// directly with `Pay.showPaymentSelector`
///
/// Throws an [StripeError] in case createApplePayToken fails.
Expand Down Expand Up @@ -183,6 +183,11 @@ class Stripe {
}
}

/// Opens the UI to set up credit cards for Apple Pay.
Future<void> openApplePaySetup() async {
await _platform.openApplePaySetup();
}

/// Presents an Apple payment sheet using [params] for additional
/// configuration. See [ApplePayPresentParams] for more details.
///
Expand Down
Loading

0 comments on commit 8e48dbb

Please sign in to comment.