Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Sep 15, 2020
1 parent aa4152e commit 4c525e0
Show file tree
Hide file tree
Showing 90 changed files with 1,764 additions and 2,130 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
@@ -1 +1 @@
v4.7.3
v10
10 changes: 4 additions & 6 deletions ACKNOWLEDGEMENTS.md
Expand Up @@ -3,13 +3,11 @@ Acknowledgements

The Braintree SDK uses code from the following libraries:

* [dateformat](https://github.com/felixge/node-dateformat), MIT License
* [depd](https://github.com/dougwilson/nodejs-depd), MIT License
* [readable-stream](https://github.com/nodejs/readable-stream), MIT License
* [semver](https://github.com/npm/node-semver), ISC License
* [underscore](https://github.com/jashkenas/underscore), MIT License
* [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js), MIT License
* [chai](https://github.com/chaijs/chai), MIT License
* [dateformat](https://github.com/felixge/node-dateformat), MIT License
* [eslint](https://github.com/eslint/eslint), MIT License
* [eslint-config-braintree](https://github.com/braintree/eslint-config), MIT License
* [mocha](https://github.com/mochajs/mocha), MIT License
* [sinon](https://github.com/sinonjs/sinon), BSD License
* [wrap-promise](https://github.com/braintree/wrap-promise), MIT License
* [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js), MIT License
47 changes: 47 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,50 @@
## 3.0.0
* Add `RequestTimeoutError` and `GatewayTimeoutError` exceptions
* Remove several no-longer-used dependencies (underscore, semver and readable-stream)
* Breaking Changes
* Rename `braintree/lib/test` to `braintree/lib/test_values` to avoid accidental removal of directories named `test` (fixes #98 and #174)
* Remove deprecated iDEAL, Coinbase, and Transparent Redirect
* Remove deprecated `connect` method
* Config class now throws an error when token environment does not match passed environment
* Remove `GrantedPaymentInstrumentUpdate` (deprecated in 2.16.0)
* Remove `InvalidTransparentRedirectHashError`
* Remove `SEPA` test nonce
* Remove deprecated `tag` parameter from dispute calls
* Remove deprecated validation error codes:
* `DiscountAmountMustBeGreaterThanZero`
* `UnitTaxAmountMustBeGreaterThanZero`
* `SEPABankAccount`:
* `IBANIsRequired`
* `BICIsRequired`
* `AccountHolderNameIsRequired`
* `SEPAMandate`:
* `AccountHolderNameIsRequired`
* `BICIsRequired`
* `IBANIsRequired`
* `TypeIsRequired`
* `IBANInvalidCharacter`
* `BICInvalidCharacter`
* `BICLengthIsInvalid`
* `BICUnsupportedCountry`
* `IBANUnsupportedCountry`
* `IBANInvalidFormat`
* `BillingAddressConflict`
* `BillingAddressIdIsInvalid`
* `TypeIsInvalid`
* `AmountDoesNotMatchIdealPaymentAmount`
* `IdealPaymentNotComplete`
* `IdealPaymentsCannotBeVaulted`
* `MerchantAccountDoesNotMatchIdealPaymentMerchantAccount`
* `OrderIdDoesNotMatchIdealPaymentOrderId`
* `OrderIdIsRequiredWithIdealPayment`
* Rename `DownForMaintenanceError` to `ServiceUnavailableError`
* Transaction searches throw `UnexpectedError` instead of `DownForMaintenanceError` when search response yields unexpected results
* Remove Masterpass Card support
* Remove Amex Express Checkout Card support
* Rename `braintree/lib/test` to `braintree/lib/test_values` to avoid accidental removal of directories named `test` (fixes #98 and #174)
* Fix bug where `expired` and `expiringBetween` methods on `CreditCardGateway` did not return full credit card results
* Bump API version to support declined refund objects.

## 2.24.0
* Add * `GatewayRejectionReason.RiskThreshold` to `Transaction`
* Update @braintree/wrap-promise to v2.1.0
Expand Down
2 changes: 0 additions & 2 deletions DEVELOPMENT.md
Expand Up @@ -24,5 +24,3 @@ There is a supplied Dockerfile for creating an environment to run this server SD
1. `rake test` needs to pass
1. Add a changelog entry under the `unreleased` header
1. Open a PR
1. Ask a developer on your team for a review, modifying for an approval
1. Ask a Developer Experience developer for a review, modifying for an approval
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -2,7 +2,7 @@ FROM debian:stretch

RUN apt-get update
RUN apt-get -y install curl gpg rake
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash -
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get -y install nodejs

WORKDIR /braintree-node
20 changes: 15 additions & 5 deletions README.md
Expand Up @@ -12,7 +12,17 @@ The Braintree Node library provides integration access to the Braintree Gateway.

### Dependencies

* node >= 4
* node >= 10

## Versions

Braintree employs a deprecation policy for our SDKs. For more information on the statuses of an SDK check our [developer docs](http://developers.braintreepayments.com/reference/general/server-sdk-deprecation-policy).

| Major version number | Status | Released | Deprecated | Unsupported |
| -------------------- | ----------- | --------------- | --------------- | --------------- |
| 3.x.x | Active | September 2020 | TBA | TBA |
| 2.x.x | Inactive | February 2017 | September 2022 | September 2023 |
| 1.x.x | Unsupported | February 2012 | February 2017 | February 2017 |

## Links

Expand All @@ -24,10 +34,6 @@ The Braintree Node library provides integration access to the Braintree Gateway.
```javascript
var braintree = require('braintree');

// previously, gateways were created by calling `braintree.connect`, but as no
// connection takes place in the method call, we've opted to document how
// to instantiate a Braintree Gateway directly. `connect` can still be used,
// but it is deprecated and will be removed in the next major version
var gateway = new braintree.BraintreeGateway({
environment: braintree.Environment.Sandbox,
merchantId: 'your_merchant_id',
Expand Down Expand Up @@ -88,6 +94,10 @@ gateway.transaction.sale({

Almost all methods that uses a callback can alternatively use a Promise. The only exceptions are `gateway.merchantAccount.all` or any of the `search` methods because they return a stream if no callback is provided.

## Documentation

* [Official documentation](https://developers.braintreepayments.com/node/sdk/server/overview)

## Developing (Docker)

The `Makefile` and `Dockerfile` will build an image containing the dependencies and drop you to a terminal where you can run tests.
Expand Down
20 changes: 5 additions & 15 deletions lib/braintree.js
Expand Up @@ -14,10 +14,7 @@ let PayPalAccount = require('./braintree/paypal_account').PayPalAccount;
let AndroidPayCard = require('./braintree/android_pay_card').AndroidPayCard;
let ApplePayCard = require('./braintree/apple_pay_card').ApplePayCard;
let VenmoAccount = require('./braintree/venmo_account').VenmoAccount;
let CoinbaseAccount = require('./braintree/coinbase_account').CoinbaseAccount;
let AmexExpressCheckoutCard = require('./braintree/amex_express_checkout_card').AmexExpressCheckoutCard;
let VisaCheckoutCard = require('./braintree/visa_checkout_card').VisaCheckoutCard;
let MasterpassCard = require('./braintree/masterpass_card').MasterpassCard;
let SamsungPayCard = require('./braintree/samsung_pay_card').SamsungPayCard;

let CreditCardVerification = require('./braintree/credit_card_verification').CreditCardVerification;
Expand All @@ -29,13 +26,12 @@ let TestingGateway = require('./braintree/testing_gateway').TestingGateway;
let UsBankAccountVerification = require('./braintree/us_bank_account_verification').UsBankAccountVerification;
let ValidationErrorCodes = require('./braintree/validation_error_codes').ValidationErrorCodes;

let CreditCardDefaults = require('./braintree/test/credit_card_defaults').CreditCardDefaults;
let CreditCardNumbers = require('./braintree/test/credit_card_numbers').CreditCardNumbers;
let MerchantAccountTest = require('./braintree/test/merchant_account').MerchantAccountTest;
let Nonces = require('./braintree/test/nonces').Nonces;
let TransactionAmounts = require('./braintree/test/transaction_amounts').TransactionAmounts;
let CreditCardDefaults = require('./braintree/test_values/credit_card_defaults').CreditCardDefaults;
let CreditCardNumbers = require('./braintree/test_values/credit_card_numbers').CreditCardNumbers;
let MerchantAccountTest = require('./braintree/test_values/merchant_account').MerchantAccountTest;
let Nonces = require('./braintree/test_values/nonces').Nonces;
let TransactionAmounts = require('./braintree/test_values/transaction_amounts').TransactionAmounts;

let connect = config => new BraintreeGateway(config); // eslint-disable-line func-style
let Test = {
CreditCardDefaults: CreditCardDefaults,
CreditCardNumbers: CreditCardNumbers,
Expand All @@ -47,9 +43,6 @@ let Test = {
module.exports = {
BraintreeGateway: BraintreeGateway,
GraphQL: GraphQL,
// NEXT_MAJOR_VERSION remove the connect method. It is confusing becuase there is no
// actual connection taking place when calling this method
connect: connect,
version: version,
Environment: Environment,
errorTypes: errorTypes,
Expand All @@ -62,10 +55,7 @@ module.exports = {
AndroidPayCard: AndroidPayCard,
ApplePayCard: ApplePayCard,
VenmoAccount: VenmoAccount,
CoinbaseAccount: CoinbaseAccount,
AmexExpressCheckoutCard: AmexExpressCheckoutCard,
VisaCheckoutCard: VisaCheckoutCard,
MasterpassCard: MasterpassCard,
SamsungPayCard: SamsungPayCard,

CreditCardVerification: CreditCardVerification,
Expand Down
3 changes: 1 addition & 2 deletions lib/braintree/advanced_search.js
Expand Up @@ -2,7 +2,6 @@

/* eslint-disable no-invalid-this, no-use-before-define */
let Util = require('./util').Util;
let _ = require('underscore');

function argsToArray(argsObject) {
return Array.prototype.slice.call(argsObject);
Expand Down Expand Up @@ -72,7 +71,7 @@ class AdvancedSearch {
constructor() { this.criteria = {}; }

addCriteria(key, value) { // eslint-disable-line consistent-return
if (this.criteria[key] === Object(this.criteria[key]) && !_.isArray(this.criteria[key])) {
if (this.criteria[key] === Object(this.criteria[key]) && !Array.isArray(this.criteria[key])) {
return Util.merge(this.criteria[key], value);
}

Expand Down
11 changes: 0 additions & 11 deletions lib/braintree/amex_express_checkout_card.js

This file was deleted.

8 changes: 0 additions & 8 deletions lib/braintree/braintree_gateway.js
Expand Up @@ -25,12 +25,8 @@ let SubscriptionGateway = require('./subscription_gateway').SubscriptionGateway;
let TestingGateway = require('./testing_gateway').TestingGateway;
let TransactionGateway = require('./transaction_gateway').TransactionGateway;
let TransactionLineItemGateway = require('./transaction_line_item_gateway').TransactionLineItemGateway;
let TransparentRedirectGateway = require('./transparent_redirect_gateway').TransparentRedirectGateway;
let UsBankAccountGateway = require('./us_bank_account_gateway').UsBankAccountGateway;
let UsBankAccountVerificationGateway = require('./us_bank_account_verification_gateway').UsBankAccountVerificationGateway;
// NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
// DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
let IdealPaymentGateway = require('./ideal_payment_gateway').IdealPaymentGateway;
let WebhookNotificationGateway = require('./webhook_notification_gateway').WebhookNotificationGateway;
let WebhookTestingGateway = require('./webhook_testing_gateway').WebhookTestingGateway;

Expand Down Expand Up @@ -65,12 +61,8 @@ class BraintreeGateway {
this.testing = new TestingGateway(this);
this.transaction = new TransactionGateway(this);
this.transactionLineItem = new TransactionLineItemGateway(this);
this.transparentRedirect = new TransparentRedirectGateway(this);
this.usBankAccount = new UsBankAccountGateway(this);
this.usBankAccountVerification = new UsBankAccountVerificationGateway(this);
// NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
// DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
this.idealPayment = new IdealPaymentGateway(this);
this.webhookNotification = new WebhookNotificationGateway(this);
this.webhookTesting = new WebhookTestingGateway(this);
}
Expand Down
11 changes: 0 additions & 11 deletions lib/braintree/coinbase_account.js

This file was deleted.

34 changes: 0 additions & 34 deletions lib/braintree/coinbase_account_gateway.js

This file was deleted.

5 changes: 2 additions & 3 deletions lib/braintree/config.js
Expand Up @@ -5,7 +5,7 @@ let CredentialsParser = require('./credentials_parser').CredentialsParser;
class Config {
constructor(rawConfig) {
this.timeout = 60000;
this.apiVersion = '5';
this.apiVersion = '6';
this.graphQLApiVersion = '2018-09-10';
let parser = new CredentialsParser();

Expand All @@ -17,8 +17,7 @@ class Config {
} else if (rawConfig.accessToken) {
parser.parseAccessToken(rawConfig.accessToken);
if (rawConfig.environment && parser.environment !== rawConfig.environment) {
// NEXT_MAJOR_VERSION: change this console.error to an exception in the next major version
console.error('Warning: AccessToken environment does not match environment passed in config'); // eslint-disable-line no-console
throw new Error('AccessToken environment does not match environment passed in config');
}
this.accessToken = parser.accessToken;
this.environment = parser.environment;
Expand Down
55 changes: 27 additions & 28 deletions lib/braintree/credit_card_gateway.js
@@ -1,9 +1,9 @@
'use strict';

let Gateway = require('./gateway').Gateway;
let CreditCard = require('./credit_card').CreditCard;
let exceptions = require('./exceptions');
let wrapPrototype = require('@braintree/wrap-promise').wrapPrototype;
const {Gateway} = require('./gateway');
const {CreditCard} = require('./credit_card');
const exceptions = require('./exceptions');
const {CreditCardSearch} = require('./credit_card_search');
const {wrapPrototype} = require('@braintree/wrap-promise');

class CreditCardGateway extends Gateway {
constructor(gateway) {
Expand Down Expand Up @@ -54,30 +54,21 @@ class CreditCardGateway extends Gateway {
return this.createResponseHandler('creditCard', CreditCard);
}

expired() {
return new Promise((resolve, reject) => {
this.gateway.http.post(`${this.config.baseMerchantPath()}/payment_methods/all/expired_ids`, {}, this.searchResponseHandler(this, (err, response) => {
if (err) {
reject(err);
} else {
resolve(response);
}
}));
});
expired(callback) {
const searchUrl = `${this.config.baseMerchantPath()}/payment_methods/all/expired_ids`;
const search = new CreditCardSearch();
const pagingFunction = this.pagingFunctionGenerator(search, 'payment_methods/all/expired');

return this.createSearchResponse(searchUrl, search, pagingFunction, callback);
}

expiringBetween(after, before) {
let url = `${this.config.baseMerchantPath()}/payment_methods/all/expiring_ids?start=${this.dateFormat(after)}&end=${this.dateFormat(before)}`;

return new Promise((resolve, reject) => {
this.gateway.http.post(url, {}, this.searchResponseHandler(this, (err, response) => {
if (err) {
reject(err);
} else {
resolve(response);
}
}));
});
expiringBetween(startDate, endDate, callback) {
const query = `start=${this.dateFormat(startDate)}&end=${this.dateFormat(endDate)}`;
const searchUrl = `${this.config.baseMerchantPath()}/payment_methods/all/expiring_ids?${query}`;
const search = new CreditCardSearch();
const pagingFunction = this.pagingFunctionGenerator(search, `payment_methods/all/expiring?${query}`);

return this.createSearchResponse(searchUrl, search, pagingFunction, callback);
}

dateFormat(date) {
Expand All @@ -91,6 +82,14 @@ class CreditCardGateway extends Gateway {

return month + date.getFullYear();
}

pagingFunctionGenerator(search, url) {
return super.pagingFunctionGenerator(search, url, CreditCard, 'paymentMethods', response => response.paymentMethods.creditCard);
}
}

module.exports = {CreditCardGateway: wrapPrototype(CreditCardGateway)};
module.exports = {
CreditCardGateway: wrapPrototype(CreditCardGateway, {
ignoreMethods: ['expired', 'expiringBetween']
})
};
12 changes: 12 additions & 0 deletions lib/braintree/credit_card_search.js
@@ -0,0 +1,12 @@
'use strict';

const {AdvancedSearch} = require('./advanced_search');

class CreditCardSearch extends AdvancedSearch {
static initClass() {
this.multipleValueField('ids');
}
}
CreditCardSearch.initClass();

module.exports = {CreditCardSearch};

0 comments on commit 4c525e0

Please sign in to comment.