@@ -154,8 +154,7 @@ it("returns TestModePurchaseNonRefundable when refunding test mode one-time purc
154154 body : {
155155 type : "one-time-purchase" ,
156156 id : transactionId ,
157- amount_usd : "5000" ,
158- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
157+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "5000" } ] ,
159158 } ,
160159 } ) ;
161160 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -184,8 +183,7 @@ it("returns SubscriptionInvoiceNotFound when id does not exist", async () => {
184183 body : {
185184 type : "subscription" ,
186185 id : missingId ,
187- amount_usd : "1000" ,
188- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
186+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "1000" } ] ,
189187 } ,
190188 } ) ;
191189 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -268,8 +266,7 @@ it("refunds non-test mode one-time purchases created via Stripe webhooks", async
268266 body : {
269267 type : "one-time-purchase" ,
270268 id : purchaseTransaction . id ,
271- amount_usd : "5000" ,
272- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
269+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "5000" } ] ,
273270 } ,
274271 } ) ;
275272 expect ( refundRes . status ) . toBe ( 200 ) ;
@@ -292,8 +289,7 @@ it("refunds non-test mode one-time purchases created via Stripe webhooks", async
292289 body : {
293290 type : "one-time-purchase" ,
294291 id : purchaseTransaction . id ,
295- amount_usd : "5000" ,
296- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
292+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "5000" } ] ,
297293 } ,
298294 } ) ;
299295 expect ( secondRefundAttempt ) . toMatchInlineSnapshot ( `
@@ -332,8 +328,7 @@ it("refunds partial amounts for non-test mode one-time purchases", async () => {
332328 body : {
333329 type : "one-time-purchase" ,
334330 id : purchaseTransaction . id ,
335- amount_usd : "1250" ,
336- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
331+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "1250" } ] ,
337332 } ,
338333 } ) ;
339334 expect ( refundRes . status ) . toBe ( 200 ) ;
@@ -361,8 +356,7 @@ it("refunds partial amounts for non-test mode one-time purchases", async () => {
361356 body : {
362357 type : "one-time-purchase" ,
363358 id : purchaseTransaction . id ,
364- amount_usd : "1250" ,
365- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
359+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "1250" } ] ,
366360 } ,
367361 } ) ;
368362 expect ( secondRefundAttempt . body . code ) . toBe ( "ONE_TIME_PURCHASE_ALREADY_REFUNDED" ) ;
@@ -377,8 +371,7 @@ it("refunds selected quantities for non-test mode one-time purchases", async ()
377371 body : {
378372 type : "one-time-purchase" ,
379373 id : purchaseTransaction . id ,
380- amount_usd : "10000" ,
381- refund_entries : [ { entry_index : 0 , quantity : 2 } ] ,
374+ refund_entries : [ { entry_index : 0 , quantity : 2 , amount_usd : "10000" } ] ,
382375 } ,
383376 } ) ;
384377 expect ( refundRes . status ) . toBe ( 200 ) ;
@@ -410,8 +403,7 @@ it("returns SCHEMA_ERROR when amount_usd is negative", async () => {
410403 body : {
411404 type : "one-time-purchase" ,
412405 id : purchaseTransaction . id ,
413- amount_usd : "-1" ,
414- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
406+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "-1" } ] ,
415407 } ,
416408 } ) ;
417409 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -447,8 +439,7 @@ it("allows amount_usd of zero", async () => {
447439 body : {
448440 type : "one-time-purchase" ,
449441 id : purchaseTransaction . id ,
450- amount_usd : "0" ,
451- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
442+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "0" } ] ,
452443 } ,
453444 } ) ;
454445 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -460,7 +451,7 @@ it("allows amount_usd of zero", async () => {
460451 ` ) ;
461452} ) ;
462453
463- it ( "allows empty refund_entries (money-only refund)" , async ( ) => {
454+ it ( "allows zero-quantity refund entries (money-only refund)" , async ( ) => {
464455 const { userId, purchaseTransaction } = await createLiveModeOneTimePurchaseTransaction ( ) ;
465456
466457 const refundRes = await niceBackendFetch ( "/api/latest/internal/payments/transactions/refund" , {
@@ -469,8 +460,7 @@ it("allows empty refund_entries (money-only refund)", async () => {
469460 body : {
470461 type : "one-time-purchase" ,
471462 id : purchaseTransaction . id ,
472- amount_usd : "5000" ,
473- refund_entries : [ ] ,
463+ refund_entries : [ { entry_index : 0 , quantity : 0 , amount_usd : "5000" } ] ,
474464 } ,
475465 } ) ;
476466 expect ( refundRes . status ) . toBe ( 200 ) ;
@@ -502,8 +492,7 @@ it("returns SCHEMA_ERROR when refund_entries contains bad entry_index", async ()
502492 body : {
503493 type : "one-time-purchase" ,
504494 id : purchaseTransaction . id ,
505- amount_usd : "5000" ,
506- refund_entries : [ { entry_index : 999 , quantity : 1 } ] ,
495+ refund_entries : [ { entry_index : 999 , quantity : 1 , amount_usd : "5000" } ] ,
507496 } ,
508497 } ) ;
509498 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -531,8 +520,7 @@ it("returns SCHEMA_ERROR when refund_entries contains negative quantity", async
531520 body : {
532521 type : "one-time-purchase" ,
533522 id : purchaseTransaction . id ,
534- amount_usd : "5000" ,
535- refund_entries : [ { entry_index : 0 , quantity : - 1 } ] ,
523+ refund_entries : [ { entry_index : 0 , quantity : - 1 , amount_usd : "5000" } ] ,
536524 } ,
537525 } ) ;
538526 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -560,8 +548,7 @@ it("allows refund_entries with zero quantity", async () => {
560548 body : {
561549 type : "one-time-purchase" ,
562550 id : purchaseTransaction . id ,
563- amount_usd : "5000" ,
564- refund_entries : [ { entry_index : 0 , quantity : 0 } ] ,
551+ refund_entries : [ { entry_index : 0 , quantity : 0 , amount_usd : "5000" } ] ,
565552 } ,
566553 } ) ;
567554 expect ( refundRes . status ) . toBe ( 200 ) ;
@@ -593,8 +580,7 @@ it("returns SCHEMA_ERROR when refund_entries contains quantity past limit", asyn
593580 body : {
594581 type : "one-time-purchase" ,
595582 id : purchaseTransaction . id ,
596- amount_usd : "5000" ,
597- refund_entries : [ { entry_index : 0 , quantity : 2 } ] ,
583+ refund_entries : [ { entry_index : 0 , quantity : 2 , amount_usd : "5000" } ] ,
598584 } ,
599585 } ) ;
600586 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -622,8 +608,7 @@ it("returns SCHEMA_ERROR when amount_usd exceeds charged amount", async () => {
622608 body : {
623609 type : "one-time-purchase" ,
624610 id : purchaseTransaction . id ,
625- amount_usd : "5001" ,
626- refund_entries : [ { entry_index : 0 , quantity : 1 } ] ,
611+ refund_entries : [ { entry_index : 0 , quantity : 1 , amount_usd : "5001" } ] ,
627612 } ,
628613 } ) ;
629614 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -651,8 +636,7 @@ it("returns SCHEMA_ERROR when refund_entries contains negative entry_index", asy
651636 body : {
652637 type : "one-time-purchase" ,
653638 id : purchaseTransaction . id ,
654- amount_usd : "5000" ,
655- refund_entries : [ { entry_index : - 1 , quantity : 1 } ] ,
639+ refund_entries : [ { entry_index : - 1 , quantity : 1 , amount_usd : "5000" } ] ,
656640 } ,
657641 } ) ;
658642 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -680,8 +664,7 @@ it("returns SCHEMA_ERROR when refund_entries quantity is not an integer", async
680664 body : {
681665 type : "one-time-purchase" ,
682666 id : purchaseTransaction . id ,
683- amount_usd : "5000" ,
684- refund_entries : [ { entry_index : 0 , quantity : 1.5 } ] ,
667+ refund_entries : [ { entry_index : 0 , quantity : 1.5 , amount_usd : "5000" } ] ,
685668 } ,
686669 } ) ;
687670 expect ( refundRes . body . code ) . toBe ( "SCHEMA_ERROR" ) ;
@@ -696,8 +679,7 @@ it("returns SCHEMA_ERROR when refund_entries references non-product_grant entrie
696679 body : {
697680 type : "one-time-purchase" ,
698681 id : purchaseTransaction . id ,
699- amount_usd : "5000" ,
700- refund_entries : [ { entry_index : 1 , quantity : 1 } ] ,
682+ refund_entries : [ { entry_index : 1 , quantity : 1 , amount_usd : "5000" } ] ,
701683 } ,
702684 } ) ;
703685 expect ( refundRes ) . toMatchInlineSnapshot ( `
@@ -725,10 +707,9 @@ it("returns SCHEMA_ERROR when refund_entries contains duplicate entry indexes",
725707 body : {
726708 type : "one-time-purchase" ,
727709 id : purchaseTransaction . id ,
728- amount_usd : "5000" ,
729710 refund_entries : [
730- { entry_index : 0 , quantity : 1 } ,
731- { entry_index : 0 , quantity : 1 } ,
711+ { entry_index : 0 , quantity : 1 , amount_usd : "5000" } ,
712+ { entry_index : 0 , quantity : 1 , amount_usd : "5000" } ,
732713 ] ,
733714 } ,
734715 } ) ;
0 commit comments