Skip to content

Commit

Permalink
2.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
braintreeps committed Oct 24, 2019
1 parent 87d6f38 commit da1c934
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @braintree/sdk
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

- [ ] Added changelog entry
- [ ] Ran unit tests (`npm test`)

<!-- **For Braintree Developers only, don't forget:**
- [ ] Does this change require work to be done to the GraphQL API? If you have questions check with the GraphQL team.
- [ ] Add & Run integration tests -->
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.21.0
* Add `AmountNotSupportedByProcessor` validation error to Transaction
* Add `ProcessorDoesNotSupportMotoForCardType` to validation errors
* Fix issue where `SettlementBatchSummary` did not include some custom fields

## 2.20.0
* Add Venmo `TokenIssuance` gateway rejection reason

Expand Down
18 changes: 18 additions & 0 deletions lib/braintree/settlement_batch_summary_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,29 @@ class SettlementBatchSummaryGateway extends Gateway {
}

underscoreCustomField(criteria, response) {
// The response from the gateway API uses snake_case keys and
// the Node SDK automatically transforms the keys to camelCase.
// This works for everything except for merchant defined custom
// fields as param values. Since these come back in the settlment
// batch summary response as keys in the object, the Node SDK
// accidentally changes them to camelCase. This function determines
// if the custom field passed in by the merchant is snake_case and
// if so, transforms the camelCased version back to the version the
// merchant originally passed in (snake_case).
if (response.success && 'groupByCustomField' in criteria) {
// if the custom field has no _, then no need to do transformation
if (criteria.groupByCustomField.indexOf('_') === -1) {
return response;
}

let camelCustomField = Util.toCamelCase(criteria.groupByCustomField);

// loop through the records to add the merchant provided
// snake_case param to the response and remove the camelCase
// version that was accidentally applied in the response parsing
for (let record of response.settlementBatchSummary.records) {
record[criteria.groupByCustomField] = record[camelCustomField];
// NEXT_MAJOR_VERSION - this should use delete instead of setting to null
record[camelCustomField] = null;
}
}
Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/validation_error_codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ class ValidationErrorCodes {
AmountIsRequired: '81502',
AmountIsTooLarge: '81528',
AmountMustBeGreaterThanZero: '81531',
AmountNotSupportedByProcessor: '815193',
BillingAddressConflict: '91530',
CannotBeVoided: '91504',
CannotCancelRelease: '91562',
Expand Down Expand Up @@ -552,6 +553,7 @@ class ValidationErrorCodes {
ProcessorAuthorizationCodeIsInvalid: '81520',
ProcessorDoesNotSupportAuths: '915104',
ProcessorDoesNotSupportCredits: '91546',
ProcessorDoesNotSupportMotoForCardType: '915195',
ProcessorDoesNotSupportPartialSettlement: '915102',
ProcessorDoesNotSupportUpdatingOrderId: '915107',
ProcessorDoesNotSupportUpdatingDescriptor: '915108',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braintree",
"version": "2.20.0",
"version": "2.21.0",
"description": "A library for integrating with Braintree.",
"keywords": [
"braintree",
Expand Down
20 changes: 20 additions & 0 deletions spec/integration/braintree/transaction_gateway_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,26 @@ describe('TransactionGateway', function () {
});
});

it('handles error AmountNotSupportedByProcessor', function (done) {
let transactionParams = {
merchantAccountId: 'hiper_brl',
amount: '0.20',
creditCard: {
number: CreditCardNumbers.CardTypeIndicators.Hiper,
expirationDate: '10/20',
cvv: '737'
}
};

specHelper.defaultGateway.transaction.sale(transactionParams, function (err, response) {
assert.isNull(err);
assert.isFalse(response.success);
assert.equal(response.errors.for('transaction').on('amount')[0].code, ValidationErrorCodes.Transaction.AmountNotSupportedByProcessor);

done();
});
});

it('charges a card using an access token', function (done) {
let oauthGateway = new braintree.BraintreeGateway({
clientId: 'client_id$development$integration_client_id',
Expand Down

0 comments on commit da1c934

Please sign in to comment.