Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 条带连接错误_Node.js_Angular_Stripe Payments - Fatal编程技术网

Node.js 条带连接错误

Node.js 条带连接错误,node.js,angular,stripe-payments,Node.js,Angular,Stripe Payments,我有下面的backend Node.js代码来连接到我的Stripe帐户进行收费。但我得到了这个错误。我使用的是Firebase函数,这个函数以前也可以使用,所以我怀疑这与Firebase访问限制有关。在此方面的任何想法和帮助都将不胜感激 var functions = require('firebase-functions'); var stripe = require('stripe')('sk_test'); var express = require('express'); var bo

我有下面的backend Node.js代码来连接到我的Stripe帐户进行收费。但我得到了这个错误。我使用的是Firebase函数,这个函数以前也可以使用,所以我怀疑这与Firebase访问限制有关。在此方面的任何想法和帮助都将不胜感激

var functions = require('firebase-functions');
var stripe = require('stripe')('sk_test');
var express = require('express');
var bodyParser = require('body-parser');
var cors = require('cors');

exports.stripePay = functions.https.onRequest((request, response) => {
  if (request.method === 'POST') {
    var app = express();
    var router = express.Router();

    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(cors());

    var stripetoken = request.body.cardToken;
    var amountpayable = request.body.amount;

    var charge = stripe.charges.create({
      amount: amountpayable,
      currency: 'usd',
      source: stripetoken,
      description: 'Sample transaction'
    }, function (err, charge) {
      console.log("ST4");
      if (err) {
        response.send("Failed!");
      }
      else {
        response.send({ success: true });
      }
    })
  }

{ Error: An error occurred with our connection to Stripe
    at Error._Error (/user_code/node_modules/stripe/lib/Error.js:12:17)
    at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)
    at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)
    at ClientRequest.<anonymous> (/user_code/node_modules/stripe/lib/StripeResource.js:192:9)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:310:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at connectErrorNT (net.js:1020:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)   type: 'StripeConnectionError', stack: 'Error: An error occurred with our connection to Stripe\n    at Error._Error (/user_code/node_modules/stripe/lib/Error.js:12:17)\n    at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)\n    at Error.Constructor (/user_code/node_modules/stripe/lib/utils.js:98:13)\n    at ClientRequest.<anonymous> (/user_code/node_modules/stripe/lib/StripeResource.js:192:9)\n    at emitOne (events.js:96:13)\n    at ClientRequest.emit (events.js:188:7)\n    at TLSSocket.socketErrorListener (_http_client.js:310:9)\n    at emitOne (events.js:96:13)\n    at TLSSocket.emit (events.js:188:7)\n    at connectErrorNT (net.js:1020:8)\n    at _combinedTickCallback (internal/process/next_tick.js:74:11)\n    at process._tickDomainCallback (internal/process/next_tick.js:122:9)',   rawType: undefined,   code: undefined,   param: undefined,   message: 'An error occurred with our connection to Stripe',   detail:     { Error: getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
       at errnoException (dns.js:28:10)
       at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
     code: 'ENOTFOUND',
     errno: 'ENOTFOUND',
     syscall: 'getaddrinfo',
     hostname: 'api.stripe.com',
     host: 'api.stripe.com',
     port: '443' },   raw:     { message: 'An error occurred with our connection to Stripe',
     detail: 
      { Error: getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
          at errnoException (dns.js:28:10)
          at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
        code: 'ENOTFOUND',
        errno: 'ENOTFOUND',
        syscall: 'getaddrinfo',
        hostname: 'api.stripe.com',
        host: 'api.stripe.com',
        port: '443' } },   requestId: undefined,   statusCode: undefined } Reply
