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
via Dimitri
No comments:
Post a Comment