Skip to content

Commit

Permalink
Merge branch 'main' into sync
Browse files Browse the repository at this point in the history
  • Loading branch information
remonh87 authored Nov 28, 2023
2 parents dd436c3 + 5153d87 commit c28d84e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
15 changes: 8 additions & 7 deletions example/lib/screens/checkout/checkout_screen.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import 'dart:convert';
import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:stripe_checkout/stripe_checkout.dart';
import 'package:stripe_example/.env.dart';
import 'package:stripe_example/widgets/example_scaffold.dart';

import '../../config.dart';
import 'platforms/stripe_checkout.dart'
if (dart.library.js) 'platforms/stripe_checkout_web.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:stripe_checkout/stripe_checkout.dart';
import 'package:http/http.dart' as http;

class CheckoutScreenExample extends StatefulWidget {
CheckoutScreenExample({
Expand Down Expand Up @@ -49,14 +50,14 @@ class _CheckoutScreenExample extends State<CheckoutScreenExample> {
);

if (mounted) {
final text = result.when(
final text = result?.when(
success: () => 'Paid succesfully',
canceled: () => 'Checkout canceled',
error: (e) => 'Error $e',
redirected: () => 'Redirected succesfully',
);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(text)),
SnackBar(content: Text(text ?? '')),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class _PaymentSheetScreenState extends State<PaymentSheetScreen> {
// Customer params
customerId: data['customer'],
customerEphemeralKeySecret: data['ephemeralKey'],

// Extra params
primaryButtonLabel: 'Pay now',
applePay: PaymentSheetApplePay(
Expand Down
5 changes: 2 additions & 3 deletions example/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,12 +549,11 @@ app.post('/payment-sheet', async (_, res) => {
);
const paymentIntent = await stripe.paymentIntents.create({
amount: 5099,
currency: 'usd',
currency: 'eur',
customer: customer.id,
// Edit the following to support different payment methods in your PaymentSheet
// Note: some payment methods have different requirements: https://stripe.com/docs/payments/payment-methods/integration-options
payment_method_types: [
'card',
// 'ideal',
// 'sepa_debit',
// 'sofort',
Expand All @@ -563,7 +562,7 @@ app.post('/payment-sheet', async (_, res) => {
// 'giropay',
// 'eps',
// 'afterpay_clearpay',
// 'klarna',
'klarna',

Check warning on line 565 in example/server/src/index.ts

View workflow job for this annotation

GitHub Actions / Typo CI

klarna

"klarna" is a typo. Did you mean "carnal"?
// 'us_bank_account',
],
});
Expand Down
3 changes: 1 addition & 2 deletions packages/stripe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ dart pub add flutter_stripe
This plugin requires several changes to be able to work on Android devices. Please make sure you follow all these steps:

1. Use Android 5.0 (API level 21) and above
2. Use Kotlin version 1.5.0 and above: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/
.gradle#L2)
2. Use Kotlin version 1.5.0 and above: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/.gradle#L2)
3. Using a descendant of `Theme.AppCompat` for your activity: [example](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/app/src/main/res/values/styles.xml#L15), [example night theme](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/app/src/main/res/values-night/styles.xml#L16)
4. Using an up-to-date Android gradle build tools version: [example](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/build.gradle#L9) and an up-to-date gradle version accordingly: [example](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/android/gradle/wrapper/gradle-wrapper.properties#L6)
5. Using `FlutterFragmentActivity` instead of `FlutterActivity` in `MainActivity.kt`: [example](https://github.com/flutter-stripe/flutter_stripe/blob/79b201a2e9b827196d6a97bb41e1d0e526632a5a/example/android/app/src/main/kotlin/com/flutter/stripe/example/MainActivity.kt#L6)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/widgets.dart';
import 'package:stripe_checkout/src/platforms/checkout.dart';

Future<CheckoutResponse?> redirectToCheckout({
required BuildContext context,
required String sessionId,
required String publishableKey,
String? stripeAccountId,
String? successUrl,
String? canceledUrl,
}) async {
return null;
}
4 changes: 2 additions & 2 deletions packages/stripe_checkout/lib/stripe_checkout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import 'package:stripe_checkout/src/platforms/checkout.dart'
show CheckoutResponse;

import 'src/platforms/checkout.dart';
import 'src/platforms/stripe_checkout.dart'
import 'src/platforms/stripe_checkout_mobile.dart'
if (dart.library.js) 'src/platforms/stripe_checkout_web.dart' as stripe;

Future<CheckoutResponse> redirectToCheckout({
Future<CheckoutResponse?> redirectToCheckout({
required BuildContext context,
required String sessionId,
required String publishableKey,
Expand Down

0 comments on commit c28d84e

Please sign in to comment.