角度付款返回带有测试数据的无效卡

时间:2015-03-21 19:51:34

标签: javascript angularjs node.js stripe-payments

我尝试使用此处的角度付款应用程序在角度js中构建条纹

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

我设置了我的可发布密钥并且没有任何问题包括Stripe.js,我知道呼叫已经完成,因为我在责任手中接收错误

任何可能导致这种情况的想法?

这是代码:

形式

<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>

这是控制器功能:

// 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标题包含...

<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,这是处理条纹的另一个回购 - 任何想法我做错了什么?

1 个答案:

答案 0 :(得分:0)

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

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
});