Skip to content

Commit

Permalink
2.24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Aug 6, 2020
1 parent 27b80ac commit aa4152e
Show file tree
Hide file tree
Showing 15 changed files with 539 additions and 94 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,25 @@
## 2.24.0
* Add * `GatewayRejectionReason.RiskThreshold` to `Transaction`
* Update @braintree/wrap-promise to v2.1.0
* Add `networkTransactionId` to `CreditCardVerification`
* Add `retrievalReferenceNumber` to `Transaction`
* Add `productSku` to `Transaction`
* Add `phoneNumber` and `shippingMethod` to `Address`
* Add `customerDeviceId`, `customerLocationZip`, and `customerTenure` to `RiskData`
* Add validation errors:
* `Transaction.ProductSkuIsInvalid`
* `Transaction.ShippingMethodIsInvalid`
* `Transaction.ShippingPhoneNumberIsInvalid`
* `Transaction.BillingPhoneNumberIsInvalid`
* `RiskData.CustomerBrowserIsTooLong`
* `RiskData.CustomerDeviceIdIsTooLong`
* `RiskData.CustomerLocationZipInvalidCharacters`
* `RiskData.CustomerLocationZipIsInvalid`
* `RiskData.CustomerLocationZipIsTooLong`
* `RiskData.CustomerTenureIsTooLong`
* Add `processedWithNetworkToken` to `Transaction`
* Add `isNetworkTokenized` to `CreditCard`

## 2.23.0
* Add `threeDSecurePassThru` parameters to `Customer.create`, `PaymentMethod.create`, `CreditCard.create`, `Customer.update`, `PaymentMethod.update` and `CreditCard.update`
* Add `threeDSecureAuthenticationId` support on transaction sale
Expand Down
48 changes: 26 additions & 22 deletions Rakefile
Expand Up @@ -2,38 +2,42 @@ task :default => %w[test:unit test:integration]
task :test => %w[test:unit test:integration]

namespace :test do
desc "Run units"
task :unit => [:npm_install] do
sh "npm test"
end

desc "Run integration"
task :integration => [:npm_install] do
sh "npm run test:integration"
end

# To run a specific it/context: rake test:focused[spec/integration/braintree/credit_card_gateway_spec.js,create]
desc "Run tests in a specific file: rake test:focused[spec/integration/braintree/credit_card_gateway_spec.js]"
task :focused, [:filename, :spec_grep] => [:npm_install] do |t, args|
filename = args[:filename]
spec_grep = args[:spec_grep]

command = local_mocha
if filename.include? "integration"
command += " --slow 2000"
# Usage:
# rake test:unit
# rake test:unit[config_spec]
# rake test:unit[config_spec,"can be configured with merchant credentials"]
desc "Run unit tests"
task :unit, [:file_name, :test_name] => [:npm_install] do |task, args|
if args.file_name.nil?
sh "npm test"
elsif args.test_name.nil?
sh "#{mocha} spec/unit/braintree/#{args.file_name}.js"
else
sh "#{mocha} -g '#{args.test_name}' spec/unit/braintree/#{args.file_name}.js"
end
end

unless spec_grep.nil?
command += " -g #{spec_grep}"
# Usage:
# rake test:integration
# rake test:integration[plan_gateway_spec]
# rake test:integration[plan_gateway_spec,"gets all plans"]
desc "Run integration tests"
task :integration, [:file_name, :test_name] => [:npm_install] do |task, args|
if args.file_name.nil?
sh "npm run test:integration"
elsif args.test_name.nil?
sh "#{mocha} --slow 2000 spec/integration/braintree/#{args.file_name}.js"
else
sh "#{mocha} --slow 2000 -g '#{args.test_name}' spec/integration/braintree/#{args.file_name}.js"
end
sh "#{command} #{filename}"
end
end

task :npm_install do
sh "npm install --force"
end

