braintree / braintree_node

Braintree Node.js library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
334 stars 104 forks source link

Deprecated your connect method but docs still reference it #175

Closed nstuyvesant closed 3 years ago

nstuyvesant commented 3 years ago

General information

Issue description

On https://developers.braintreepayments.com/start/hello-server/node, the example given is:

var braintree = require("braintree");

var gateway = braintree.connect({
  environment: braintree.Environment.Sandbox,
  merchantId: "useYourMerchantId",
  publicKey: "useYourPublicKey",
  privateKey: "useYourPrivateKey"
});

But in 3.0.0, you deprecated the connect() method according to the CHANGELOG. The CHANGELOG also doesn't state the method that replaced it.

Can you improve your documentation? Deprecating a method like this without any advance warning creates some risk.

hollabaq86 commented 3 years ago

👋 hey @nstuyvesant, thanks for reaching out. We're aware the code snippets in our docs use the now removed connect method. Our docs will be updated soon calling out these changes, but in the meantime I'll leave this issue open so folks are aware.

elrumordelaluz commented 3 years ago

Same issue here, dropped a request to the support team. Is there a place where explain how to connect the new way? Thanks!

nstuyvesant commented 3 years ago

Here's an example I was able to get working by looking at one of Braintree's tests...

import braintree from 'braintree';
import config from '../../config/environment';

// Gets a token from Braintree
export async function index(req, res) {
  const gateway = new braintree.BraintreeGateway(config.gateway); // synchronous call

  // Generate the client token
  const { clientToken } = await gateway.clientToken.generate({});
  res.status(200).send(clientToken);
  return clientToken;
}
crookedneighbor commented 3 years ago

The readme also has an example. https://github.com/braintree/braintree_node#quick-start

If everything goes as normal, the main docs site should be updated today with the new method of instantiating a Braintree gateway object.

crookedneighbor commented 3 years ago

The docs are now updated: https://developers.braintreepayments.com/start/hello-server/node#install-and-configure

Here's a migration guide for going from v2 to v3: https://developers.braintreepayments.com/reference/general/server-sdk-migration-guide/node