@@ -22,20 +22,51 @@ describe('AuthorizeNet service', function () {
22
22
service . authCaptureTransaction ( randomAmount ( ) , 4012888818888 , 2017 , 1 ) . then ( function ( transaction ) {
23
23
assert . equal ( transaction . transactionResponse . responseCode , '1' ) ;
24
24
done ( ) ;
25
- } ) ;
25
+ } , function ( rejection ) {
26
+ done ( rejection ) ;
27
+ } )
26
28
} ) ;
27
29
28
30
it ( 'should submit authorizationCapture request with some extra params' , function ( done ) {
29
31
service . authCaptureTransaction ( randomAmount ( ) , 4012888818888 , 2016 , 10 , {
30
32
transactionRequest : {
31
33
payment : { creditCard : { cardCode : 999 } } ,
32
- billTo : { firstName : 'bob' , lastName : 'Eponge' }
34
+ lineItems : [
35
+ { lineItem : { itemId :1 , name : 'Test Item' , quantity :2 , unitPrice : 4.99 } } ,
36
+ { lineItem : { itemId :2 , name : 'Test Item2' , quantity :3 , unitPrice : 5.99 } }
37
+ ] ,
38
+ tax : {
39
+ amount : 2.13 ,
40
+ name : 'city tax' ,
41
+ description : 'some text here'
42
+ } ,
43
+ duty : {
44
+ amount : 1.21 ,
45
+ name : 'duty name' ,
46
+ description : 'duty description'
47
+ } ,
48
+ shipping : {
49
+ amount : 12.99 ,
50
+ name : '2 Day Shipping' ,
51
+ description : 'UPS'
52
+ } ,
53
+ poNumber : 'abcd-1234' ,
54
+ billTo : { firstName : 'bob' , lastName : 'Eponge' } ,
55
+ customer : {
56
+ id : 12345678
57
+ } ,
58
+ userFields : [
59
+ { userField : { name : 'cartId' , value : 'xyx1234' } } ,
60
+ { userField : { name : 'discountCode' , value : 'xcxcx' } }
61
+ ]
33
62
}
34
63
} ) . then ( function ( transaction ) {
35
64
assert . equal ( transaction . transactionResponse . responseCode , '1' ) ;
36
65
done ( ) ;
66
+ } , function ( rejection ) {
67
+ done ( JSON . stringify ( rejection ) ) ;
37
68
} ) ;
38
- } ) ;
69
+ } ) ;
39
70
40
71
it ( 'should reject the promise when web service send an error code' , function ( done ) {
41
72
service . authCaptureTransaction ( randomAmount ( ) , 234234 , 2016 , 10 ) . then ( function ( ) {
@@ -66,14 +97,18 @@ describe('AuthorizeNet service', function () {
66
97
service . authOnlyTransaction ( randomAmount ( ) , 4007000000027 , 2016 , 2 ) . then ( function ( transaction ) {
67
98
assert . equal ( transaction . transactionResponse . responseCode , '1' ) ;
68
99
done ( ) ;
69
- } ) ;
100
+ } ) . catch ( function ( err ) {
101
+ done ( err ) ;
102
+ } )
70
103
} ) ;
71
104
72
105
it ( 'should submit authorization only request with extra params' , function ( done ) {
73
106
service . authOnlyTransaction ( randomAmount ( ) , 4007000000027 , 2017 , 11 , { transactionRequest : { payment : { creditCard : { cardCode : 666 } } } } ) . then ( function ( transaction ) {
74
107
assert . equal ( transaction . transactionResponse . responseCode , '1' ) ;
75
108
done ( ) ;
76
- } ) ;
109
+ } ) . catch ( function ( err ) {
110
+ done ( err ) ;
111
+ } )
77
112
} ) ;
78
113
79
114
it ( 'should reject the promise when web service send an error code' , function ( done ) {
@@ -114,6 +149,7 @@ describe('AuthorizeNet service', function () {
114
149
} )
115
150
. catch ( function ( err ) {
116
151
console . log ( err ) ;
152
+ done ( err ) ;
117
153
} ) ;
118
154
} ) ;
119
155
@@ -178,7 +214,10 @@ describe('AuthorizeNet service', function () {
178
214
. then ( function ( trans ) {
179
215
assert . equal ( trans . transactionResponse . responseCode , '1' ) ;
180
216
done ( ) ;
181
- } ) ;
217
+ } )
218
+ . catch ( function ( err ) {
219
+ done ( err ) ;
220
+ } )
182
221
} ) ;
183
222
184
223
it ( 'should reject the promise when web service send an error code' , function ( done ) {
@@ -218,7 +257,10 @@ describe('AuthorizeNet service', function () {
218
257
assert . equal ( trans . transaction . responseCode , '1' ) ;
219
258
assert . equal ( trans . transaction . transId , transId ) ;
220
259
done ( ) ;
221
- } ) ;
260
+ } )
261
+ . catch ( function ( err ) {
262
+ done ( err ) ;
263
+ } )
222
264
} ) ;
223
265
224
266
it ( 'should reject the promise when web service return error code' , function ( done ) {
@@ -250,7 +292,9 @@ describe('AuthorizeNet service', function () {
250
292
service . getUnsettledTransactionList ( ) . then ( function ( response ) {
251
293
assert ( response . transactions , 'transactions field should be defined' ) ;
252
294
done ( ) ;
253
- } ) ;
295
+ } ) . catch ( function ( err ) {
296
+ done ( err ) ;
297
+ } )
254
298
} ) ;
255
299
256
300
} ) ;
@@ -261,7 +305,9 @@ describe('AuthorizeNet service', function () {
261
305
service . getSettledBatchList ( true , new Date ( Date . now ( ) - 7 * 24 * 3600 * 1000 ) , new Date ( ) ) . then ( function ( response ) {
262
306
assert ( response . batchList , 'batchList should be defined' ) ;
263
307
done ( ) ;
264
- } ) ;
308
+ } ) . catch ( function ( err ) {
309
+ done ( err ) ;
310
+ } )
265
311
} ) ;
266
312
267
313
} ) ;
@@ -273,10 +319,12 @@ describe('AuthorizeNet service', function () {
273
319
var batchId = response . batchList . batch . length ? response . batchList . batch [ 0 ] . batchId : response . batchList . batch . batchId ;
274
320
return service . getBatchStatistics ( batchId ) ;
275
321
} )
276
- . then ( function ( response ) {
277
- assert ( response . batch , 'batch should be defined' ) ;
278
- done ( ) ;
279
- } ) ;
322
+ . then ( function ( response ) {
323
+ assert ( response . batch , 'batch should be defined' ) ;
324
+ done ( ) ;
325
+ } ) . catch ( function ( err ) {
326
+ done ( err ) ;
327
+ } )
280
328
} ) ;
281
329
282
330
it ( 'should reject the promise if any error happens' , function ( done ) {
@@ -298,10 +346,13 @@ describe('AuthorizeNet service', function () {
298
346
var batchId = response . batchList . batch . length ? response . batchList . batch [ 0 ] . batchId : response . batchList . batch . batchId ;
299
347
return service . getTransactionList ( batchId ) ;
300
348
} )
301
- . then ( function ( response ) {
302
- assert ( response . transactions . transaction , 'it should have a list of transactions' ) ;
303
- done ( ) ;
304
- } ) ;
349
+ . then ( function ( response ) {
350
+ assert ( response . transactions . transaction , 'it should have a list of transactions' ) ;
351
+ done ( ) ;
352
+ } ) . catch ( function ( err ) {
353
+ done ( err ) ;
354
+ } )
305
355
} ) ;
306
- } ) ;
356
+ } ) ;
357
+
307
358
} ) ;
0 commit comments