---
title: PayWithApplePayButton
framework: passkit
role: symbol
role_heading: Structure
path: passkit/paywithapplepaybutton
---

# PayWithApplePayButton

A type that provides a button to pay with Apple pay.

## Declaration

```swift
@MainActor @preconcurrency struct PayWithApplePayButton<Fallback> where Fallback : View
```

## Overview

Overview Use this structure as the SwiftUI equivalent to PKPaymentButton. For design guidance, see Human Interface Guidelines > Apple Pay > Using Apple Pay buttons. This example shows an implementation of the Pay with Apple Pay button. // Create a payment request. @State private var paymentRequest = PKPaymentRequest()

// Create a payment authorization change method. func paymentAuthorizationDidChange(phase: PayWithApplePayButtonPaymentAuthorizationPhase) { ... }

@ViewBuilder var payButton: some View {     PayWithApplePayButton(         .plain,         request: paymentRequest,         onPaymentAuthorizationChange: paymentAuthorizationDidChange     ) {         // Display a fallback view if the payment request fails.     }     .frame(width: 250, height: 50)     .payWithApplePayButtonStyle(.automatic) }

## Topics

### Creating the button

- [init(_:action:)](passkit/paywithapplepaybutton/init(_:action:).md)
- [init(_:action:fallback:)](passkit/paywithapplepaybutton/init(_:action:fallback:).md)
- [init(_:request:onPaymentAuthorizationChange:)](passkit/paywithapplepaybutton/init(_:request:onpaymentauthorizationchange:).md)
- [init(_:request:onPaymentAuthorizationChange:fallback:)](passkit/paywithapplepaybutton/init(_:request:onpaymentauthorizationchange:fallback:).md)
- [init(_:request:onPaymentAuthorizationChange:onMerchantSessionRequested:)](passkit/paywithapplepaybutton/init(_:request:onpaymentauthorizationchange:onmerchantsessionrequested:).md)
- [init(_:request:onPaymentAuthorizationChange:onMerchantSessionRequested:fallback:)](passkit/paywithapplepaybutton/init(_:request:onpaymentauthorizationchange:onmerchantsessionrequested:fallback:).md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
- [View](swiftui/view.md)

## See Also

### Apple Pay buttons

- [PKPaymentButton](passkit/pkpaymentbutton.md)
- [PayWithApplePayButtonLabel](passkit/paywithapplepaybuttonlabel.md)
- [PayWithApplePayButtonStyle](passkit/paywithapplepaybuttonstyle.md)
- [PayWithApplePayButtonLabel](passkit/paywithapplepaybuttonlabel.md)
