我一直在尝试寻找一种解决方案,以在我的angular2应用程序中包括UI中的braintrees drop,但是我找不到合适的解决方案。我查看了这个angular2 / braintree解决方案,但它在顶部表示不再维护该视图,并将访问者引向braintree网站。我初始化信用卡表格没有问题,但是当我将payment_nonce发送到服务器时,该值为空。
有没有人有任何建议或参考一个示例,以介绍如何在angular2应用程序中包含ui中的脑树下降?谢谢!
如评论中所述,这是一个丑陋的解决方案。但是我能够使用onPaymentMethodReceived获取令牌,然后将该值添加到隐藏的输入中并将表单发送到服务器。我的表单有特殊要求,因此我必须使用ngNoForm属性。
...
<input id="nonce" type="text" hidden [(ngModel)]="nonce" name="nonce">
...
</form>
ngOnInit() {
var url = window.location.href;
var id = this.getEmployeeUserId(url);
this.employeeId = id;
this.ghttp.getEmployeeByuserId(id)
.then((data)=>{
this.day30Price = data._addAmount;
this.day60Price = data._add2month;
this.day90Price = data._add3month;
});
this.splashhttp.getToken()
.then((res)=>{
var id = res._body;
braintree.setup(id, 'dropin', {
container: 'dropin-container',
onPaymentMethodReceived: function (obj) {
document.getElementById("nonce").value = obj.nonce;
var myForm = document.getElementById("myForm");
myForm.submit();
}
});
});
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句