我使用Bluesnap沙盒支付网关,但我无法获得payment_field_token。解决它
var _authdata = $base64.encode('xxxxxxxxxxx' + ':' + 'xxxxxxxx');
$http.defaults.headers.common['Authorization'] = 'Basic' + _authdata;
$http.defaults.headers.common['Content-Type'] = 'application/json';
$http.defaults.headers.common['Accept'] = 'application/json';
$http.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
console.log("Authenticaltion Data : " + _authdata);
var _headers = {
'Authorization': 'Basic ' + _authdata
}
// console.log("Headers : " + _headers);
console.log(JSON.stringify(_headers));
return $http({
method:'POST',
url: 'https://sandbox.bluesnap.com/services/2/payment-fields-tokens',
headers:_headers
}).
success(function(data, status, headers, config) {
console.log("Success Data : " + data);
}).
error(function(data, status, headers, config) {
console.log("Error Data : " + data);
});
我在重新创建示例代码来检查此问题时遇到问题,但我认为问题是您在"基本"之后缺少一个空白: $http.defaults.headers.common['Authorization'] = 'Basic' + _authdata;
此外,如果您正在设置默认标头,则无需在标头中再次发送它...
如果这没有帮助,你能提供一个完整的演示html吗?