在angularjs前端显示电荷

时间:2017-11-25 03:08:36

标签: javascript angularjs stripe-payments

我想在我的mean-stack网站上添加一个付款页面。我正在关注https://stripe.com/docs/checkout/express

主要区别在于我想使用angularjs。所以我创建了一个pay.html

<form action="/httpOnly/charge" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_AonyNpyBLlSWdLN7ZsUagG0h" 
    data-amount="999"
    data-name="Stripe.com"
    data-description="Widget"
    data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
    data-locale="auto"
    data-zip-code="true">
  </script>
</form>

路由器:

router.post("/httpOnly/charge", (req, res) => {
    var stripe = require("stripe")("sk_test_CZnHvVa3ntbFSDSd57h5VB4A");

    let amount = 500;

    stripe.customers.create({
        email: req.body.stripeEmail,
        source: req.body.stripeToken
    })
    .then(customer =>
        stripe.charges.create({
            amount: amount,
            description: "Sample Charge",
            currency: "usd",
            customer: customer.id
    }))
    .then(charge => {
        console.log("charge: " + JSON.stringify(charge))
        ???
    })
})

由于我不想使用pug,我不知道如何发送结果并将其显示在前端。

有人可以帮忙吗?

0 个答案:

没有答案