Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes december #1543

Merged
merged 16 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,36 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## 2023-12-11

### Changes

---

Packages with breaking changes:

- There are no breaking changes in this release.

Packages with other changes:

- [`stripe_js` - `v3.3.0`](#stripe_js---v330)
- [`flutter_stripe_web` - `v4.6.1`](#flutter_stripe_web---v461)

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` - `v4.6.1`

---

#### `stripe_js` - `v3.3.0`

- aaa

- **FIX**: invalid argument `requires_capture` on web (#1431).


## 2023-11-29

### Changes
Expand Down
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,24 @@ 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/main/example/android/build.gradle)
3. Requires Android Gradle plugin 8 and higher
4. 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)
5. 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)
6. 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)
7. Rebuild the app, as the above changes don't update with hot reload
7. Add the following rules to your `proguard-rules.pro` file: [example](https://github.com/flutter-stripe/flutter_stripe/blob/master/example/android/app/proguard-rules.pro)
```proguard
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
```
8. Rebuild the app, as the above changes don't update with hot reload

These changes are needed because the Android Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

If you are having troubles to make this package to work on Android, join [this discussion](https://github.com/flutter-stripe/flutter_stripe/discussions/538) to get some support
If you are having troubles to make this package to work on Android, join [this discussion](https://github.com/flutter-stripe/flutter_stripe/discussions/538) to get some support.

#### iOS

Expand All @@ -68,6 +76,16 @@ You will also need to update in your Podfile:

`platform :ios, '13.0'`

For card scanning add the following to your Info.plist:

```xml
<key>NSCameraUsageDescription</key>
<string>Scan your card to add it automatically</string>
<key>NSCameraUsageDescription
&lt;string&gt;To scan cards&lt;/string&gt;</key>
<string>To scan cards</string>
```

#### Web (Experimental)

Now you can use Stripe with Flutter web! Notice right now it is highly experimental and only a subset of features is implemented. Namely:
Expand Down
26 changes: 23 additions & 3 deletions docs/troubleshooting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ You can check if your backend is communicating with the live environment at the
"livemode": true,
"next_action": null,
"status": "succeeded",
...
}
```

#### Client side
Expand Down Expand Up @@ -157,16 +157,19 @@ The payment intent should be linked to a customer and for the customer an epheme


```json

{
"id": "pi_12345",
"object": "payment_intent",
....
"charges": {
"object": "list",
"data": [
{
"id": "ch_1234",
"customer": "cus_12345",
}
]
},
}
```

#### Client-side
Expand All @@ -184,4 +187,21 @@ The payment intent should be linked to a customer and for the customer an epheme
customerEphemeralKeySecret: data['ephemeralKey'],
// Extra params
```
#### Android compile issue app bundle
When you get this issue when building android app bundle.

```bash
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error (referenced from: void com.reactnativestripesdk.pushprovisioning.PushProvisioningProxy$createActivityEventListener$listener$1.onActivityResult(android.app.Activity, int, int, android.content.Intent))
Missing class com.stripe.android.pushProvisioning.PushProvisioningActivityStarter (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider))
Missing class com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider (referenced from: void com.reactnativestripesdk.pushprovisioning.DefaultPushProvisioningProxy.beginPushProvisioning(android.app.Activity, java.lang.String, com.reactnativestripesdk.pushprovisioning.EphemeralKeyProvider) and 1 other context)
```

Add the following rules to your `proguard-rules.pro` file: [example](https://github.com/flutter-stripe/flutter_stripe/blob/master/example/android/app/proguard-rules.pro)
```proguard
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
```
5 changes: 4 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace 'com.flutter.stripe.example'
compileSdk 33
compileSdk 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_17
Expand All @@ -53,6 +53,9 @@ android {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug

proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"

}
}
}
Expand Down
5 changes: 5 additions & 0 deletions example/android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
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'],
returnURL: 'flutterstripe://redirect',

// Extra params
primaryButtonLabel: 'Pay now',
Expand Down
12 changes: 11 additions & 1 deletion example/lib/screens/wallets/apple_pay_create_payment_method.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:stripe_example/widgets/example_scaffold.dart';
import 'package:stripe_example/widgets/response_card.dart';

class ApplePayCreatePaymentMethodScreen extends StatefulWidget {
@override
_ApplePayScreenState createState() => _ApplePayScreenState();
}

class _ApplePayScreenState extends State<ApplePayCreatePaymentMethodScreen> {
PlatformPayPaymentMethod? response;
@override
void initState() {
Stripe.instance.isPlatformPaySupportedListenable.addListener(update);
Expand Down Expand Up @@ -37,6 +39,10 @@ class _ApplePayScreenState extends State<ApplePayCreatePaymentMethodScreen> {
)
else
Text('Apple Pay is not available in this device'),
SizedBox(
height: 50,
),
ResponseCard(response: response?.toString() ?? ''),
],
);
}
Expand Down Expand Up @@ -76,8 +82,12 @@ class _ApplePayScreenState extends State<ApplePayCreatePaymentMethodScreen> {
),
);

setState(() {
response = paymentMethod;
});

ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(
'Success!: The payment method with id: ${paymentMethod.id} was created successfully,')));
'Success!: The payment method with id: ${paymentMethod.paymentMethod.id} was created successfully,')));
}
}
3 changes: 2 additions & 1 deletion example/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@
// 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 @@ -562,7 +563,7 @@
// 'giropay',
// 'eps',
// 'afterpay_clearpay',
'klarna',
// 'klarna',

Check warning on line 566 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
24 changes: 21 additions & 3 deletions packages/stripe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,24 @@ 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/main/example/android/build.gradle)
3. Requires Android Gradle plugin 8 and higher
4. 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)
5. 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)
6. 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)
7. Rebuild the app, as the above changes don't update with hot reload
7. Add the following rules to your `proguard-rules.pro` file: [example](https://github.com/flutter-stripe/flutter_stripe/blob/master/example/android/app/proguard-rules.pro)
```proguard
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivity$g
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Args
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter$Error
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningActivityStarter
-dontwarn com.stripe.android.pushProvisioning.PushProvisioningEphemeralKeyProvider
```
8. Rebuild the app, as the above changes don't update with hot reload

These changes are needed because the Android Stripe SDK requires the use of the AppCompat theme for their UI components and the Support Fragment Manager for the Payment Sheets

If you are having troubles to make this package to work on Android, join [this discussion](https://github.com/flutter-stripe/flutter_stripe/discussions/538) to get some support
If you are having troubles to make this package to work on Android, join [this discussion](https://github.com/flutter-stripe/flutter_stripe/discussions/538) to get some support.

#### iOS

Expand All @@ -68,6 +76,16 @@ You will also need to update in your Podfile:

`platform :ios, '13.0'`

For card scanning add the following to your Info.plist:

```xml
<key>NSCameraUsageDescription</key>
<string>Scan your card to add it automatically</string>
<key>NSCameraUsageDescription
&lt;string&gt;To scan cards&lt;/string&gt;</key>
<string>To scan cards</string>
```

#### Web (Experimental)

Now you can use Stripe with Flutter web! Notice right now it is highly experimental and only a subset of features is implemented. Namely:
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe/lib/src/stripe.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class Stripe {
/// Creating payment method does not return a token by default. Use `usesDeprecatedTokenFlow` instead.
///
/// throws [StripeError] in case creating payment method is failing.
Future<PaymentMethod> createPlatformPayPaymentMethod({
Future<PlatformPayPaymentMethod> createPlatformPayPaymentMethod({
required PlatformPayPaymentMethodParams params,
bool usesDeprecatedTokenFlow = false,
}) async {
Expand Down
6 changes: 3 additions & 3 deletions packages/stripe/lib/src/widgets/apple_pay_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ApplePayButton extends StatelessWidget {
Key? key,
this.style = PlatformButtonStyle.automatic,
this.type = PlatformButtonType.plain,
this.cornerRadius=4,
this.cornerRadius = 4,
this.onPressed,
double? width,
double? height = _kApplePayButtonDefaultHeight,
Expand Down Expand Up @@ -242,8 +242,8 @@ class _UiKitApplePayButtonState extends State<_UiKitApplePayButton> {
}

// For some reason json serializable cannot be cast
ApplePayShippingContact _convertShippingContact(dynamic json) =>
ApplePayShippingContact(
PlatformPayShippingContact _convertShippingContact(dynamic json) =>
PlatformPayShippingContact(
phoneNumber: json['phoneNumber'],
name: ApplePayContactName(
familyName: json['name']['familyName'],
Expand Down
4 changes: 4 additions & 0 deletions packages/stripe_js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.3.0
**FIXES**
- Invalid argument `requires_capture` on web (#1431).

## 3.2.0
**FIXES**
- PaymentConfirmationRedirect enum value (#1221).
Expand Down
2 changes: 1 addition & 1 deletion packages/stripe_js/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: stripe_js
description: Stripe.js bindings for dart. This package is used by Stripe web so that the Stripe js sdk can be invoked directly.
version: 3.2.0
version: 3.3.0
homepage: https://github.com/flutter-stripe/flutter_stripe

environment:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ class MethodChannelStripe extends StripePlatform {
PaymentSheetPaymentOption? _parsePaymentSheetResult(
Map<String, dynamic>? result) {
if (result != null) {
if (result.isEmpty) {
///iOS sometimes returns empty paymentoption so add workaround for it.
if (result.isEmpty ||
(result['paymentOption'] == null && result['error'] == null)) {
return null;
} else if (result['paymentOption'] != null) {
return PaymentSheetPaymentOption.fromJson(result['paymentOption']);
Expand Down Expand Up @@ -568,7 +570,7 @@ class MethodChannelStripe extends StripePlatform {
}

@override
Future<PaymentMethod> platformPayCreatePaymentMethod({
Future<PlatformPayPaymentMethod> platformPayCreatePaymentMethod({
required PlatformPayPaymentMethodParams params,
bool usesDeprecatedTokenFlow = false,
}) async {
Expand Down Expand Up @@ -596,9 +598,11 @@ class MethodChannelStripe extends StripePlatform {
'usesDeprecatedTokenFlow': usesDeprecatedTokenFlow,
});

return ResultParser<PaymentMethod>(
parseJson: (json) => PaymentMethod.fromJson(json))
.parse(result: result!, successResultKey: 'paymentMethod');
if (result!.containsKey('error')) {
throw ResultParser<void>(parseJson: (json) => {}).parseError(result);
}

return PlatformPayPaymentMethod.fromJson(result);
}

@override
Expand Down
24 changes: 2 additions & 22 deletions packages/stripe_platform_interface/lib/src/models/apple_pay.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:stripe_platform_interface/src/models/platform_pay.dart';

part 'apple_pay.freezed.dart';
part 'apple_pay.g.dart';
Expand Down Expand Up @@ -202,28 +203,7 @@ class ApplePayErrorAddressField with _$ApplePayErrorAddressField {
_$ApplePayErrorAddressFieldFromJson(json);
}

@freezed

/// Entered Shipping contact data
class ApplePayShippingContact with _$ApplePayShippingContact {
@JsonSerializable(explicitToJson: true)
const factory ApplePayShippingContact({
/// Email address of the shipping contact
String? emailAddress,

/// Name of shipping contact
required ApplePayContactName name,

/// Postal address of shipping contact
required ApplePayPostalAddress postalAddress,

///Phone Number of the shipping contact
String? phoneNumber,
}) = _ApplePayShippingContact;

factory ApplePayShippingContact.fromJson(Map<String, dynamic> json) =>
_$ApplePayShippingContactFromJson(json);
}

@freezed

Expand Down Expand Up @@ -264,7 +244,7 @@ class ApplePayPostalAddress with _$ApplePayPostalAddress {
}

typedef OnDidSetShippingContact = FutureOr<void> Function(
ApplePayShippingContact contact);
PlatformPayShippingContact contact);
typedef OnDidSetShippingMethod = FutureOr<void> Function(
ApplePayShippingMethod method);
typedef OnCouponCodeEntered = FutureOr<void> Function(String couponCode);
Expand Down
Loading
Loading