解析云代码问题中的条带模块

Stripe Module in Parse Cloud Code Woes

本文关键字:模块 问题 代码      更新时间:2023-09-26

我正在试验解析云代码条纹模块,我一直得到一个400坏请求错误与以下消息:

code: 141, message: "TypeError: Object [Object Object]没有方法'i…Create (stripe.js:157:16) (at main.js:11:31)

只要我不引用Stripe,云代码就运行。这个令牌应该是好的,因为我刚刚创建了它,尽管即使它不是,我也会期望得到一个完全不同的错误消息。在我绞尽脑汁几个小时后,我失去了其他的想法,我真的,真的很感激任何帮助:

var Stripe = require('stripe');
Stripe.initialize('sk_test_oBhEeXgs9x...'); //dots added for confidentiality
Parse.Cloud.define("pay", function(request, response) {
    Stripe.Charges.create({
        amount: 100 * 10, // $10 expressed in cents
        currency: "usd",
        card: "tok_3TnIVhEv9..." // dots added for confidentiality
    },{
        success: function(httpResponse) {
            response.success("Purchase made!");
        },
        error: function(httpResponse) {
            response.error("Uh oh, something went wrong");
        }
    });
});

和我的客户端代码是:

<script>
Parse.initialize("CGqOtFjaHZIs6vG57hAWc...", "j4hDZ7N0s4jwfQIl0t...");
Parse.Cloud.run('pay', {}, {
    success: function (result) {
        console.log(result);
    },
    error: function (error) {
        console.log(error);
    }
});
</script>

我也有同样的问题。我在终端的项目目录中使用:parse jssdk 1.5.0恢复到1.5.0。