def local_mocha
def mocha
"./node_modules/mocha/bin/mocha --timeout 62000 --reporter spec -r spec/spec_helper"
end
4 changes: 2 additions & 2 deletions lib/braintree/address_gateway.js
Expand Up @@ -47,8 +47,8 @@ class AddressGateway extends Gateway {
sharedSignature(prefix) {
let signatureKeys = [
'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric',
'countryName', 'extendedAddress', 'firstName',
'lastName', 'locality', 'postalCode', 'region', 'streetAddress'
'countryName', 'extendedAddress', 'firstName', 'lastName', 'locality',
'phoneNumber', 'postalCode', 'region', 'streetAddress'
];

let signature = [];
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/test/credit_card_numbers.js
Expand Up @@ -13,6 +13,7 @@ let CreditCardNumbers = {
IssuingBank: '4111111141010101',
CountryOfIssuance: '4111111111121102',
Fraud: '4000111111111511',
RiskThresholds: '4111130000000003',
Hiper: '6370950000000005',
HiperCard: '6062820524845321'
},
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/test/nonces.js
Expand Up @@ -61,6 +61,7 @@ let Nonces = {
PayPalFuturePaymentRefreshToken: 'fake-paypal-future-refresh-token-nonce',
SEPA: 'fake-sepa-bank-account-nonce',
GatewayRejectedFraud: 'fake-gateway-rejected-fraud-nonce',
GatewayRejectedRiskThresholds: 'fake-gateway-rejected-risk-thresholds-nonce',
VenmoAccount: 'fake-venmo-account-nonce',
VenmoAccountTokenIssuanceError: 'fake-token-issuance-error-venmo-account-nonce',
MasterpassAmEx: 'fake-masterpass-amex-nonce',
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/transaction.js
Expand Up @@ -73,6 +73,7 @@ class Transaction extends AttributeSetter {
AvsAndCvv: 'avs_and_cvv',
Duplicate: 'duplicate',
Fraud: 'fraud',
RiskThreshold: 'risk_threshold',
ThreeDSecure: 'three_d_secure',
TokenIssuance: 'token_issuance'
};
Expand Down
10 changes: 8 additions & 2 deletions lib/braintree/transaction_gateway.js
Expand Up @@ -212,8 +212,10 @@ class TransactionGateway extends Gateway {
'sharedShippingAddressId',
'riskData',
'riskData[customerBrowser]',
'riskData[customerDeviceId]',
'riskData[customerIp]',
'riskData[customerBrowser]',
'riskData[customerLocationZip]',
'riskData[customerTenure]',
'creditCard',
'creditCard[token]',
'creditCard[cardholderName]',
Expand Down Expand Up @@ -280,6 +282,7 @@ class TransactionGateway extends Gateway {
'paypalAccount[payeeEmail]',
'paypalAccount[payerId]',
'paypalAccount[paymentId]',
'productSku',
'industry',
'industry[industryType]',
'industry[data]',
Expand Down Expand Up @@ -368,7 +371,10 @@ class TransactionGateway extends Gateway {
'externalVault[previousNetworkTransactionId]'
];

validKeys = validKeys.concat(new AddressGateway(this).sharedSignature('shipping'), new AddressGateway(this).sharedSignature('billing'));
let validShippingKeys = new AddressGateway(this).sharedSignature('shipping').concat('shipping[shippingMethod]');
let validBillingKeys = new AddressGateway(this).sharedSignature('billing');

validKeys = validKeys.concat(validShippingKeys, validBillingKeys);

return {
valid: validKeys,
Expand Down
13 changes: 13 additions & 0 deletions lib/braintree/validation_error_codes.js
Expand Up @@ -467,6 +467,7 @@ class ValidationErrorCodes {
AmountMustBeGreaterThanZero: '81531',
AmountNotSupportedByProcessor: '815193',
BillingAddressConflict: '91530',
BillingPhoneNumberIsInvalid: '915206',
CannotBeVoided: '91504',
CannotCancelRelease: '91562',
CannotCloneCredit: '91543',
Expand Down Expand Up @@ -560,6 +561,7 @@ class ValidationErrorCodes {
ProcessorDoesNotSupportUpdatingDescriptor: '915108',
ProcessorDoesNotSupportUpdatingTransactionDetails: '915130',
ProcessorDoesNotSupportVoiceAuthorizations: '91545',
ProductSkuIsInvalid: '915202',
PurchaseOrderNumberIsInvalid: '91548',
PurchaseOrderNumberIsTooLong: '91537',
RefundAmountIsTooLarge: '91521',
Expand All @@ -577,6 +579,8 @@ class ValidationErrorCodes {
ShippingAmountFormatIsInvalid: '915162',
ShippingAmountCannotBeNegative: '915163',
ShippingAmountIsTooLarge: '915164',
ShippingMethodIsInvalid: '915203',
ShippingPhoneNumberIsInvalid: '915204',
ShipsFromPostalCodeIsTooLong: '915165',
ShipsFromPostalCodeIsInvalid: '915166',
ShipsFromPostalCodeInvalidCharacters: '915167',
Expand Down Expand Up @@ -767,6 +771,15 @@ class ValidationErrorCodes {
CavvAlgorithmIsInvalid: '942122'
}
};

this.RiskData = {
CustomerBrowserIsTooLong: '94701',
CustomerDeviceIdIsTooLong: '94702',
CustomerLocationZipInvalidCharacters: '94703',
CustomerLocationZipIsInvalid: '94704',
CustomerLocationZipIsTooLong: '94705',
CustomerTenureIsTooLong: '94706'
};
}
}
ValidationErrorCodes.initClass();
Expand Down
51 changes: 34 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "braintree",
"version": "2.23.0",
"version": "2.24.0",
"description": "A library for integrating with Braintree.",
"keywords": [
"braintree",
Expand All @@ -21,7 +21,7 @@
"npm": ">=5"
},
"dependencies": {
"@braintree/wrap-promise": "2.0.0",
"@braintree/wrap-promise": "2.1.0",
"dateformat": "^3.0.3",
"depd": "~1.1.0",
"readable-stream": "1.1.10",
Expand Down
31 changes: 30 additions & 1 deletion spec/integration/braintree/credit_card_gateway_spec.js
Expand Up @@ -812,7 +812,8 @@ describe('CreditCardGateway', function () {
);

describe('find', function () {
let customerToken;
let customerToken, creditCardParams, customerId;
let networkTokenizedCreditCardToken = 'network_tokenized_credit_card';

before(function (done) {
let customerParams = {
Expand All @@ -824,6 +825,7 @@ describe('CreditCardGateway', function () {

specHelper.defaultGateway.customer.create(customerParams, function (err, response) {
customerToken = response.customer.creditCards[0].token;
customerId = response.customer.id;
done();
});
});
Expand Down Expand Up @@ -853,6 +855,33 @@ describe('CreditCardGateway', function () {
done();
})
);

it('finds the network tokenized card', done =>
specHelper.defaultGateway.creditCard.find(networkTokenizedCreditCardToken, function (err, creditCard) {
assert.isNull(err);
assert.isTrue(creditCard.isNetworkTokenized);

done();
})
);

it('finds the non network tokenized card', done => {
creditCardParams = {
customerId,
number: '5105105105105100',
expirationDate: '05/2012'
};
specHelper.defaultGateway.creditCard.create(creditCardParams, function (err, response) {
assert.isNull(err);
assert.isTrue(response.success);

specHelper.defaultGateway.creditCard.find(response.creditCard.token, function (err, creditCard) {
assert.isNull(err);
assert.isFalse(creditCard.isNetworkTokenized);
done();
});
});
});
});

describe('fromNonce', function () {
Expand Down

0 comments on commit aa4152e

Please sign in to comment.