2017-10-21 96 views
2

我試圖使用Stripe v3付款。指南在這裏https://stripe.com/docs/elements不要收集帶條形碼的郵政編碼

我不想收集郵政編碼。但我無法弄清楚如何。我的HTML是:

<form> 
    <label> 
    <div id="card-element" class="field is-empty"></div> 
    <span><span>Credit or debit card</span></span> 
    </label> 
    <button type="submit">Pay</button> 
    <div class="outcome"> 
    <div class="error" role="alert"></div> 
    <div class="success"> 
     Success! Your Stripe token is <span class="token"></span> 
    </div> 
    </div> 
</form> 

和Javascript是:

var card = elements.create('card', { 
    style: { 
    hidePostalCode: true, 
    base: { 
     iconColor: '#666EE8', 
     color: '#31325F', 
     lineHeight: '40px', 
     fontWeight: 300, 
     fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 
     fontSize: '15px', 

     '::placeholder': { 
     color: '#CFD7E0', 
     }, 
    }, 
    } 
}); 

card.mount('#card-element'); 

但它始終要求提供郵政編碼:

enter image description here

有指導元素的標籤在這裏https://stripe.com/docs/stripe.js#element-types 。但我看不到我可以在哪裏收集卡號,CVC和卡到期,但不是郵政編碼...

+0

你的代碼是好的。 – Zico

回答

1

謝天謝地,這應該是一個非常簡單的修復! hidePostalCode: true應該是options中的頂級屬性,而不是嵌套在style這裏。

https://stripe.com/docs/stripe.js#element-options

var card = elements.create('card', { 
hidePostalCode: true, 
style: { 
base: { 
    iconColor: '#666EE8', 
    color: '#31325F', 
    lineHeight: '40px', 
    fontWeight: 300, 
    fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 
    fontSize: '15px', 

    '::placeholder': { 
    color: '#CFD7E0', 
    }, 
    }, 
} 
}); 

card.mount('#card-element');