Apple Pay Bottom Sheet – Incorrect Failure Design Handling After Backend Call Using Apple Pay Token
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
调研方向
从 issue 中所示的 Flutter ApplePayButton 配置和原生 iOS paymentAuthorizationController callback 开始。复现一次异步 createOrder 失败,并检查 plugin 如何处理 completion handler 和 payment result。当已确定延迟成功或失败所支持的行为,并以一致的方式将其记录或暴露出来时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Dart
- 星标
- 180
- 派生
- 144
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
google-pay/flutter-plugin 的其他 Issue
-
Unable to load asset: "packages/pay_platform_interface/pubspec.yaml".可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 3/5 1-2 天 新手友好度 42/100
google-pay/flutter-plugin#331 ·
-
难度 4/5 3-5 天 新手友好度 52/100
google-pay/flutter-plugin#323 · 3 条评论 · 1 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 52/100
google-pay/flutter-plugin#321 · 2 条评论 · 9 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 40/100
google-pay/flutter-plugin#312 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 25/100
google-pay/flutter-plugin#311 · 2 条评论 ·
查看 google-pay/flutter-plugin 的全部 Issue
相似的 Issue
-
area/ci-build bug
难度 2/5 1-3 小时 新手友好度 65/100
DarkFlippers/qUnleashed#423 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 67/100
google/skills_lint.dart#152 ·
维护者通常 1 天内回复
-
Docs: correct the unbuilt "full re-verify" claim and three untrue sync comments可能已有人在做 @ibanner56 今天认领。 未关闭area: sync priority: low severity: trivial type: docs
难度 2/5 1-3 小时 新手友好度 75/100
ibanner56/CallersCompendium#1942 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 64/100
appshubcc/Bettbox#584 · 1 条评论 ·
维护者通常 1 天内回复