Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 78 lines (72 sloc) 3.218 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
require('../../spec_helper')
{CreditCardNumbers} = require('../../../lib/braintree/test/credit_card_numbers')
{CreditCard} = require('../../../lib/braintree/credit_card')

braintree = specHelper.braintree

vows
  .describe('CreditCardVerificationGateway')
  .addBatch
    'find':
      'when found':
        topic: ->
          callback = @callback
          specHelper.defaultGateway.customer.create(
            creditCard:
              cardholderName: "John Smith"
              number: '4000111111111115'
              expirationDate: '05/2014'
              options:
                verifyCard: true
          , (err, response) ->
            specHelper.defaultGateway.creditCardVerification.find(response.verification.id, callback)
          )
          undefined
        'does not have an error': (err, response) ->
          assert.isNull(err)
        'returns customer details': (err, verification) ->
          assert.equal(verification.creditCard.cardholderName, 'John Smith')
      'when not found':
        topic: ->
          specHelper.defaultGateway.creditCardVerification.find('nonexistent_verification', @callback)
          undefined
        'returns a not found error': (err, response) ->
          assert.equal(err.type, braintree.errorTypes.notFoundError)

      'when the id is whitespace':
        topic: ->
          specHelper.defaultGateway.creditCardVerification.find(' ', @callback)
          undefined
        'returns a not found error': (err, response) ->
          assert.equal(err.type, braintree.errorTypes.notFoundError)

      'when using a card with card type indicators':
        topic: ->
          callback = @callback
          name = specHelper.randomId() + ' Smith'
          specHelper.defaultGateway.customer.create({
            creditCard:
              cardholderName: name,
              number: CreditCardNumbers.CardTypeIndicators.Unknown,
              expirationDate: '05/12',
              options:
                verifyCard: true
            }, (err, response) ->
              specHelper.defaultGateway.creditCardVerification.search((search) ->
                search.creditCardCardholderName().is(name)
              , (err, response) ->
                response.first((err, result) ->
                  callback(err,
                    verification: result
                    name: name
                  )
                )
              )
            )
          undefined
        'card details card type indicator should be prepaid': (err, result) ->
          assert.isNull(err)
          assert.equal(result.verification.creditCard.cardholderName, result.name)
          assert.equal(result.verification.creditCard.prepaid, CreditCard.Prepaid.Unknown)
          assert.equal(result.verification.creditCard.durbinRegulated, CreditCard.DurbinRegulated.Unknown)
          assert.equal(result.verification.creditCard.commercial, CreditCard.Commercial.Unknown)
          assert.equal(result.verification.creditCard.healthcare, CreditCard.Healthcare.Unknown)
          assert.equal(result.verification.creditCard.debit, CreditCard.Debit.Unknown)
          assert.equal(result.verification.creditCard.payroll, CreditCard.Payroll.Unknown)

  .export(module)
Something went wrong with that request. Please try again.