Polymer POST http:// localhost:3000/404(未找到)

时间:2015-08-12 07:49:10

标签: firebase polymer stripe-payments polymer-1.0

我正在尝试使用node.js为Stripe创建费用。所以我跟着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问题?

1 个答案:

答案 0 :(得分:0)

将您的网址更改为真正的路径,而不是哈希位置:

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

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

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