PEApplePayButton class
A button widget for initiating an Apple Pay transaction.
This button handles the Apple Pay payment process, including requesting payment details, processing transactions, and handling callbacks.
Example Usage:
// Create a payment request
final paymentRequest = PEPaymentRequest(
merchantId: Config.merchantId,
paymentAmount: 10.00,
paymentItems: [
PEPaymentItem(
label: "Test Item",
amount: 10.00,
)
],
platformOptions: PEApplePayOptions(
requiredBillingContactFields: [PEContactField.postalAddress],
requiredShippingContactFields: [PEContactField.name],
),
);
// Use the payment request in the Apple Pay button
PEApplePayButton(
paymentRequest: paymentRequest,
onPaymentFailed: (error) {
print('Payment failed: $error');
},
onPaymentSheetDismissed: () {
print('Payment sheet dismissed');
},
onTokenDidReturn: (token, metadata, billingContact, shippingContact) {
print('Received Apple Pay token: $token');
print('Metadata: $metadata');
print('Billing Contact: ${billingContact?.givenName}');
print('Shipping Contact: ${shippingContact?.givenName}');
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PEApplePayButton
Constructors
- PEApplePayButton({Key? key, required PEPaymentRequest paymentRequest, double width = double.infinity, double height = 36, dynamic onPaymentFailed(Exception)?, VoidCallback? onPaymentSheetDismissed, dynamic onTokenDidReturn(String token, dynamic metadata, PEApplePayContact? billingContact, PEApplePayContact? shippingContact)?})
-
Creates an instance of PEApplePayButton.
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
The height of the Apple Pay button.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- onPaymentFailed → dynamic Function(Exception)?
-
A callback function that is triggered when the payment fails.
final
- onPaymentSheetDismissed → VoidCallback?
-
A callback function that is triggered when the Apple Pay payment sheet is dismissed.
final
- onTokenDidReturn → dynamic Function(String token, dynamic metadata, PEApplePayContact? billingContact, PEApplePayContact? shippingContact)?
-
A callback function that is triggered when the Apple Pay token is successfully generated.
final
- paymentRequest → PEPaymentRequest
-
The payment request containing details about the transaction.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- width → double
-
The width of the Apple Pay button.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PEApplePayButton> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited