我在使用平衡的javascript通过balanced.js发送信用卡信息时遇到问题。即使我没有尝试过jQuery.post它,响应似乎是400响应。我正在使用rails 4和coffeescript。我在这里使用jsFiddle:http://jsfiddle.net/balanced/ZwhrA/。
jQuery ->
$('#cc-submit').click (e) ->
e.preventDefault()
marketplaceuri = "TEST-MP5o4Bt04Oo1XBYKVLVV3xWt"
balanced.init(marketplaceuri)
responseTarget = "localhost:3000/events/7/tablecharges/new"
payload = {
name: $('#cc-name').val()
card_number: $('#cc-number').val()
expiration_month: $('#cc-expiration-month').val()
expiration_year: $('#cc-expiration-year').val()
security_code: $('#cc-ccv').val()
}
card = balanced.card.create(payload, (response) ->
if (response.status == 201 && response.uri)
alert('respone.id')
else
alert(JSON.stringify(response, false, 4)))