Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var helpers = require('./helpers.js');
var braintree = require('braintree');
var gateway;
// if running on Heroku
if (process.env.BRAINTREE_MERCHANTID) {
gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: process.env.BRAINTREE_MERCHANTID,
publicKey: process.env.BRAINTREE_PUBLICKEY,
privateKey: process.env.BRAINTREE_PRIVATEKEY,
});
} else { // running locally
var config = require('./config.js');
gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: config.braintree.merchantId,
publicKey: config.braintree.publicKey,
privateKey: config.braintree.privateKey,
});
}
// Get info of single artist
app.get('/artists/id/:id', function(req, res) {
var artistId = req.params.id;
db.artist.findOne({where: {id: artistId}, include: [db.show]})
.then(function(artist) {
if (artist === null) {
res.status(404).end('ArtistID ' + artistId + ' not found.');
}
var express = require('express');
var router = express.Router();
var braintree = require('braintree');
var gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: "ffdqc9fyffn7yn2j",
publicKey: "qj65nndbnn6qyjkp",
privateKey: "a3de3bb7dddf68ed3c33f4eb6d9579ca"
});
/* GET Creates a new token and returns it in the response */
router.get('/token', function (req, res) {
gateway.clientToken.generate({}, function (error, response) {
if (!error) {
res.send(response.clientToken);
} else {
res.send(response);
}
});
});
import braintree from 'braintree';
import config from 'config';
import jwt from 'jsonwebtoken';
import * as constants from '../../constants/transactions';
import * as libpayments from '../../lib/payments';
import models from '../../models';
import errors from '../../lib/errors';
const gateway = braintree.connect({
environment: config.paypalbt.environment,
clientId: config.paypalbt.clientId,
clientSecret: config.paypalbt.clientSecret,
});
/** Return the URL needed by the PayPal Braintree client */
async function oauthRedirectUrl(remoteUser, CollectiveId) {
const hostCollective = await models.Collective.findById(CollectiveId);
const state = jwt.sign({
CollectiveId,
CreatedByUserId: remoteUser.id
}, config.keys.opencollective.secret, {
// People may need some time to set up their Paypal Account if
// they don't have one already
expiresIn: '45m'
});
async function getMerchantGateway(collective) {
// Merchant ID of the host account
const hostCollectiveId = await collective.getHostCollectiveId();
if (!hostCollectiveId) throw new errors.BadRequest('Can\'t retrieve host collective id');
const connectedAccount = await models.ConnectedAccount.findOne({
where: { service: 'paypalbt', CollectiveId: hostCollectiveId } });
if (!connectedAccount) throw new errors.BadRequest('Host does not have a paypal account');
const { token } = connectedAccount;
return braintree.connect({
accessToken: token,
environment: config.paypalbt.environment,
});
}
trialEnded() {
TestProvider.called = 'trialEnded';
}
@BraintreeSubscriptionWentPastDue()
wentPastDue() {
TestProvider.called = 'wentPastDue';
}
@BraintreeSubscriptionWentActive()
wentActive() {
TestProvider.called = 'wentActive';
}
}
const gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
});
beforeEach(async () => {
module = await Test.createTestingModule({
imports: [
BraintreeModule.forRoot({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
}),
BraintreeWebhookModule,
function getGateway(isNewPayment) {
const accountOptions = getAccountOptions(isNewPayment);
if (accountOptions.environment === "production") {
accountOptions.environment = Braintree.Environment.Production;
} else {
accountOptions.environment = Braintree.Environment.Sandbox;
}
const gateway = Braintree.connect(accountOptions);
return gateway;
}
var Q = require('q'),
_ = require('underscore'),
ConfigService = require('../services/config-service'),
FirebaseService = require('../services/firebase-service'),
ObjectService = require('../services/object-service'),
PaymentService = require('../services/payment-service'),
braintree = require('braintree'),
gateway = braintree.connect({
environment: braintree.Environment[ConfigService.get('private.braintree.environment') || 'Sandbox'],
merchantId: ConfigService.get('private.braintree.merchantId'),
publicKey: ConfigService.get('private.braintree.publicKey'),
privateKey: ConfigService.get('private.braintree.privateKey')
});
module.exports = {
getClientToken: function (req, res) {
PaymentService.clientToken(req.user.id, function (err, response) {
if (err) {
res.status(500).send(err);
} else {
res.status(200).send(response.clientToken);
}
});
const makeGateway = ({ config }) => {
return braintree.connect({
environment: braintree.Environment[config.settings.braintree.environment],
merchantId: config.settings.braintree.merchantId,
publicKey: config.settings.braintree.publicKey,
privateKey:config.settings.braintree.privateKey
})
}
var braintree = require('braintree');
var gateway = braintree.connect({
accessToken: 'access_token$sandbox$3w2ttvwd246548hd$829117ab3d240f371c0b2069492b8453'
});
module.exports = {
clientToken: () => {
var response = new Promise((resolve, reject) => {
gateway.clientToken.generate({}, (err, res) => {
if (err || res.success === false) {
reject(err);
}
resolve(res);
});
});