gpt4 book ai didi

javascript - Angular 支付返回带有测试数据的无效卡

转载 作者:太空宇宙 更新时间:2023-11-04 02:27:56 27 4
gpt4 key购买 nike

我正在尝试使用此处找到的 Angular-Payments 应用程序在 Angular JS 中配置 Stripe

https://github.com/laurihy/angular-payments

问题是,即使有测试数据,它似乎也会返回 invalid_card 错误。

这是错误:

POST https://api.stripe.com/v1/tokens 402 (Payment Required)
Stripe.isDoubleLoaded.c(index):3 Stripe.isDoubleLoaded.e(index):3 Stripe.isDoubleLoaded.a(index):3 Stripe.isDoubleLoaded.Stripe.xhr(index):2 Stripe.a._rawRequest(index):2 Stripe.a.request(index):2 Stripe.token.a.create(index):2 Stripe.card.b.createToken(index):2 Stripe.a._channelListener(index):2 Stripe.isDoubleLoaded.H.Socket.t.concat.incoming(index):2

我正在设置可发布 key 并毫无问题地包含 Stripe.js,并且我知道调用已完成,因为我在 ResponsHandler 中发现了错误

有什么想法可能导致这种情况吗?

这是代码:

表格

<form name="myform" id="signup-form" stripe-handler="saveCustomer">
<div class="form-group">
<label for="card_number">Card Number</label>
<input type="text" class="form-control" size="20" ng-model="number" payments-validate="card" payments-format="card" payments-type-model="type" ng-class="myform.number.$card.type"/>
</div>

<div class="form-row">
<label for="CVC"> CVC</label>

<input type="text" class="form-control" size="4" ng-model="cvc" payments-validate="cvc" payments-format="cvc" payments-type-model="type"/>
</div>

<div class="form-row">
<label for="expiry"> Expiry</label>
<input type="text" class="form-control" size="2" ng-model="expiry" payments-validate="expiry" payments-format="expiry" />

</div>

<div class="text-center">
<span class="glyphicon glyphicon-heart"></span>
<h3>Thanks For Your Money!</h3>

<button type="submit" class="btn">Submit</button>
</div>

这是 Controller 函数:

// function to process the form
$scope.saveCustomer = function(status, response) {

if (response.error) {
// Show the errors on the form
console.log(response);
console.log(response.error);
} else {
// response contains id and card, which contains additional card details
var token = response.id;
console.log(token);
formData.token = token;
}
}

我的index.html header 包括...

<script type="text/javascript" src="https://js.stripe.com/v2/"></script>

<script type="text/javascript">
// This identifies your website in the createToken call below
Stripe.setPublishableKey('my-key-here');
// ...
</script>

奇怪的是,它正在与 stripe-angluar 一起使用,这是另一个用于处理 Stripe 的存储库 - 你知道我做错了什么吗?

最佳答案

您可能错误地创建了 token 。我也遇到了同样的问题。对我有用的是像这样设置卡片:

Stripe.card.createToken({
"number": '4242424242424242',
"exp_month": 12,
"exp_year": 2016,
"cvc": '123'
}, function(status, response) {
stripeResponseHandler(status, response);
});

而不是这个(注意卡片对象是如何创建两次的 - 因此我相信“Stripe.isDoubleLoaded”错误):

Stripe.card.createToken({
card: {
"number": '4242424242424242',
"exp_month": 12,
"exp_year": 2016,
"cvc": '123'
}
}, function(status, response) {
stripeResponseHandler
});

关于javascript - Angular 支付返回带有测试数据的无效卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29187307/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com