首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >要么您没有将卡保存到您的钱包,要么当前域未注册为Apple Pay

要么您没有将卡保存到您的钱包,要么当前域未注册为Apple Pay
EN

Stack Overflow用户
提问于 2022-08-20 13:47:46
回答 1查看 167关注 0票数 0

我正试图在我的网站上使用Stripe建立Apple Pay。

我遵循这里的说明,https://stripe.com/docs/stripe-js/elements/payment-request-button

我已经在Stripe上注册了我的域名

然后,我在我的macbook上的钱包里添加了测试卡,见这里。

当我在本地主机上运行ngrok时,ngrok向我展示了以下内容

代码语言:javascript
运行
复制
ngrok                                                                                                                 (Ctrl+C to quit)
                                                                                                                                      
Hello World! https://ngrok.com/next-generation                                                                                        
                                                                                                                                      
Session Status                online                                                                                                  
Account                       XXXXXXX (Plan: Pro)                                                                                    
Version                       3.0.6                                                                                                   
Region                        United States (us)                                                                                      
Latency                       302ms                                                                                                   
Web Interface                 http://127.0.0.1:4040                                                                                   
Forwarding                    https://XXXXXXXXXX.ngrok.io -> https://blabla.xxxxx.com:443                                           
                                                                                                                                      
Connections                   ttl     opn     rt1     rt5     p50     p90                                                             
                              91      0       0.01    0.01    5.03    9.41                                                            
                                                                                                                                      
HTTP Requests                                                                                                                         
-------------                                                                                                                         
                                                                                                                                      
GET /frontend/web/debug/default/toolbar    200 OK                                                                                     
GET /frontend/web/payment/checkout/ 200 OK                                                                                     
GET /frontend/web/debug/default/toolbar    200 OK                                                                                     
GET /frontend/web/payment/checkout/ 200 OK                                                                                     
GET /frontend/web/debug/default/toolbar    200 OK                                                                                     
GET /frontend/web/payment/checkout/ 200 OK                                                                                     
GET /frontend/web/debug/default/toolbar    200 OK                                                                                     
GET /frontend/web/payment/checkout/ 200 OK                                                                                     
GET /frontend/web/debug/default/toolbar    200 OK                                                                                     
GET /frontend/web/payment/checkout/ 200 OK 

当我通过Safari上的ngrok域查看我的站点时,我在safari控制台上得到了这个错误

代码语言:javascript
运行
复制
Either you do not have a card saved to your Wallet or the current domain (XXXXXXXX.ngrok.io) is not registered for Apple Pay. Visit https://dashboard.stripe.com/account/apple_pay to register this domain.

我使用stripe.js和stripe.js作为我的付款。这是我的JS

代码语言:javascript
运行
复制
var publishableKey = document.getElementById('payment-form').getAttribute('data-stripe-publishable-key');
var paymentIntent = document.getElementById('payment-form').getAttribute('data-stripe-paymentIntent');

document.addEventListener('DOMContentLoaded', async () => {
    if (!publishableKey) {
        document.getElementById('applepay-error').textContent = 'No publishable key returned from the server';
    }
  
    // 1. Initialize Stripe
    const stripe = Stripe(publishableKey, {
      apiVersion: '2020-08-27',
    });
  
    // 2. Create a payment request object
    var paymentRequest = stripe.paymentRequest({
      country: 'US',
      currency: 'usd',
      total: {
        label: 'Demo total',
        amount: 1999,
      },
      requestPayerName: true,
      requestPayerEmail: true,
    });
  
    // 3. Create a PaymentRequestButton element
    const elements = stripe.elements();
    const prButton = elements.create('paymentRequestButton', {
      paymentRequest: paymentRequest,
    });
  
    // Check the availability of the Payment Request API,
    // then mount the PaymentRequestButton
    paymentRequest.canMakePayment().then(function (result) {
      if (result) {
        prButton.mount('#applepay-element');
      } else {
        document.getElementById('applepay-element').style.display = 'none';
        document.getElementById('applepay-error').textContent = 'Apple Pay support not found. Check the pre-requisites above and ensure you are testing in a supported browser.';
      }
    });
  
paymentRequest.on('paymentmethod', async (e) => {
      // Confirm the PaymentIntent without handling potential next actions (yet).
      let {error, paymentIntent} = await stripe.confirmCardPayment(
        clientSecret,
        {
          payment_method: e.paymentMethod.id,
        },
        {
          handleActions: false,
        }
      );
  
      if (error) {
        document.getElementById('applepay-error').textContent = error.message;

        // Report to the browser that the payment failed, prompting it to
        // re-show the payment interface, or show an error message and close
        // the payment interface.
        e.complete('fail');
        return;
      }
      // Report to the browser that the confirmation was successful, prompting
      // it to close the browser payment method collection interface.
      e.complete('success');
  
      // Check if the PaymentIntent requires any actions and if so let Stripe.js
      // handle the flow. If using an API version older than "2019-02-11" instead
      // instead check for: `paymentIntent.status === "requires_source_action"`.
      if (paymentIntent.status === 'requires_action') {
        // Let Stripe.js handle the rest of the payment flow.
        let {error, paymentIntent} = await stripe.confirmCardPayment(
          clientSecret
        );
        if (error) {
            // The payment failed -- ask your customer for a new payment method.
            document.getElementById('applepay-error').textContent = error.message;
          return;
        }
        document.getElementById('applepay-error').textContent = 'Payment ${paymentIntent.status}: ${paymentIntent.id}';
      }
  
      document.getElementById('applepay-error').textContent = 'Payment ${paymentIntent.status}: ${paymentIntent.id}';
    });
  });  

知道怎么让这件事起作用吗?谢谢。

EN

回答 1

Stack Overflow用户

发布于 2022-08-22 02:48:24

可能有多个原因需要反复检查:

  1. 域是在与可发布密钥的所有者帐户不同的Stripe帐户中设置的。
  2. 问题涉及特定的苹果帐户。如果涉及Stripe连接和标准/直接收费,则
  3. 将更加复杂。

你可以再检查一遍,向你的朋友或同事寻求检查的帮助。如果这没有帮助,那么写信给Stripe支持,他们将能够帮助进一步检查3)。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73427218

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档