Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into web_deffered_payment

# Conflicts:
#	packages/stripe/CHANGELOG.md
#	packages/stripe/pubspec.yaml
#	packages/stripe_js/CHANGELOG.md
#	packages/stripe_js/lib/src/api/payment_intents/confirm_payment_options.freezed.dart
#	packages/stripe_js/lib/src/js/elements/elements.dart
#	packages/stripe_js/pubspec.yaml
#	packages/stripe_platform_interface/CHANGELOG.md
#	packages/stripe_web/CHANGELOG.md
#	packages/stripe_web/lib/src/widgets/payment_element.dart
#	packages/stripe_web/pubspec.yaml
  • Loading branch information
Eduard Dumitrescu committed Oct 30, 2024
2 parents 2ac8be2 + d73d633 commit 232af88
Show file tree
Hide file tree
Showing 81 changed files with 6,782 additions and 2,069 deletions.
146 changes: 146 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,152 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`flutter_stripe` - `v11.2.0`](#flutter_stripe---v1120)

---

#### `flutter_stripe` - `v11.2.0`


## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`stripe_android` - `v11.2.0`](#stripe_android---v1120)
- [`flutter_stripe` - `v11.1.1`](#flutter_stripe---v1111)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `flutter_stripe` - `v11.1.1`

---

#### `stripe_android` - `v11.2.0`


## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`stripe_ios` - `v11.2.0`](#stripe_ios---v1120)
- [`flutter_stripe` - `v11.1.1`](#flutter_stripe---v1111)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `flutter_stripe` - `v11.1.1`

---

#### `stripe_ios` - `v11.2.0`


## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`flutter_stripe_web` - `v6.2.0`](#flutter_stripe_web---v620)

---

#### `flutter_stripe_web` - `v6.2.0`


## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`stripe_js` - `v6.2.0`](#stripe_js---v620)
- [`flutter_stripe_web` - `v6.1.1`](#flutter_stripe_web---v611)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `flutter_stripe_web` - `v6.1.1`

---

#### `stripe_js` - `v6.2.0`


## 2024-10-08

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`stripe_platform_interface` - `v11.2.0`](#stripe_platform_interface---v1120)
- [`flutter_stripe_web` - `v6.1.1`](#flutter_stripe_web---v611)
- [`flutter_stripe` - `v11.1.1`](#flutter_stripe---v1111)

Packages with dependency updates only:

> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `flutter_stripe_web` - `v6.1.1`
- `flutter_stripe` - `v11.1.1`

---

#### `stripe_platform_interface` - `v11.2.0`

- **FIX**: #1912 wallet parsing.


## 2024-09-18

### Changes
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,18 @@ For card scanning add the following to your Info.plist:
<string>To scan cards</string>
```

#### Web (Experimental)
#### Web

Now you can use Stripe with Flutter web! Notice right now it is highly experimental and only a subset of features is implemented. Namely:

- Create paymentmethod
- Confirm payment intent
- Confirm setup intent
- Create token
- Confirm payment element (recommended way of handling payments on web)

### Supported widgets
- [Confirm payment element](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/lib/screens/payment_sheet/payment_element/platforms/payment_element_web.dart) (recommended way of handling payments on web)
- [Express checkout](https://github.com/flutter-stripe/flutter_stripe/blob/main/example/lib/screens/payment_sheet/express_checkout/platforms/express_checkout_element_web.dart)

To use Stripe on web, it is required to add `flutter_stripe_web` in your pubspec file

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import 'dart:convert';

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

import 'platforms/express_checkout_element.dart'
if (dart.library.js) 'platforms/express_checkout_element_web.dart';

class ExpressCheckoutElementExample extends StatefulWidget {
@override
_ThemeCardExampleState createState() => _ThemeCardExampleState();
}

class _ThemeCardExampleState extends State<ExpressCheckoutElementExample> {
String? clientSecret;

@override
void initState() {
super.initState();
getClientSecret();
}

Future<void> getClientSecret() async {
try {
final client = await createPaymentIntent();
setState(() {
clientSecret = client;
});
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
e.toString(),
),
),
);
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter App'),
),
body: Center(
child: Container(
constraints: BoxConstraints(maxWidth: 600),
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 52),
child: Column(
children: [
SizedBox(
child: clientSecret != null
? ExpressCheckoutWidget(clientSecret)
: Center(child: CircularProgressIndicator())),
LoadingButton(onPressed: pay, text: 'Pay'),
],
),
),
),
);
}

Future<String> 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': 'usd',
'amount': 5099,
}),
);
return json.decode(response.body)['clientSecret'];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/widgets.dart';

Future<void> pay() async {
throw UnimplementedError();
}

class ExpressCheckoutWidget extends StatelessWidget {
const ExpressCheckoutWidget(this.clientSecret);

final String? clientSecret;

@override
Widget build(BuildContext context) {
return Container();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_stripe_web/flutter_stripe_web.dart';
import 'package:web/web.dart' as web;

String getUrlPort() => web.window.location.port;

String getReturnUrl() => web.window.location.href;

Future<void> pay() async {
await WebStripe.instance.confirmPaymentElement(
ConfirmPaymentElementOptions(
confirmParams: ConfirmPaymentParams(return_url: getReturnUrl()),
),
);
}

class ExpressCheckoutWidget extends StatelessWidget {
const ExpressCheckoutWidget(this.clientSecret);

final String? clientSecret;

@override
Widget build(BuildContext context) {
return ExpressCheckoutElement(
onConfirm: (value) {
pay();
},
clientSecret: clientSecret ?? '',
);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:html' as html;
import 'package:web/web.dart' as html;

String getUrlPort() => html.window.location.port;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ class AffirmScreen extends StatelessWidget {
}),
);

print('blaat ${json.decode(response.body)}');
return json.decode(response.body);
}

Expand Down
14 changes: 14 additions & 0 deletions example/lib/screens/screens.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:stripe_example/screens/customer_sheet/customer_sheet_screen.dart';
import 'package:stripe_example/screens/others/can_add_to_wallet_screen.dart';
import 'package:stripe_example/screens/payment_sheet/express_checkout/express_checkout_element.dart';
import 'package:stripe_example/screens/payment_sheet/payment_element/payment_element.dart';
import 'package:stripe_example/screens/payment_sheet/payment_sheet_deffered_screen.dart';
import 'package:stripe_example/screens/payment_sheet/payment_sheet_screen.dart';
Expand All @@ -20,6 +21,7 @@ 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/mobile_pay_create_payment_method_screen.dart';
import 'package:stripe_example/screens/wallets/open_apple_pay_setup_screen.dart';
import 'package:stripe_example/widgets/platform_icons.dart';

Expand Down Expand Up @@ -122,6 +124,13 @@ class Example extends StatelessWidget {
DevicePlatform.web,
],
),
Example(
title: 'ExpressCheckout',
builder: (c) => ExpressCheckoutElementExample(),
platformsSupported: [
DevicePlatform.web,
],
),
],
expanded: true,
),
Expand Down Expand Up @@ -226,6 +235,11 @@ class Example extends StatelessWidget {
builder: (c) => GooglePayScreen(),
platformsSupported: [DevicePlatform.android],
),
Example(
title: 'Google/Apple Pay - Create payment method',
builder: (c) => MobilePayCreatePaymentMethodScreen(),
platformsSupported: [DevicePlatform.web],
),
],
),
ExampleSection(title: 'Regional Payment Methods', children: [
Expand Down
Loading

0 comments on commit 232af88

Please sign in to comment.