Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

1.3.0

  • Loading branch information...
commit 909c7a3dbd54182d6b34924afc79a077e13c00dc 1 parent 83844db
Braintree Open Source braintreeps authored
5 CHANGELOG.md
View
@@ -1,3 +1,8 @@
+## 1.3.0
+
+* Additional card information, such as prepaid, debit, commercial, Durbin regulated, healthcare, and payroll, are returned on credit card responses
+* Allows transactions to be specified as recurring
+
## 1.2.0
* Add prepaid field to credit card (possible values include Yes, No, Unknown)
2  lib/braintree.coffee
View
@@ -7,6 +7,6 @@ connect = (config) ->
new BraintreeGateway(new Config(config))
exports.connect = connect
-exports.version = '1.1.2'
+exports.version = '1.3.0'
exports.Environment = Environment
exports.errorTypes = errorTypes
25 lib/braintree/credit_card.coffee
View
@@ -29,6 +29,31 @@ class CreditCard extends AttributeSetter
No : "No"
Unknown : "Unknown"
+ @Commercial =
+ Yes : "Yes"
+ No : "No"
+ Unknown : "Unknown"
+
+ @Payroll =
+ Yes : "Yes"
+ No : "No"
+ Unknown : "Unknown"
+
+ @Healthcare =
+ Yes : "Yes"
+ No : "No"
+ Unknown : "Unknown"
+
+ @DurbinRegulated =
+ Yes : "Yes"
+ No : "No"
+ Unknown : "Unknown"
+
+ @Debit =
+ Yes : "Yes"
+ No : "No"
+ Unknown : "Unknown"
+
constructor: (attributes) ->
super attributes
@maskedNumber = "#{@bin}******#{@last4}"
13 lib/braintree/test/credit_card_numbers.coffee
View
@@ -0,0 +1,13 @@
+CreditCardNumbers =
+ CardTypeIndicators : {
+ Prepaid : "4111111111111210"
+ Commercial : "4111111111131010"
+ Payroll : "4111111114101010"
+ Healthcare : "4111111510101010"
+ DurbinRegulated : "4111161010101010"
+ Debit : "4117101010101010"
+ Unknown : "4111111111112101"
+ No : "4111111111310101"
+ }
+
+exports.CreditCardNumbers = CreditCardNumbers
2  package.json
View
@@ -1,6 +1,6 @@
{
"name" : "braintree",
- "version" : "1.2.0",
+ "version" : "1.3.0",
"description" : "A library for integrating with Braintree.",
"keywords" : ["payments"],
"homepage" : "http://github.com/braintree/braintree_node",
115 spec/integration/braintree/credit_card_gateway_spec.coffee
View
@@ -3,6 +3,7 @@ _ = require('underscore')._
braintree = specHelper.braintree
util = require('util')
{CreditCard} = require('../../../lib/braintree/credit_card')
+{CreditCardNumbers} = require('../../../lib/braintree/test/credit_card_numbers')
vows
.describe('CreditCardGateway')
@@ -28,7 +29,7 @@ vows
'has credit card attributes': (err, response) ->
assert.equal(response.creditCard.maskedNumber, '510510******5100')
assert.equal(response.creditCard.expirationDate, '05/2012')
- assert.isTrue(/^\w{32}$/.test(response.creditCard.uniqueNumberIdentifier))
+ assert.isTrue(response.creditCard.uniqueNumberIdentifier.length == 32)
'with billing address':
topic: ->
@@ -205,7 +206,7 @@ vows
'returns a not found error': (err, address) ->
assert.equal(err.type, braintree.errorTypes.notFoundError)
- 'prepaid':
+ 'card type indicator are set':
'with a prepaid card':
topic: () ->
callback = @callback
@@ -215,7 +216,7 @@ vows
, (err, response) ->
specHelper.defaultGateway.creditCard.create(
customerId: response.customer.id,
- number: '4500600000000061',
+ number: CreditCardNumbers.CardTypeIndicators.Prepaid,
expirationDate: '05/2012',
options: {
verifyCard: true
@@ -224,8 +225,99 @@ vows
undefined
'sets the prepaid field to Yes': (err, response) ->
assert.equal(response.creditCard.prepaid, CreditCard.Prepaid.Yes)
+ 'with a commercial card':
+ topic: () ->
+ callback = @callback
+ specHelper.defaultGateway.customer.create(
+ firstName: 'John',
+ lastName: 'Smith'
+ , (err, response) ->
+ specHelper.defaultGateway.creditCard.create(
+ customerId: response.customer.id,
+ number: CreditCardNumbers.CardTypeIndicators.Commercial,
+ expirationDate: '05/2012',
+ options: {
+ verifyCard: true
+ }
+ , callback))
+ undefined
+ 'sets the commercial field to Yes': (err, response) ->
+ assert.equal(response.creditCard.commercial, CreditCard.Commercial.Yes)
+ 'with a payroll card':
+ topic: () ->
+ callback = @callback
+ specHelper.defaultGateway.customer.create(
+ firstName: 'John',
+ lastName: 'Smith'
+ , (err, response) ->
+ specHelper.defaultGateway.creditCard.create(
+ customerId: response.customer.id,
+ number: CreditCardNumbers.CardTypeIndicators.Payroll,
+ expirationDate: '05/2012',
+ options: {
+ verifyCard: true
+ }
+ , callback))
+ undefined
+ 'sets the payroll field to Yes': (err, response) ->
+ assert.equal(response.creditCard.payroll, CreditCard.Payroll.Yes)
+ 'with a heathcare card':
+ topic: () ->
+ callback = @callback
+ specHelper.defaultGateway.customer.create(
+ firstName: 'John',
+ lastName: 'Smith'
+ , (err, response) ->
+ specHelper.defaultGateway.creditCard.create(
+ customerId: response.customer.id,
+ number: CreditCardNumbers.CardTypeIndicators.Healthcare,
+ expirationDate: '05/2012',
+ options: {
+ verifyCard: true
+ }
+ , callback))
+ undefined
+ 'sets the healthcare field to Yes': (err, response) ->
+ assert.equal(response.creditCard.healthcare, CreditCard.Healthcare.Yes)
+ 'with a durbin regulated card':
+ topic: () ->
+ callback = @callback
+ specHelper.defaultGateway.customer.create(
+ firstName: 'John',
+ lastName: 'Smith'
+ , (err, response) ->
+ specHelper.defaultGateway.creditCard.create(
+ customerId: response.customer.id,
+ number: CreditCardNumbers.CardTypeIndicators.DurbinRegulated,
+ expirationDate: '05/2012',
+ options: {
+ verifyCard: true
+ }
+ , callback))
+ undefined
+ 'sets the durbin regulated field to Yes': (err, response) ->
+ assert.equal(response.creditCard.durbinRegulated, CreditCard.DurbinRegulated.Yes)
+ 'with a debit card':
+ topic: () ->
+ callback = @callback
+ specHelper.defaultGateway.customer.create(
+ firstName: 'John',
+ lastName: 'Smith'
+ , (err, response) ->
+ specHelper.defaultGateway.creditCard.create(
+ customerId: response.customer.id,
+ number: CreditCardNumbers.CardTypeIndicators.Debit,
+ expirationDate: '05/2012',
+ options: {
+ verifyCard: true
+ }
+ , callback))
+ undefined
+ 'sets the debit field to Yes': (err, response) ->
+ assert.equal(response.creditCard.debit, CreditCard.Debit.Yes)
- 'with a non-prepaid card':
+ 'negative card type indicators':
+ 'with a negative card type indicator card':
topic: () ->
callback = @callback
specHelper.defaultGateway.customer.create(
@@ -234,7 +326,7 @@ vows
, (err, response) ->
specHelper.defaultGateway.creditCard.create(
customerId: response.customer.id,
- number: '4111111111111111',
+ number: CreditCardNumbers.CardTypeIndicators.No,
expirationDate: '05/2012',
options: {
verifyCard: true
@@ -243,7 +335,18 @@ vows
undefined
'sets the prepaid field to No': (err, response) ->
assert.equal(response.creditCard.prepaid, CreditCard.Prepaid.No)
+ 'sets the payroll field to No': (err, response) ->
+ assert.equal(response.creditCard.payroll, CreditCard.Payroll.No)
+ 'sets the debit field to No': (err, response) ->
+ assert.equal(response.creditCard.debit, CreditCard.Debit.No)
+ 'sets the commercial field to No': (err, response) ->
+ assert.equal(response.creditCard.commercial, CreditCard.Commercial.No)
+ 'sets the durbin regulated field to No': (err, response) ->
+ assert.equal(response.creditCard.durbinRegulated, CreditCard.DurbinRegulated.No)
+ 'sets the heathcare field to No': (err, response) ->
+ assert.equal(response.creditCard.healthcare, CreditCard.Healthcare.No)
+ 'unknown card type indicators':
'with an un-identified card':
topic: () ->
callback = @callback
@@ -253,7 +356,7 @@ vows
, (err, response) ->
specHelper.defaultGateway.creditCard.create(
customerId: response.customer.id,
- number: '5555555555554444',
+ number: CreditCardNumbers.CardTypeIndicators.Unknown,
expirationDate: '05/2012',
options: {
verifyCard: true
17 spec/integration/braintree/transaction_gateway_spec.coffee
View
@@ -213,6 +213,23 @@ vows
'has custom fields in response': (err, response) ->
assert.equal(response.transaction.customFields.storeMe, 'custom value')
+ 'when setting recurring':
+ topic: ->
+ specHelper.defaultGateway.transaction.sale(
+ amount: '5.00'
+ creditCard:
+ number: '5105105105105100'
+ expirationDate: '05/12'
+ recurring: true
+ , @callback)
+ undefined
+ 'does not have an error': (err, response) ->
+ assert.isNull(err)
+ 'is successful': (err, response) ->
+ assert.isTrue(response.success)
+ 'sets recurring to true': (err, response) ->
+ assert.equal(response.transaction.recurring, true)
+
'when processor declined':
topic: ->
specHelper.defaultGateway.transaction.sale(
Please sign in to comment.
Something went wrong with that request. Please try again.