Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripe Connection Error

I have the follow backend Node.js code to connect to my Stripe account to make a Charge. But I'm getting this error. I'm using Firebase Functions, and this functionality used to work before, so I doubt this is anything to do with Firebase access restrictions. Any ideas and help on this will be greatly appreciated!

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
like image 668
Dimitri Avatar asked May 17 '17 12:05

Dimitri


People also ask

What does Stripe error mean?

The customer must use another card or method of payment. processing_error. An error occurred while processing the card. The payment needs to be attempted again. If it still can't be processed, try again later.

Is Stripe down right now?

All services are online.

What is Stripe API error?

Stripe uses conventional HTTP response codes to indicate the success or failure of an API request. In general: Codes in the 2xx range indicate success. Codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted, a charge failed, etc.).

What does errors code Card_decline_rate_limit_exceeded mean?

card_decline_rate_limit_exceeded. This card has been declined too many times. You can try to charge this card again after 24 hours. We suggest reaching out to your customer to make sure they have entered all of their information correctly and that there are no issues with their card.


2 Answers

this is a good one! Firebase blocks external API connections for Free accounts, just get any paid account and this will work!

like image 131
Dimitri Avatar answered Nov 06 '22 09:11

Dimitri


Dimitris answer is correct, in more layman's terms simply get on the blaze plan and you can make calls to stripe api from Firebase Functions.

like image 26
Jason Avatar answered Nov 06 '22 07:11

Jason