【问题标题】:Stripe - Not charging card条纹 - 不充电卡
【发布时间】:2023-03-05 15:17:01
【问题描述】:

我已经使用 javascript 设置了条纹自定义结帐。每个参数都会通过,当我们付款时,我会在日志中收到状态 200。一切看起来都经过了。但是,Parsed Request Query Parameters 中的金额仍然为“0”,并且不向卡收费。

我已经阅读了几个小时的文档,但无法解决这个问题。

<script src="https://checkout.stripe.com/checkout.js"></script>

<script>
  var pinId = "<%= @id %>";
  var from = "<%= @from %>";
  var content = "Supersize+me";
  var handler = StripeCheckout.configure({
    key: 'Published-Key',
    image: '/assets/campusboard-logo.png',
    token: function(token, args) {
        $.getJSON( "purchased/"+pinId )
          .done(function( data ) {
             window.location = "http://"+window.location.host+"/pins/"+pinId+"?utm_source=Purchased&utm_medium="+from+"&utm_campaign=Featured%20Pins&utm_content="+content;
           })
          .fail(function( jqxhr, textStatus, error ) {
            alert("We've encountered a problem with the transaction. Please try again.");
        });
    }
  });

  document.getElementById('ssm').addEventListener('click', function(e) {
    // Open Checkout with further options
    handler.open({
      name: 'CampusBoard',
      description: 'Featured Pin (£29.00)',
      amount: "100",
      currency: 'GBP',
      panelLabel: 'Supersize my Pin'
    });
    e.preventDefault();
  });

  document.getElementById('mmh').addEventListener('click', function(e) {
    // Open Checkout with further options
    handler.open({
      name: 'CampusBoard',
      description: 'Featured Pin (£59.00)',
      amount: 5900,
      currency: 'GBP',
      panelLabel: 'Make my Pin Huge'
    });
    content = "Make+me+huge";
    e.preventDefault();
  });
</script>

有人能看出我哪里出错了吗?

【问题讨论】:

    标签: javascript ruby-on-rails ruby stripe-payments


    【解决方案1】:

    Stripe Checkout 只是一个精心制作的预付款表单。您实际上必须使用您的 Stripe 秘密 API 密钥在您的服务器上创建一个 Charge 对象。按照您的特定语言关注these tutorials

    【讨论】:

      【解决方案2】:

      您将金额作为字符串传递,而我认为 stripe 期望它作为数字。所以:

      handler.open({
        ...
        amount: 100,
        ...
      });
      

      【讨论】:

      • 虽然我现在注意到你已经把它混合在两个电话之间了。他们都失败了吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 2021-12-20
      • 2014-04-28
      • 2021-10-20
      • 1970-01-01
      • 2015-11-10
      • 2020-08-16
      相关资源
      最近更新 更多