【发布时间】:2016-07-18 13:06:02
【问题描述】:
我正在使用 braintree Drop-in UI 与 angularjs(frontend) 和 rails(Backend)。我正在创建一个 clientToken 并将其发送到 Braintree 设置。
客户端令牌方法,
@client_token = Braintree::ClientToken.generate(customer_id: current_user.braintree_customer_id,options: {
verify_card: true,
fail_on_duplicate_payment_method: true
})
如您所见,我选择了“fail_on_duplicate_payment_method”选项。并尝试再次添加相同的付款方式。
然后,通过该验证,我在 dropin 上收到错误消息 “处理您的请求时出错”,但它不会出现在错误回调中。
这是设置,很好,
braintree.setup(vm.clientToken, 'dropin', {
container: 'dropin-container',
onPaymentMethodReceived: function(data)
{
alert('came recieved')
// console.log($scope.paymentForm)
vm.submit($scope.paymentForm, data.nonce)
},
onReady: function () {
vm.disablePay = false;
},
onError: function(type, message) {
alert('came error')
vm.serverError = message;
}
});
这是错误的图像,
网络中的错误是,
callback_jsona7f3c885267b4f49aa13fbf01cecdb60({"error":{"message":"Credit card is invalid"},<br>"fieldErrors":[{"field":"creditCard","fieldErrors":[{"field":"number","code":"81724","message":"Duplicate card exists in the vault"}]}],"status":422})
我想将此错误提取到我的视图中。我搜索了很多链接,但没有得到我需要的答案。任何帮助都是可观的。
提前谢谢你。
【问题讨论】: