File tree 4 files changed +9
-9
lines changed
Samples/MobileBuyIntegration/MobileBuyIntegration
4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -151,13 +151,8 @@ extension ApplePayHandler: PKPaymentAuthorizationControllerDelegate {
151
151
partial: true
152
152
)
153
153
154
- guard let firstDeliveryGroup = CartManager . shared. cart? . deliveryGroups. nodes. first
155
- else {
156
- throw CartManager . Errors. invariant ( message: " deliveryGroups empty " )
157
- }
158
-
159
154
let shippingMethods = PassKitFactory . shared. createShippingMethods (
160
- firstDeliveryGroup: firstDeliveryGroup
155
+ firstDeliveryGroup: CartManager . shared . cart ? . deliveryGroups . nodes . first
161
156
)
162
157
163
158
_ = try await CartManager . shared. performCartPrepareForCompletion ( )
Original file line number Diff line number Diff line change @@ -108,8 +108,13 @@ class PassKitFactory {
108
108
}
109
109
110
110
public func createShippingMethods(
111
- firstDeliveryGroup: Storefront . CartDeliveryGroup
111
+ /**
112
+ * Default to first delivery group when user changes their delivery contact
113
+ * `nil` for digital products
114
+ */
115
+ firstDeliveryGroup: Storefront . CartDeliveryGroup ?
112
116
) -> [ PKShippingMethod ] {
117
+ guard let firstDeliveryGroup else { return [ ] }
113
118
return firstDeliveryGroup. deliveryOptions. compactMap {
114
119
guard let title = $0. title, let description = $0. description else {
115
120
print ( " Invalid deliveryOption to map shipping method " )
Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ class CartManager: ObservableObject {
178
178
179
179
let buyerIdentityInput = StorefrontInputFactory . shared. createCartBuyerIdentityInput (
180
180
// During ApplePay `contact.emailAddress` is nil until `didAuthorizePayment`
181
- email: contact. emailAddress ?? " " ,
181
+ email: contact. emailAddress,
182
182
deliveryAddressPreferencesInput: deliveryAddressPreferencesInput
183
183
)
184
184
Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ class StorefrontInputFactory {
192
192
}
193
193
194
194
public func createCartBuyerIdentityInput(
195
- email: String ,
195
+ email: String ? ,
196
196
deliveryAddressPreferencesInput: Input < [ Storefront . DeliveryAddressInput ] >
197
197
) -> Storefront . CartBuyerIdentityInput {
198
198
if appConfiguration. useVaultedState {
You can’t perform that action at this time.
0 commit comments