Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Does it instance with options using registry', async () => {
const module = await Test.createTestingModule({
imports: [
BraintreeModule.forRoot({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
}),
],
}).compile();
const options = module.get(BRAINTREE_OPTIONS_PROVIDER);
const provider = module.get(BraintreeProvider);
expect(options.environment).toBe(braintree.Environment.Sandbox);
expect(options.merchantId).toBe('merchantId');
expect(options.publicKey).toBe('publicKey');
expect(options.privateKey).toBe('privateKey');
expect(provider).toBeInstanceOf(BraintreeProvider);
});
it('BraintreeModule.forFeature', async () => {
@Module({
imports: [BraintreeModule.forFeature()],
})
class TestModule {}
const module: TestingModule = await Test.createTestingModule({
imports: [
BraintreeModule.forRoot({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
}),
TestModule,
],
}).compile();
const testProvider = module.select(TestModule).get(BraintreeProvider);
expect(testProvider).toBeInstanceOf(BraintreeProvider);
});
});
const module: TestingModule = await Test.createTestingModule({
imports: [
ConfigModule.load(
path.resolve(__dirname, '__stubs__', 'config', '*.ts'),
),
BraintreeModule.forRootAsync({
useFactory: async config => config.get('braintree'),
inject: [ConfigService],
}),
BraintreeWebhookModule,
],
providers: [SubscriptionProvider],
}).compile();
const gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
});
const braintreeProvider = module.get(BraintreeProvider);
const webhookProvider = module.get(
BraintreeWebhookProvider,
);
const webhookNotification = await braintreeProvider.parseWebhook(
gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionCanceled,
),
);
'use strict';
require('./dotenv');
const braintree = require('braintree');
const gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: process.env.BRAINTREE_MERCHANT_ID,
publicKey: process.env.BRAINTREE_PUBLIC_KEY,
privateKey: process.env.BRAINTREE_PRIVATE_KEY
});
module.exports = gateway;
'use strict';
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json());
var braintree = require('braintree');
require('dotenv').load();
try {
var gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: process.env.BT_MERCHANT_ID,
publicKey: process.env.BT_PUBLIC_KEY,
privateKey: process.env.BT_PRIVATE_KEY
});
} catch(error) {
throw new Error('Copy example.env to .env and add your Braintree credentials');
}
app.get('/get_token', function (req, res) {
gateway.clientToken.generate({}, function (err, response) {
if (err) {
console.log('Error generating client token: ', err);
return res.status(500).send(err);
}
console.log('Client Token generated and sent: ', response);
return res.send(response);
const express = require('express');
const donate = express.Router();
const config = require('../config');
const async = require('async');
const moment = require('moment');
const stripe_secret = config.STRIPE_SECRET;
const stripe_public = config.STRIPE_PUBLIC;
const stripe = require('stripe')(stripe_secret);
const braintree = require('braintree');
const gateway = braintree.connect({
environment: config.NODE_ENV !== 'development' ? braintree.Environment.Production
: braintree.Environment.Sandbox,
merchantId: config.BRAIN_TREE_MERCHANT_ID,
publicKey: config.BRAIN_TREE_PUBLIC_KEY,
privateKey: config.BRAIN_TREE_PRIVATE_KEY,
});
const bodyParser = require('body-parser');
module.exports = function (db, redis) {
donate.use(bodyParser.json());
donate.use(bodyParser.urlencoded(
{
extended: true,
}));
donate.route('/carry').get((req, res, next) => {
db.from('players').where('cheese', '>', 0).limit(50).orderBy('cheese', 'desc')
.asCallback((err, results) => {
var braintree = require('braintree');
var gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: "ENTER YOUR ID",
publicKey: "ENTER YOUR KEY",
privateKey: "ENTER YOUR PRIVATE KEY"
});
var controller = {
getClientToken: function (callback) {
gateway.clientToken.generate({}, function (err, response) {
if (err) {
callback(err)
}
if (response.clientToken) {
callback(response.clientToken)
} else {
callback(response)
}
var ConfigService = require('./config-service');
var FirebaseService = require('./firebase-service');
var Utility = require('../extensions/utility');
var Q = require('q');
var braintree = require('braintree');
var 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')
});
var slug = require('slug');
var findCustomer = function (id, cb) {
var deferred = Utility.async(cb);
gateway.customer.find(slug(id), function (err, customer) {
return err ? deferred.reject(err) : deferred.resolve(customer);
});
return deferred.promise;
},
updateCustomer = function (id, customer, cb) {
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;
}
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
})
}