Skip to content

Commit

Permalink
2.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Feb 20, 2020
1 parent da1c934 commit 7819d7a
Show file tree
Hide file tree
Showing 17 changed files with 206 additions and 84 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
## 2.22.0
* Add `RefundAuthHardDeclined` and `RefundAuthSoftDeclined` to validation errors
* Add GraphQL ID to `CreditCardVerification`, `Customer`, `Dispute`, and `Transaction`
* Add level 2 processing options `purchaseOrderNumber`, `taxAmount`, and `taxExempt` on transaction submitForSettlement
* Add level 3 processing options `discountAmount`, `shippingAmount`, `shipsFromPostalCode`, and `lineItems` on transaction submitForSettlement

## 2.21.0
* Add `AmountNotSupportedByProcessor` validation error to Transaction
* Add `ProcessorDoesNotSupportMotoForCardType` to validation errors
Expand Down
5 changes: 5 additions & 0 deletions lib/braintree/attribute_setter.js
Expand Up @@ -6,9 +6,14 @@ class AttributeSetter {
if (!attributes.hasOwnProperty(key)) {
continue;
}

let value = attributes[key];

this[key] = value;

if (key === 'globalId') {
this.graphQLId = attributes.globalId;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/braintree/config.js
Expand Up @@ -17,7 +17,7 @@ class Config {
} else if (rawConfig.accessToken) {
parser.parseAccessToken(rawConfig.accessToken);
if (rawConfig.environment && parser.environment !== rawConfig.environment) {
// TODO: change this console.error to an exception in the next major version
// 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
}
this.accessToken = parser.accessToken;
Expand Down
26 changes: 25 additions & 1 deletion lib/braintree/transaction_gateway.js
Expand Up @@ -146,7 +146,31 @@ class TransactionGateway extends Gateway {

_submitForSettlementSignature() {
return {
valid: ['orderId', 'descriptor[name]', 'descriptor[phone]', 'descriptor[url]']
valid: [
'descriptor[name]',
'descriptor[phone]',
'descriptor[url]',
'orderId',
'purchaseOrderNumber',
'taxAmount',
'taxExempt',
'discountAmount',
'shippingAmount',
'shipsFromPostalCode',
'lineItems[quantity]',
'lineItems[name]',
'lineItems[description]',
'lineItems[kind]',
'lineItems[unitAmount]',
'lineItems[unitTaxAmount]',
'lineItems[totalAmount]',
'lineItems[discountAmount]',
'lineItems[unitOfMeasure]',
'lineItems[productCode]',
'lineItems[commodityCode]',
'lineItems[url]',
'lineItems[taxAmount]'
]
};
}

Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/validation_error_codes.js
Expand Up @@ -562,6 +562,8 @@ class ValidationErrorCodes {
PurchaseOrderNumberIsInvalid: '91548',
PurchaseOrderNumberIsTooLong: '91537',
RefundAmountIsTooLarge: '91521',
RefundAuthHardDeclined: '915200',
RefundAuthSoftDeclined: '915201',
ServiceFeeAmountCannotBeNegative: '91554',
ServiceFeeAmountFormatIsInvalid: '91555',
ServiceFeeAmountIsTooLarge: '91556',
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "braintree",
"version": "2.21.0",
"version": "2.22.0",
"description": "A library for integrating with Braintree.",
"keywords": [
"braintree",
Expand Down
9 changes: 5 additions & 4 deletions spec/integration/braintree/credit_card_gateway_spec.js
Expand Up @@ -674,7 +674,7 @@ describe('CreditCardGateway', function () {
let customerParams = {
creditCard: {
number: '5105105105105100',
expirationDate: '01/2015'
expirationDate: `01/${new Date().getFullYear() - 3}`
}
};

Expand All @@ -692,18 +692,19 @@ describe('CreditCardGateway', function () {

describe('expiringBetween', () =>
it('returns card expiring between the given dates', function (done) {
const year = new Date().getFullYear() - 3;
let customerParams = {
creditCard: {
number: '5105105105105100',
expirationDate: '05/2016'
expirationDate: `05/${year}`
}
};

specHelper.defaultGateway.customer.create(customerParams, function (err, response) {
let testCard = response.customer.creditCards[0];

let before = new Date('2016-04-31');
let after = new Date('2016-10-01');
let before = new Date(`${year}-04-31`);
let after = new Date(`${year}-10-01`);

specHelper.defaultGateway.creditCard.expiringBetween(before, after, function (err, result) {
assert.isNull(err);
Expand Down
Expand Up @@ -22,6 +22,7 @@ describe('CreditCardVerificationGateway', function () {
specHelper.defaultGateway.creditCardVerification.find(response.verification.id, function (err, verification) {
assert.isNull(err);
assert.equal(verification.creditCard.cardholderName, 'John Smith');
assert.isDefined(verification.graphQLId);

done();
})
Expand Down
1 change: 1 addition & 0 deletions spec/integration/braintree/customer_gateway_spec.js
Expand Up @@ -784,6 +784,7 @@ describe('CustomerGateway', function () {
assert.isNull(err);
assert.equal(customer.firstName, 'John');
assert.equal(customer.lastName, 'Smith');
assert.isDefined(customer.graphQLId);
let billingAddress = customer.creditCards[0].billingAddress;

assert.equal(billingAddress.streetAddress, '123 E Fake St');
Expand Down
1 change: 1 addition & 0 deletions spec/integration/braintree/dispute_gateway_spec.js
Expand Up @@ -496,6 +496,7 @@ describe('DisputeGateway', () => {
assert.equal('open_dispute', dispute.id);
assert.equal(Dispute.Status.Open, dispute.status);
assert.equal('open_disputed_transaction', dispute.transaction.id);
assert.isDefined(dispute.graphQLId);
});
});

Expand Down
4 changes: 2 additions & 2 deletions spec/integration/braintree/dispute_search_spec.js
Expand Up @@ -35,7 +35,7 @@ describe('DisputeSearch', () => {
]);
}, function (err, response) {
assert.isNull(err);
assert.equal(2, response.length);
assert(response.length >= 2);

done();
});
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('DisputeSearch', () => {
stream.on('data', dispute => disputes.push(dispute));

stream.on('end', () => {
assert.equal(2, disputes.length);
assert(disputes.length >= 2);

done();
});
Expand Down
21 changes: 2 additions & 19 deletions spec/integration/braintree/payment_method_gateway_spec.js
Expand Up @@ -110,6 +110,7 @@ describe('PaymentMethodGateway', function () {
assert.isString(response.paymentMethod.expirationYear);
assert.isTrue(response.paymentMethod.default);
assert.include(response.paymentMethod.imageUrl, 'android_pay');
assert.isFalse(response.paymentMethod.isNetworkTokenized);
assert.equal(response.paymentMethod.sourceCardType, specHelper.braintree.CreditCard.CardType.Discover);
assert.equal(response.paymentMethod.sourceCardLast4, '1111');
assert.equal(response.paymentMethod.sourceDescription, 'Discover 1111');
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('PaymentMethodGateway', function () {
assert.isString(response.paymentMethod.expirationYear);
assert.isTrue(response.paymentMethod.default);
assert.include(response.paymentMethod.imageUrl, 'android_pay');
assert.isTrue(response.paymentMethod.isNetworkTokenized);
assert.equal(response.paymentMethod.sourceCardType, specHelper.braintree.CreditCard.CardType.MasterCard);
assert.equal(response.paymentMethod.sourceCardLast4, '4444');
assert.equal(response.paymentMethod.sourceDescription, 'MasterCard 4444');
Expand Down Expand Up @@ -1029,25 +1031,6 @@ describe('PaymentMethodGateway', function () {
})
);

it('creates a paypal account from a paypal refresh token without upgrade', done =>
specHelper.defaultGateway.customer.create({}, function (err, response) {
customerId = response.customer.id;
let paypalAccountParams = {
customerId,
paypalRefreshToken: 'PAYPAL_REFRESH_TOKEN',
paypalVaultWithoutUpgrade: true
};

specHelper.defaultGateway.paymentMethod.create(paypalAccountParams, function (err, response) {
assert.isNull(err);
assert.isTrue(response.success);
assert.isString(response.paymentMethod.customerId);
assert.isNull(response.paymentMethod.billingAgreementId);
done();
});
})
);

it('can create a payment method and set the token and default', done =>
specHelper.defaultGateway.customer.create({}, function (err, response) {
customerId = response.customer.id;
Expand Down
@@ -1,6 +1,5 @@
'use strict';

let braintree = specHelper.braintree;
let ValidationErrorCodes = require('../../../lib/braintree/validation_error_codes').ValidationErrorCodes;
let UsBankAccountVerification = require('../../../lib/braintree/us_bank_account_verification').UsBankAccountVerification;
let MerchantAccountTest = require('../../../lib/braintree/test/merchant_account').MerchantAccountTest;
Expand Down Expand Up @@ -66,21 +65,14 @@ describe('PaymentMethodGateway', function () {
});

describe('compliant merchant', function () {
let config = {
environment: braintree.Environment.Development,
merchantId: 'integration2_merchant_id',
publicKey: 'integration2_public_key',
privateKey: 'integration2_private_key'
};

let gateway = new braintree.BraintreeGateway(config);
let gateway = specHelper.merchant2Gateway;

describe('create', function () {
it('vaults an unverified bank account', function (done) {
gateway.customer.create({}, function (err, response) {
let customerId = response.customer.id;

specHelper.generateValidUsBankAccountNonce('567891234', function (nonce) {
specHelper.generateValidUsBankAccountNonce('567891234', gateway, function (nonce) {
let paymentMethodParams = {
customerId,
paymentMethodNonce: nonce,
Expand Down Expand Up @@ -110,19 +102,12 @@ describe('PaymentMethodGateway', function () {
});

it('vaults an verified bank account', function (done) {
let config = {
environment: braintree.Environment.Development,
merchantId: 'integration2_merchant_id',
publicKey: 'integration2_public_key',
privateKey: 'integration2_private_key'
};

let gateway = new braintree.BraintreeGateway(config);
let gateway = specHelper.merchant2Gateway;

gateway.customer.create({}, function (err, response) {
let customerId = response.customer.id;

specHelper.generateValidUsBankAccountNonce('567891234', function (nonce) {
specHelper.generateValidUsBankAccountNonce('567891234', gateway, function (nonce) {
let paymentMethodParams = {
customerId,
paymentMethodNonce: nonce,
Expand Down Expand Up @@ -155,19 +140,12 @@ describe('PaymentMethodGateway', function () {
});

it('rejects an invalid verification method', function (done) {
let config = {
environment: braintree.Environment.Development,
merchantId: 'integration2_merchant_id',
publicKey: 'integration2_public_key',
privateKey: 'integration2_private_key'
};

let gateway = new braintree.BraintreeGateway(config);
let gateway = specHelper.merchant2Gateway;

gateway.customer.create({}, function (err, response) {
let customerId = response.customer.id;

specHelper.generateValidUsBankAccountNonce('567891234', function (nonce) {
specHelper.generateValidUsBankAccountNonce('567891234', gateway, function (nonce) {
let paymentMethodParams = {
customerId,
paymentMethodNonce: nonce,
Expand Down

0 comments on commit 7819d7a

Please sign in to comment.