Skip to content

Commit 3c91ec0

Browse files
committed
feat: add onbehalfof to cardfield
1 parent eb3fbdc commit 3c91ec0

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

example/ios/Runner/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

packages/stripe/lib/src/widgets/card_field.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class CardField extends StatefulWidget {
3131
this.postalCodeHintText,
3232
this.controller,
3333
this.preferredNetworks,
34+
this.onBehalfOf,
3435
this.androidPlatformViewRenderType =
3536
AndroidPlatformViewRenderType.expensiveAndroidView,
3637
});
@@ -50,6 +51,9 @@ class CardField extends StatefulWidget {
5051
/// Color of the cursor when a field gets focus.
5152
final Color? cursorColor;
5253

54+
/// The account (if any) for which the funds of the intent are intended.
55+
final String? onBehalfOf;
56+
5357
/// Whether or not to show the postalcode field in the form.
5458
///
5559
/// Defaults is `false`. If your configuration in Stripe requires a postalcode
@@ -197,6 +201,7 @@ class _CardFieldState extends State<CardField> {
197201
focusNode: _node,
198202
style: style,
199203
placeholder: placeholder,
204+
onBehalfOf: widget.onBehalfOf,
200205
enablePostalCode: widget.enablePostalCode,
201206
countryCode: widget.countryCode,
202207
dangerouslyGetFullCardDetails:
@@ -295,6 +300,7 @@ class _MethodChannelCardField extends StatefulWidget {
295300
this.preferredNetworks,
296301
this.dangerouslyGetFullCardDetails = false,
297302
this.dangerouslyUpdateFullCardDetails = false,
303+
this.onBehalfOf,
298304
this.autofocus = false,
299305
}) : assert(constraints == null || constraints.debugAssertIsValid()),
300306
constraints = (width != null || height != null)
@@ -317,6 +323,7 @@ class _MethodChannelCardField extends StatefulWidget {
317323
final bool dangerouslyUpdateFullCardDetails;
318324
final AndroidPlatformViewRenderType androidPlatformViewRenderType;
319325
final List<CardBrand>? preferredNetworks;
326+
final String? onBehalfOf;
320327

321328
// This is used in the platform side to register the view.
322329
static const _viewType = 'flutter.stripe/card_field';
@@ -405,6 +412,7 @@ class _MethodChannelCardFieldState extends State<_MethodChannelCardField>
405412
'placeholder': placeholder.toJson(),
406413
'postalCodeEnabled': widget.enablePostalCode,
407414
'countryCode': widget.countryCode,
415+
if (widget.onBehalfOf != null) 'onBehalfOf': widget.onBehalfOf,
408416
if (widget.preferredNetworks != null)
409417
'preferredNetworks':
410418
widget.preferredNetworks?.map((e) => e.brandValue).toList(),

packages/stripe_android/android/src/main/kotlin/com/flutter/stripe/StripeSdkCardPlatformView.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class StripeSdkCardPlatformView(
3838
if (creationParams?.containsKey("postalCodeEnabled") == true) {
3939
stripeSdkCardViewManager.setPostalCodeEnabled(cardView, creationParams["postalCodeEnabled"] as Boolean)
4040
}
41+
if(creationParams?.containsKey("onBehalfOf")==true){
42+
stripeSdkCardViewManager.setOnBehalfOf(cardView, creationParams["onBehalfOf"] as String)
43+
}
4144
if (creationParams?.containsKey("countryCode") == true) {
4245
stripeSdkCardViewManager.setCountryCode(cardView, creationParams["countryCode"] as? String)
4346
}

packages/stripe_ios/ios/Classes/CardFieldFactory.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class CardFieldPlatformView: NSObject, FlutterPlatformView, STPPaymentCardTextFi
137137
cardField.disabled = disabled
138138
}
139139

140+
if let onBehalfOf = arguments["onBehalfOf"] as? String{
141+
cardField.onBehalfOf = onBehalfOf
142+
}
143+
140144
if let preferredNetworks = arguments["preferredNetworks"] as? Array<Int>{
141145
cardField.preferredNetworks = preferredNetworks
142146
}

packages/stripe_platform_interface/lib/src/models/payment_sheet.freezed.dart

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)