Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

1.3.0

  • Loading branch information...
commit 909c7a3dbd54182d6b34924afc79a077e13c00dc 1 parent 83844db
Braintree Open Source braintreeps authored
5 CHANGELOG.md
Source Rendered
... ... @@ -1,3 +1,8 @@
  1 +## 1.3.0
  2 +
  3 +* Additional card information, such as prepaid, debit, commercial, Durbin regulated, healthcare, and payroll, are returned on credit card responses
  4 +* Allows transactions to be specified as recurring
  5 +
1 6 ## 1.2.0
2 7
3 8 * Add prepaid field to credit card (possible values include Yes, No, Unknown)
2  lib/braintree.coffee
@@ -7,6 +7,6 @@ connect = (config) ->
7 7 new BraintreeGateway(new Config(config))
8 8
9 9 exports.connect = connect
10   -exports.version = '1.1.2'
  10 +exports.version = '1.3.0'
11 11 exports.Environment = Environment
12 12 exports.errorTypes = errorTypes
25 lib/braintree/credit_card.coffee
@@ -29,6 +29,31 @@ class CreditCard extends AttributeSetter
29 29 No : "No"
30 30 Unknown : "Unknown"
31 31
  32 + @Commercial =
  33 + Yes : "Yes"
  34 + No : "No"
  35 + Unknown : "Unknown"
  36 +
  37 + @Payroll =
  38 + Yes : "Yes"
  39 + No : "No"
  40 + Unknown : "Unknown"
  41 +
  42 + @Healthcare =
  43 + Yes : "Yes"
  44 + No : "No"
  45 + Unknown : "Unknown"
  46 +
  47 + @DurbinRegulated =
  48 + Yes : "Yes"
  49 + No : "No"
  50 + Unknown : "Unknown"
  51 +
  52 + @Debit =
  53 + Yes : "Yes"
  54 + No : "No"
  55 + Unknown : "Unknown"
  56 +
32 57 constructor: (attributes) ->
33 58 super attributes
34 59 @maskedNumber = "#{@bin}******#{@last4}"
13 lib/braintree/test/credit_card_numbers.coffee
... ... @@ -0,0 +1,13 @@
  1 +CreditCardNumbers =
  2 + CardTypeIndicators : {
  3 + Prepaid : "4111111111111210"
  4 + Commercial : "4111111111131010"
  5 + Payroll : "4111111114101010"
  6 + Healthcare : "4111111510101010"
  7 + DurbinRegulated : "4111161010101010"
  8 + Debit : "4117101010101010"
  9 + Unknown : "4111111111112101"
  10 + No : "4111111111310101"
  11 + }
  12 +
  13 +exports.CreditCardNumbers = CreditCardNumbers
