How to use the braintree.Environment function in braintree

To help you get started, we’ve selected a few braintree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nestjsx / nestjs-braintree / src / __tests__ / braintree.module.spec.ts View on Github external
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);
  });
github nestjsx / nestjs-braintree / src / __tests__ / braintree.module.spec.ts View on Github external
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);
  });
});
github nestjsx / nestjs-braintree / src / __tests__ / braintree.webhook.provider.spec.ts View on Github external
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,
      ),
    );
github enhancv / mongoose-subscriptions / test / gateway.js View on Github external
'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;
github ferndopolis / react-native-braintree-card / Server / server.js View on Github external
'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);
github odota / core / routes / donate.js View on Github external
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) => {
github rick4470 / braintree-billing / controllers / paypal.js View on Github external
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)
			}
github deltaepsilon / quiver-cms / lib / services / payment-service.js View on Github external
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) {
github reactioncommerce / reaction / imports / plugins / included / payments-braintree / server / methods / braintreeApi.js View on Github external
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;
}
github fluidtrends / carmel / chunks / payments / functions / token.js View on Github external
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
  })
}

braintree

A library for server-side integrating with Braintree.

MIT
Latest version published 2 months ago

Package Health Score

73 / 100
Full package analysis