var functions=require('firebase-functions');
var stripe=require('stripe')('sk_test');
var express=需要(“express”);
var bodyParser=require('body-parser');
var cors=要求(“cors”);
exports.stripePay=functions.https.onRequest((请求,响应)=>{
if(request.method==='POST'){
var-app=express();
var router=express.router();
use(bodyParser.urlencoded({extended:false}));
应用程序使用(cors());
var stripetoken=request.body.cardToken;
var AmountPayment=request.body.amount;
var charge=stripe.charges.create({
金额:应付金额,
货币:美元,
资料来源:stripetoken,
描述:“示例事务”
},功能(错误,收费){
控制台日志(“ST4”);
如果(错误){
响应。发送(“失败!”);
}
否则{
response.send({success:true});
}
})
}
{错误:与Stripe的连接出错
错误。\错误(/user\u code/node\u modules/stripe/lib/Error.js:12:17)
构造函数(/user\u code/node\u modules/stripe/lib/utils.js:98:13)
构造函数(/user\u code/node\u modules/stripe/lib/utils.js:98:13)
在ClientRequest上。(/user\u code/node\u modules/stripe/lib/StripeResource.js:192:9)
在emitOne(events.js:96:13)
在ClientRequest.emit(events.js:188:7)
在TLSSocket.socketErrorListener(_http_client.js:310:9)
在emitOne(events.js:96:13)
在TLSSocket.emit(events.js:188:7)
在connectErrorNT(net.js:1020:8)
at _combinedTickCallback(内部/流程/下一步_tick.js:74:11)
在进程中。\ u tickDomainCallback(internal/process/next\u tick.js:122:9)键入:“StripeConnectionError”,stack:'Error:连接到条带时出错。\ u Error(/user\u code/node\u modules/Stripe/lib/Error.js:12:17)\n at Error.Constructor(/user\u code/node\u modules/Stripe/lib/utils.js:98:13)\n at Error.Constructor(/user\u code/node\u modules/stripe/lib/utils.js:98:13)\n在ClientRequest。(/user\u code/node\u modules/stripe/lib/StripeResource.js:192:9)\n在emitOne(events.js:96:13)\n在ClientRequest.emit(events.js:188:7)\n在TlssocketErrorListener(\u http\u client.js:310:9)\n在TlsocketOne(events.js:96:13)\n在Tlsocket.emit(events.js:188:7)\n在connectErrorNT(net.js:1020:8)\n在\u combinedTickCallback(internal/process/next\u tick.js:74:11)\n在process.\u tickDomainCallback(internal/process/next\u tick.js:122:9)',rawType:undefined,code:undefined,param:undefined,消息:“连接到条带时发生错误”,详细信息:{错误:getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
在errnoException(dns.js:28:10)
在GetAddrInfoReqWrap.onlookup[as oncomplete](dns.js:76:26)
代码:“ENOTFOUND”,
errno:'ENOTFOUND',
系统调用:“getaddrinfo”,
主机名:“api.stripe.com”,
主机:“api.stripe.com”,
端口:'443'},原始:{消息:'连接到条带'时出错,
详情:
{错误:getaddrinfo ENOTFOUND api.stripe.com api.stripe.com:443
在errnoException(dns.js:28:10)
在GetAddrInfoReqWrap.onlookup[as oncomplete](dns.js:76:26)
代码:“ENOTFOUND”,
errno:'ENOTFOUND',
系统调用:“getaddrinfo”,
主机名:“api.stripe.com”,
主机:“api.stripe.com”,
端口:'443'}},请求ID:未定义,状态代码:未定义}回复

这是一个很好的方法!Firebase阻止免费帐户的外部API连接,只要获得任何付费帐户,这就可以了!

Dimitris的回答是正确的,用更通俗的话说,只需进入blaze plan,您就可以从Firebase函数调用stripe API。

您确定吗?我有两个项目,都在同一个目录下但是,如果您授权stripe connect即使在免费版本中也能工作,则它对其中一个项目有效,而对另一个项目无效。如果您想与未经授权的用户打交道,则只能使用付费版本。@Dimitri您如何授权?您的意思是允许stripe作为firebase帐户中的外部api吗?您的答案很好第一,非常有用。作为授权用户登录对我来说不起作用,我必须升级。但现在必须为开发环境付费并不理想。