2  package.json
... ... @@ -1,6 +1,6 @@
1 1 {
2 2 "name" : "braintree",
3   - "version" : "1.2.0",
  3 + "version" : "1.3.0",
4 4 "description" : "A library for integrating with Braintree.",
5 5 "keywords" : ["payments"],
6 6 "homepage" : "http://github.com/braintree/braintree_node",
115 spec/integration/braintree/credit_card_gateway_spec.coffee
@@ -3,6 +3,7 @@ _ = require('underscore')._
3 3 braintree = specHelper.braintree
4 4 util = require('util')
5 5 {CreditCard} = require('../../../lib/braintree/credit_card')
  6 +{CreditCardNumbers} = require('../../../lib/braintree/test/credit_card_numbers')
6 7
7 8 vows
8 9 .describe('CreditCardGateway')
@@ -28,7 +29,7 @@ vows
28 29 'has credit card attributes': (err, response) ->
29 30 assert.equal(response.creditCard.maskedNumber, '510510******5100')
30 31 assert.equal(response.creditCard.expirationDate, '05/2012')
31   - assert.isTrue(/^\w{32}$/.test(response.creditCard.uniqueNumberIdentifier))
  32 + assert.isTrue(response.creditCard.uniqueNumberIdentifier.length == 32)
32 33
33 34 'with billing address':
34 35 topic: ->
@@ -205,7 +206,7 @@ vows
205 206 'returns a not found error': (err, address) ->
206 207 assert.equal(err.type, braintree.errorTypes.notFoundError)
207 208
208   - 'prepaid':
  209 + 'card type indicator are set':
209 210 'with a prepaid card':
210 211 topic: () ->
211 212 callback = @callback
@@ -215,7 +216,7 @@ vows
215 216 , (err, response) ->
216 217 specHelper.defaultGateway.creditCard.create(
217 218 customerId: response.customer.id,
218   - number: '4500600000000061',
  219 + number: CreditCardNumbers.CardTypeIndicators.Prepaid,
219 220 expirationDate: '05/2012',
220 221 options: {
221 222 verifyCard: true
@@ -224,8 +225,99 @@ vows
224 225 undefined
225 226 'sets the prepaid field to Yes': (err, response) ->
226 227 assert.equal(response.creditCard.prepaid, CreditCard.Prepaid.Yes)
  228 + 'with a commercial card':
  229 + topic: () ->
  230 + callback = @callback
  231 + specHelper.defaultGateway.customer.create(
  232 + firstName: 'John',
  233 + lastName: 'Smith'
  234 + , (err, response) ->
  235 + specHelper.defaultGateway.creditCard.create(
  236 + customerId: response.customer.id,
  237 + number: CreditCardNumbers.CardTypeIndicators.Commercial,
  238 + expirationDate: '05/2012',
  239 + options: {
  240 + verifyCard: true
  241 + }
  242 + , callback))
  243 + undefined
  244 + 'sets the commercial field to Yes': (err, response) ->
  245 + assert.equal(response.creditCard.commercial, CreditCard.Commercial.Yes)
  246 + 'with a payroll card':
  247 + topic: () ->
  248 + callback = @callback
  249 + specHelper.defaultGateway.customer.create(
  250 + firstName: 'John',
  251 + lastName: 'Smith'
  252 + , (err, response) ->
  253 + specHelper.defaultGateway.creditCard.create(
  254 + customerId: response.customer.id,
  255 + number: CreditCardNumbers.CardTypeIndicators.Payroll,
  256 + expirationDate: '05/2012',
  257 + options: {
  258 + verifyCard: true
  259 + }
  260 + , callback))
  261 + undefined
  262 + 'sets the payroll field to Yes': (err, response) ->
  263 + assert.equal(response.creditCard.payroll, CreditCard.Payroll.Yes)
  264 + 'with a heathcare card':
  265 + topic: () ->
  266 + callback = @callback
  267 + specHelper.defaultGateway.customer.create(
  268 + firstName: 'John',
  269 + lastName: 'Smith'
  270 + , (err, response) ->
  271 + specHelper.defaultGateway.creditCard.create(
  272 + customerId: response.customer.id,
  273 + number: CreditCardNumbers.CardTypeIndicators.Healthcare,
  274 + expirationDate: '05/2012',
  275 + options: {
  276 + verifyCard: true
  277 + }
  278 + , callback))
  279 + undefined
  280 + 'sets the healthcare field to Yes': (err, response) ->
  281 + assert.equal(response.creditCard.healthcare, CreditCard.Healthcare.Yes)
  282 + 'with a durbin regulated card':
  283 + topic: () ->
  284 + callback = @callback
  285 + specHelper.defaultGateway.customer.create(
  286 + firstName: 'John',
  287 + lastName: 'Smith'
  288 + , (err, response) ->
  289 + specHelper.defaultGateway.creditCard.create(
  290 + customerId: response.customer.id,
  291 + number: CreditCardNumbers.CardTypeIndicators.DurbinRegulated,
  292 + expirationDate: '05/2012',
  293 + options: {
  294 + verifyCard: true
  295 + }
  296 + , callback))
  297 + undefined
  298 + 'sets the durbin regulated field to Yes': (err, response) ->
  299 + assert.equal(response.creditCard.durbinRegulated, CreditCard.DurbinRegulated.Yes)
  300 + 'with a debit card':
  301 + topic: () ->
  302 + callback = @callback
  303 + specHelper.defaultGateway.customer.create(
  304 + firstName: 'John',
  305 + lastName: 'Smith'
  306 + , (err, response) ->
  307 + specHelper.defaultGateway.creditCard.create(
  308 + customerId: response.customer.id,
  309 + number: CreditCardNumbers.CardTypeIndicators.Debit,
  310 + expirationDate: '05/2012',
  311 + options: {
  312 + verifyCard: true
  313 + }
  314 + , callback))
  315 + undefined
  316 + 'sets the debit field to Yes': (err, response) ->
  317 + assert.equal(response.creditCard.debit, CreditCard.Debit.Yes)
227 318
228   - 'with a non-prepaid card':
  319 + 'negative card type indicators':
  320 + 'with a negative card type indicator card':
229 321 topic: () ->
230 322 callback = @callback
231 323 specHelper.defaultGateway.customer.create(
@@ -234,7 +326,7 @@ vows
234 326 , (err, response) ->
235 327 specHelper.defaultGateway.creditCard.create(
236 328 customerId: response.customer.id,
237   - number: '4111111111111111',
  329 + number: CreditCardNumbers.CardTypeIndicators.No,
238 330 expirationDate: '05/2012',
239 331 options: {
240 332 verifyCard: true
@@ -243,7 +335,18 @@ vows
243 335 undefined
244 336 'sets the prepaid field to No': (err, response) ->
245 337 assert.equal(response.creditCard.prepaid, CreditCard.Prepaid.No)
  338 + 'sets the payroll field to No': (err, response) ->
  339 + assert.equal(response.creditCard.payroll, CreditCard.Payroll.No)
  340 + 'sets the debit field to No': (err, response) ->
  341 + assert.equal(response.creditCard.debit, CreditCard.Debit.No)
  342 + 'sets the commercial field to No': (err, response) ->
  343 + assert.equal(response.creditCard.commercial, CreditCard.Commercial.No)
  344 + 'sets the durbin regulated field to No': (err, response) ->
  345 + assert.equal(response.creditCard.durbinRegulated, CreditCard.DurbinRegulated.No)
  346 + 'sets the heathcare field to No': (err, response) ->
  347 + assert.equal(response.creditCard.healthcare, CreditCard.Healthcare.No)
246 348
  349 + 'unknown card type indicators':
247 350 'with an un-identified card':
248 351 topic: () ->
249 352 callback = @callback
@@ -253,7 +356,7 @@ vows
253 356 , (err, response) ->
254 357 specHelper.defaultGateway.creditCard.create(
255 358 customerId: response.customer.id,
256   - number: '5555555555554444',
  359 + number: CreditCardNumbers.CardTypeIndicators.Unknown,
257 360 expirationDate: '05/2012',
258 361 options: {
259 362 verifyCard: true
17 spec/integration/braintree/transaction_gateway_spec.coffee
@@ -213,6 +213,23 @@ vows
213 213 'has custom fields in response': (err, response) ->
214 214 assert.equal(response.transaction.customFields.storeMe, 'custom value')
215 215
  216 + 'when setting recurring':
  217 + topic: ->
  218 + specHelper.defaultGateway.transaction.sale(
  219 + amount: '5.00'
  220 + creditCard:
  221 + number: '5105105105105100'
  222 + expirationDate: '05/12'
  223 + recurring: true
  224 + , @callback)
  225 + undefined
  226 + 'does not have an error': (err, response) ->
  227 + assert.isNull(err)
  228 + 'is successful': (err, response) ->
  229 + assert.isTrue(response.success)
  230 + 'sets recurring to true': (err, response) ->
  231 + assert.equal(response.transaction.recurring, true)
  232 +
216 233 'when processor declined':
217 234 topic: ->
218 235 specHelper.defaultGateway.transaction.sale(

0 comments on commit 909c7a3

Please sign in to comment.
Something went wrong with that request. Please try again.