Apple Pay Bottom Sheet – Incorrect Failure Design Handling After Backend Call Using Apple Pay Token
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con la configurazione Flutter di ApplePayButton e il callback nativo iOS paymentAuthorizationController mostrati nell’issue. Riproduci un errore asincrono di createOrder e verifica come il plugin gestisce il completion handler e il payment result. Il lavoro è completato quando il comportamento supportato per un successo o un errore ritardato è stato identificato e documentato o esposto in modo coerente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Dear All
Kindly Inform You
We are facing an issue with Apple Pay payment flow when handling async order creation.
Current flow:
- User opens Apple Pay bottom sheet.
- Payment token is generated automatically by Apple Pay.
- User confirms payment via Face ID / double click.
- We call our backend
createOrderAPI after authorization. - We need to wait for the API response before dismissing the Apple Pay sheet.
to handle Bottom Sheet Message "Done" or "Payment Failed" the Current situation now it return All the time as "Done" but we need if the backend replay to us as Payment Failed show this "Payment Failed" to the user
Expected behavior:
- If the API succeeds → show payment success.
- If the API fails → keep the sheet open and show “Payment Failed”.
Issue:
Apple Pay requires PKPaymentAuthorizationResult to be returned immediately, but our order creation is async. There is no clear way to keep the Apple Pay bottom sheet active until the backend response is received, and then emit success or failure properly.
Currently, even when the backend fails, the sheet dismisses before we can show an error.
Question:
What is the recommended way to:
- Delay completion of
didAuthorizePayment - Wait for backend response
- Return
.successor.failuredynamically - Display “Payment Failed” without dismissing the Apple Pay sheet prematurely?
Please find below the payment configuration I'm using:
ApplePayButton(
paymentConfiguration: PaymentConfiguration.fromJsonString(
'''{
"provider": "apple_pay",
"data": {
"merchantIdentifier": "$merchantId",
"displayName": "App Name",
"merchantCapabilities": ["3DS", "debit", "credit"],
"supportedNetworks": ["amex", "visa", "discover", "masterCard","Visa","mada"],
"countryCode": "SA",
"currencyCode": "SAR",
"requiredBillingContactFields": [],
"requiredShippingContactFields": [],
"shippingMethods": []
}
}''',
),
paymentItems: [
PaymentItem(
label: 'App Name',
amount: amount,
status: PaymentItemStatus.final_price,
),
],
style: ApplePayButtonStyle.black,
type: ApplePayButtonType.inStore,
width: double.infinity,
height: 50,
onPaymentResult: onPressed,
onPressed: onClick,
loadingIndicator: Center(child: CircularProgressIndicator()),
)
and this is the code that we use it in native IOS swift App
func paymentAuthorizationController(
_ controller: PKPaymentAuthorizationController,
didAuthorizePayment payment: PKPayment,
handler completion: @escaping (PKPaymentAuthorizationResult) -> Void
) {
createOrder(paymentToken: payment.token) { result in
switch result {
case .success:
completion(
PKPaymentAuthorizationResult(status: .success)
)
case .failure:
completion(
PKPaymentAuthorizationResult(
status: .failure,
errors: [NSError(
domain: PKPaymentErrorDomain,
code: PKPaymentError.Code.unknownError.rawValue,
userInfo: [NSLocalizedDescriptionKey: "Payment Failed"]
)]
)
)
}
}
}
Beast Regards
Mohamed Elgammal
- Lingua principale
- Dart
- Stelle
- 176
- Fork
- 146
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google-pay/flutter-plugin
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
google-pay/flutter-plugin#331 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
google-pay/flutter-plugin#323 · 2 commenti · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 52/100
google-pay/flutter-plugin#321 · 2 commenti · 9 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
google-pay/flutter-plugin#312 · 1 commento ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
google-pay/flutter-plugin#311 · 2 commenti ·
Tutte le issue di google-pay/flutter-plugin
Issue simili
-
Smart charging: USB charger re-assert is starved during BLE scans, so the tablet never dischargesApertabug ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
decentespresso/decaid#931 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
flame-engine/flame#4067 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
mrgnhnt96/zonai#37 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
google/skills_lint.dart#58 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
nvim-flutter/flutter-tools.nvim#557 ·
I maintainer di solito rispondono entro 1 giorno