Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Apple Pay Bottom Sheet – Incorrect Failure Design Handling After Backend Call Using Apple Pay Token

未关闭
#322 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
dart, flutter, ios, swift
领域
mobile, payments

调研方向

从 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:

  1. User opens Apple Pay bottom sheet.
  2. Payment token is generated automatically by Apple Pay.
  3. User confirms payment via Face ID / double click.
  4. We call our backend createOrder API after authorization.
  5. 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 .success or .failure dynamically
  • 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

google-pay/flutter-plugin 的其他 Issue

查看 google-pay/flutter-plugin 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。