首页 > 解决方案 > Apple Pay web 使用 c#(在 ngrok 上测试)

问题描述

我正在尝试使用ngrok测试我的 Apple 支付应用程序。但是,商家验证失败,我没有获得所需的令牌。Apple 支付按钮在我用于测试的 iPhone 上可见。我已使用此链接创建示例应用程序:https ://github.com/justeat/ApplePayJSSample

我得到了以下信息(如上面的 URL 所示)

  1. pfx 文件(放置在项目路径中)
  2. 商家验证 txt 文件(放在 .wellknown 文件夹中)
  3. 域名在apple pay网站上通过验证

有人可以建议如何测试应用程序吗?或者商户验证失败的可能原因?

requestUri 应该是什么(test 和 Prod 是否不同?),显示名称可以是任何东西还是特定于证书?

JsonDocument merchantSession;
                if (!ModelState.IsValid ||
                    string.IsNullOrWhiteSpace(model?.ValidationUrl) ||
                    !Uri.TryCreate(model.ValidationUrl, UriKind.Absolute, out Uri requestUri))
                {
                    return BadRequest();
                }
                // Create the JSON payload to POST to the Apple Pay merchant validation URL.
                var request = new MerchantSessionRequest()
                {
                    DisplayName = _options.StoreName,
                    Initiative = "web",
                    InitiativeContext = Request.GetTypedHeaders().Host.Value,
                    MerchantIdentifier = _ApplePayServieBusiness.GetMerchantIdentifier(),
                };

 

                merchantSession = await _ApplePayServieBusiness.GetMerchantSessionAsync(requestUri, request, cancellationToken);

更新: 我已将用于 MerchantValidation 的步骤放在以下链接中。但是,我仍然无法在 site.js https://github.com/justeat/ApplePayJSSample/issues/68#issuecomment-795687727中点击 onpaymentauthorized 函数

标签: c#iosngrok

解决方案


推荐阅读