聚合物 POST http://localhost:3000/ 404(未找到)

Polymer POST http://localhost:3000/ 404 (Not Found)

我正在尝试为 Stripe using node.js. So I have followed Firebase method 创建一个费用,看看我是否可以让它工作:

为清楚起见,我省略了聚合物元素的导入。假设一切都很好。

/charge.html:

<dom-module id="stripe-charge">
  <template>
    <script>
      var firebaseStripe = new Firebase('https://blahblah.firebaseio-demo.com/');

        firebaseStripe.set({
          var stripe = require("stripe")("sk_test_blahblah");
          var stripeToken = request.body.stripeToken;

          var charge = stripe.charges.create({
            amount: 1000, // amount in cents, again
            currency: "gbp",
            source: stripeToken,
            description: "Example charge"
          }, function(err, charge) {
            if (err && err.type === 'StripeCardError') {
              // The card has been declined
            }
        });
    </script>
  </template>
  <script>
    Polymer({
      is: 'stripe-charge',
    });
  </script>
</dom-module>

索引:

<section data-route="charge">
 <stripe-charge></stripe-charge>
</section>

routing.html:

page('/charge', function () {
  app.route = 'charge';
});

page({
  hashbang: true
});

形式:

<form is="iron-form" id="myForm" action="http://localhost:3000/#!/charge" method="post">
   <input type="hidden" is="iron-input" id="amount" name="amount" bind-value="{{total}}">
   <input type="hidden" id="stripeToken" name="stripeToken"/>
   <input type="hidden" is="iron-input" id="stripeEmail" name="stripeEmail" bind-value="{{emailInput}}"/>
</form>
<paper-button class="fullBtn" id="customButton" on-click="stripe">
  <iron-icon icon="icons:credit-card"></iron-icon>
  Pay
</paper-button>

当我按下支付按钮,填写银行卡详细信息等,然后点击 Strip 支付按钮时,我得到了绿色,但是当它进入收费页面时,我得到 POST http://localhost:3000/ 404 (Not Found) 不知何故它不会这一页。有任何想法吗?我觉得会有更多的错误,但现在,我想得到那个页面。 Firebase 问题?

将您的 url 更改为真实路径,而不是哈希位置:

<form is="iron-form" id="myForm" action="http://localhost:3000/charge" method="post">

您需要 运行 一个接受 post 的服务器,然后使用您的私钥调用 Stripe,您不能 运行 Stripe 作为纯客户端进程.

浏览器中的第一步调用 stripe 并打包提供的信用卡信息,但随后您需要将该令牌提供给您的服务器。否则任何人都可以代表您提交费用,包括退款!