【问题标题】:Apple Pay Stripe IntegrationsApple Pay 条纹集成
【发布时间】:2020-05-23 16:00:43
【问题描述】:

这是我使用 Stripe 开发 Apple Payment Request 按钮的 JavaScript 代码,我在上面放置了相关代码,我还添加了相关的 stripe v3 库并添加了一个带有 payment-request-button id 的 div在html中

var stripe = Stripe('pk_test_ZjbcGwDeoJsycvIs7KGEFkVR00qOzHxlrX');
    elements = stripe.elements();

    // Config payment request
    paymentRequest = stripe.paymentRequest({
     country: 'US',
     currency: 'usd',
     total: {
      label: 'Demo total',
      amount: 100,
     },
    });
    paymentRequest.on('source', function(event) {
     console.log('Got source: ', event.source.id);
     event.complete('success');
     ChromeSamples.log(JSON.stringify(event.source, 2));
     // Send the source to your server to charge it!
    });
    prButton = elements.create('paymentRequestButton', {
     paymentRequest,
    });
    // Check the availability of the Payment Request API first.
    paymentRequest.canMakePayment().then((result) => {
     //console.log(prButton);
     if (result) {
      prButton.mount('#payment-request-button');
     } else {
      document.getElementById('payment-request-button').style.display = 'none';
      ChromeSamples.setStatus("Not supported, please check: https://stripe.com/docs/elements/payment-request-button#testing");
     }
    });

    // Helpers
    var ChromeSamples = {
     log: function() {
      var line = Array.prototype.slice.call(arguments).map(function(argument) {
       return typeof argument === 'string' ? argument : JSON.stringify(argument);
      }).join(' ');

      document.querySelector('#log').textContent += line + '\n';
     },

     clearLog: function() {
      document.querySelector('#log').textContent = '';
     },

     setStatus: function(status) {
      document.querySelector('#status').textContent = status;
     },

     setContent: function(newContent) {
      var content = document.querySelector('#content');
      while (content.hasChildNodes()) {
       content.removeChild(content.lastChild);
      }
      content.appendChild(newContent);
     }
    };

【问题讨论】:

  • 我不得不想象有集成/实现文档供您遵循。这不是一般“我需要建立付款流程的分步指南”的地方
  • 我正在执行这些步骤,但我无法看到按钮。
  • 如果您有尝试过的代码,请更新您的问题以包含它。还包括对预期结果和实际结果的详细描述,以及您已经完成的调试。还请花一些时间查看How To Ask,以获取构建更好问题的指南。
  • @mukeshkumar 你用什么浏览器测试? Apple Pay 按钮仅在 iOS 或 Mac 中显示,并且仅在使用 Safari 时显示。它不会出现在 Firefox 或 Windows 中。
  • 我已按照此链接为 web stripe.com/docs/stripe-js/elements/payment-request-button创建了一个 Stripe Apple Pay 付款请求按钮

标签: php stripe-payments laravel-5.8 applepay applepayjs


【解决方案1】:

我正在 Window 10 OS 的 Chrome 80+ 版本中对其进行测试

根据 Apple 的 "Apple Pay is compatible with these devices" page,Apple Pay 仅适用于 Mac、iPhone、iPad 和 Apple Watch 设备,并且仅适用于 Safari。

Stripe docs you linked 也说:

带有付款请求按钮的 Apple Pay 需要 macOS 10.12.1+ 或 iOS 10.1+。

您需要一台 Apple 设备来测试您的 Apple Pay 集成。

【讨论】:

  • 是的,我认为你是对的。但是,在印度,我们可以创建一个沙盒测试器进行测试
  • 我们可以使用沙盒测试帐户在印度测试苹果支付吗
猜你喜欢
  • 2015-08-13
  • 2018-09-30
  • 2023-02-08
  • 1970-01-01
  • 2021-09-16
  • 2015-01-30
  • 2016-08-30
  • 2020-03-27
  • 2020-09-05
相关资源
最近更新 更多