2017-04-03 76 views
0

我称为HTTPS端点对谷歌的云功能,以http触发器,但我得到了调用HTTPS请求连接到服务器

{ 
    "type": "connection_error", 
    "message": "Error occured while connecting to First API", 
    "error": { 
     "code": "ENOTFOUND", 
     "errno": "ENOTFOUND", 
     "syscall": "getaddrinfo", 
     "hostname": "api-cert.payeezy.com", 
     "host": "api-cert.payeezy.com", 
     "port": 443 
    } 
} 

完全相同的代码工作在亚马逊的λ,不任何人都知道如果谷歌云功能需要特别调整HTTPS服务器?我尝试使用Cors,但仍然给出相同的错误。

我的代码是使用payeezy API

var nonce = Math.random() * 1000000000000000000; 
 
    var timeInMillis = new Date().getTime(); 
 
    var requestJSON=JSON.stringify({ 
 
      method: 'credit_card', 
 
      amount: '1299', 
 
      currency_code: 'USD', 
 
      credit_card: { 
 
       card_number: '4788250000028291', 
 
       cvv: '123', 
 
       type: 'visa', 
 
       exp_date: '1230', 
 
       cardholder_name: 'Tom Eck' 
 
      }, 
 
      billing_address: { 
 
       street: '225 Liberty Street', 
 
       city: 'NYC', 
 
       state_province: 'NY', 
 
       zip_postal_code: '10281', 
 
       country: 'US' 
 
      } 
 
     }); 
 
    var headers = { 
 
     'Content-Type': 'application/json', 
 
     'Accept': 'application/json', 
 
     'apikey': apikey, 
 
     'token': merchant_token, 
 
     'nonce': nonce, 
 
     'timestamp':timeInMillis, 
 
     'Authorization': getAuthorizationHeader(apikey, apisecret, requestJSON, merchant_token, nonce, timeInMillis) 
 
    }; 
 
    
 
    var options = { 
 
     host: "api-cert.payeezy.com", 
 
     path: '/v1/transactions', 
 
     method: "POST", 
 
     headers: headers 
 
    }; 
 
    var req1 = http.request(options); 
 
    req1.on('response', responseHandler(callback)); 
 
    req1.on('error', errorHandler(callback)); 
 
    req1.write(requestJSON); 
 
    req1.end();

+0

从错误中明确指出'api-cert.payeezy.com'不存在。 –

+1

您无法在Spark计划上进行外部API请求。 –

回答

0

感谢詹姆斯·丹尼尔的评论非常普通的HTTP调用,我发现谷歌的功能只能通过星火计划调用谷歌自己的服务。 定价页面中有一个出站联网行 https://firebase.google.com/pricing/