【发布时间】:2014-09-19 01:36:56
【问题描述】:
我正在使用 Braintree 作为支付网关,但遇到了一个问题。
我正在发送带有其他用户详细信息的信用卡信息。
出于安全目的,信用卡信息必须加密,并且由 Braintree 通过以下方式完成:
braintree.onSubmitEncryptForm('braintree-payment-form');
这工作正常,直到我在前端使用纯 JavaScript (AngularJS) 并且我看到数据在发送到服务器时没有加密,
下面是代码:
<form name="paymentForm" ng-submit="submitUser(userDetails)" method="post" id="braintree-payment-form">
<p>
<label style="color:white">Name</label>
<input type="text" ng-model="userDetails.userName" name="userName" size="20" />
</p>
<p>
<label style="color:white">Email</label>
<input type="text" ng-model="userDetails.email" name="email" size="20"/>
</p>
<p>
<label style="color:white">Company</label>
<input type="text" ng-model="userDetails.company" name="company" size="20" />
</p>
<label style="color:white">Card Number</label>
<input type="text" size="20" ng-model="userDetails.number" autocomplete="off" data-encrypted-name="number" />
</p>
<p>
<label style="color:white">CVV</label>
<input type="text" size="4" ng-model="userDetails.cvv" autocomplete="off" data-encrypted-name="cvv" />
</p>
<p>
<label style="color:white">Expiration (MM/YYYY)</label>
<input type="text" size="2" ng-model="userDetails.month" data-encrypted-name="month" /> / <input type="text" size="4" ng-model="userDetails.year" data-encrypted-name="year" />
</p>
<input type="submit" id="submit" />
在提交表单时,我正在向服务器发送数据。
$scope.submitUser = function(userDetails){
$http({
url: '/createtransaction',
method: 'POST',
data: JSON.stringify(userDetails),
headers: {'Content-Type': 'application/json'}
}).success(function (data, status, headers, config) {
// success
}).error(function (data, status, headers, config) {
//error
});
}
我可以加密卡的详细信息吗?
【问题讨论】:
-
正如 Dan 所说,HTTPS 是这里的关键。为什么 JS 密码学不是很安全在这里解释得很好:matasano.com/articles/javascript-cryptography
标签: javascript angularjs payment-gateway credit-card braintree