@@ -154,11 +154,13 @@ public function testEntries(): void
154
154
public function testTransactionDetails (): void
155
155
{
156
156
$ messages = [
157
- $ this ->getV2Message (),
158
157
$ this ->getV4Message (),
159
158
$ this ->getV8Message (),
160
159
];
161
160
161
+ // this is because V4 and V8 don't support the structure with proprietary amount
162
+ $ this ->testV2Message ();
163
+
162
164
foreach ($ messages as $ message ) {
163
165
$ notifications = $ message ->getRecords ();
164
166
@@ -376,4 +378,276 @@ public function testTransactionDetails(): void
376
378
}
377
379
}
378
380
}
381
+
382
+ public function testV2Message (): void
383
+ {
384
+ $ message = $ this ->getV2Message ();
385
+
386
+ $ notifications = $ message ->getRecords ();
387
+
388
+ self ::assertCount (1 , $ notifications );
389
+ foreach ($ notifications as $ notification ) {
390
+ $ entries = $ notification ->getEntries ();
391
+
392
+ self ::assertCount (1 , $ entries );
393
+ foreach ($ entries as $ entry ) {
394
+ $ transactionDetails = $ entry ->getTransactionDetails ();
395
+ self ::assertCount (4 , $ transactionDetails );
396
+ foreach ($ transactionDetails as $ index => $ transactionDetail ) {
397
+ switch ($ index ) {
398
+ case 0 :
399
+ // Legacy : The first message comes from unstructured block
400
+ self ::assertEquals (
401
+ 'Unstructured Remittance Information V1 ' ,
402
+ $ transactionDetail
403
+ ->getRemittanceInformation ()
404
+ ->getMessage ()
405
+ );
406
+
407
+ // Only one structured data block
408
+ self ::assertEquals (
409
+ 'Unstructured Remittance Information V1 ' ,
410
+ $ transactionDetail
411
+ ->getRemittanceInformation ()
412
+ ->getUnstructuredBlock ()
413
+ ->getMessage ()
414
+ );
415
+
416
+ // Check structured and unstructured blocks
417
+ self ::assertEquals (
418
+ 'ISR ref number V1 ' ,
419
+ $ transactionDetail
420
+ ->getRemittanceInformation ()
421
+ ->getStructuredBlock ()
422
+ ->getCreditorReferenceInformation ()
423
+ ->getRef ()
424
+ );
425
+
426
+ self ::assertEquals (
427
+ 'ISR Reference ' ,
428
+ $ transactionDetail
429
+ ->getRemittanceInformation ()
430
+ ->getStructuredBlock ()
431
+ ->getCreditorReferenceInformation ()
432
+ ->getProprietary ()
433
+ );
434
+
435
+ self ::assertNull (
436
+ $ transactionDetail
437
+ ->getRemittanceInformation ()
438
+ ->getStructuredBlock ()
439
+ ->getCreditorReferenceInformation ()
440
+ ->getCode ()
441
+ );
442
+
443
+ self ::assertEquals (
444
+ 'Additional Remittance Information V1 ' ,
445
+ $ transactionDetail
446
+ ->getRemittanceInformation ()
447
+ ->getStructuredBlock ()
448
+ ->getAdditionalRemittanceInformation ()
449
+ );
450
+
451
+ break ;
452
+ case 1 :
453
+ self ::assertEquals (
454
+ 'ISR ref number V2 ' ,
455
+ $ transactionDetail
456
+ ->getRemittanceInformation ()
457
+ ->getMessage ()
458
+ );
459
+
460
+ // Only one structured data block
461
+ self ::assertEquals (
462
+ 'ISR ref number V2 ' ,
463
+ $ transactionDetail
464
+ ->getRemittanceInformation ()
465
+ ->getUnstructuredBlock ()
466
+ ->getMessage ()
467
+ );
468
+
469
+ // Check structured and unstructured blocks
470
+ self ::assertEquals (
471
+ 'ISR ref number V2 ' ,
472
+ $ transactionDetail
473
+ ->getRemittanceInformation ()
474
+ ->getStructuredBlock ()
475
+ ->getCreditorReferenceInformation ()
476
+ ->getRef ()
477
+ );
478
+
479
+ self ::assertEquals (
480
+ null ,
481
+ $ transactionDetail
482
+ ->getRemittanceInformation ()
483
+ ->getStructuredBlock ()
484
+ ->getCreditorReferenceInformation ()
485
+ ->getProprietary ()
486
+ );
487
+
488
+ self ::assertEquals (
489
+ 'SCOR ' ,
490
+ $ transactionDetail
491
+ ->getRemittanceInformation ()
492
+ ->getStructuredBlock ()
493
+ ->getCreditorReferenceInformation ()
494
+ ->getCode ()
495
+ );
496
+
497
+ self ::assertEquals (
498
+ null ,
499
+ $ transactionDetail
500
+ ->getRemittanceInformation ()
501
+ ->getStructuredBlock ()
502
+ ->getAdditionalRemittanceInformation ()
503
+ );
504
+ break ;
505
+ case 2 :
506
+
507
+ // Legacy : ref number from the structured information
508
+ // because the unstructured block is not present
509
+ self ::assertEquals (
510
+ 'ISR ref number V2 ' ,
511
+ $ transactionDetail
512
+ ->getRemittanceInformation ()
513
+ ->getMessage ()
514
+ );
515
+
516
+ // No unstructured block
517
+ self ::assertCount (
518
+ 0 ,
519
+ $ transactionDetail
520
+ ->getRemittanceInformation ()
521
+ ->getUnstructuredBlocks ()
522
+ );
523
+
524
+ // Check structured and unstructured blocks
525
+ self ::assertEquals (
526
+ 'ISR ref number V2 ' ,
527
+ $ transactionDetail
528
+ ->getRemittanceInformation ()
529
+ ->getStructuredBlock ()
530
+ ->getCreditorReferenceInformation ()
531
+ ->getRef ()
532
+ );
533
+
534
+ self ::assertEquals (
535
+ 'ISR Reference ' ,
536
+ $ transactionDetail
537
+ ->getRemittanceInformation ()
538
+ ->getStructuredBlock ()
539
+ ->getCreditorReferenceInformation ()
540
+ ->getProprietary ()
541
+ );
542
+
543
+ self ::assertNull (
544
+ $ transactionDetail
545
+ ->getRemittanceInformation ()
546
+ ->getStructuredBlock ()
547
+ ->getCreditorReferenceInformation ()
548
+ ->getCode ()
549
+ );
550
+
551
+ self ::assertEquals (
552
+ 'Additional Remittance Information V2 ' ,
553
+ $ transactionDetail
554
+ ->getRemittanceInformation ()
555
+ ->getStructuredBlock ()
556
+ ->getAdditionalRemittanceInformation ()
557
+ );
558
+
559
+ break ;
560
+ case 3 :
561
+ // Legacy : ref number from the first unstructured block
562
+ self ::assertEquals (
563
+ 'Unstructured Remittance Information V3 block 1 ' ,
564
+ $ transactionDetail
565
+ ->getRemittanceInformation ()
566
+ ->getMessage ()
567
+ );
568
+
569
+ // First unstructured block
570
+ self ::assertEquals (
571
+ 'Unstructured Remittance Information V3 block 1 ' ,
572
+ $ transactionDetail
573
+ ->getRemittanceInformation ()
574
+ ->getUnstructuredBlocks ()[0 ]
575
+ ->getMessage ()
576
+ );
577
+
578
+ // Second unstructured block
579
+ self ::assertEquals (
580
+ 'Unstructured Remittance Information V3 block 2 ' ,
581
+ $ transactionDetail
582
+ ->getRemittanceInformation ()
583
+ ->getUnstructuredBlocks ()[1 ]
584
+ ->getMessage ()
585
+ );
586
+
587
+ // Ref number from the first structured block
588
+ self ::assertEquals (
589
+ 'Ref number V3 block 1 ' ,
590
+ $ transactionDetail
591
+ ->getRemittanceInformation ()
592
+ ->getStructuredBlocks ()[0 ]
593
+ ->getCreditorReferenceInformation ()
594
+ ->getRef ()
595
+ );
596
+
597
+ // Ref number from the second structured block
598
+ self ::assertEquals (
599
+ 'Ref number V3 block 2 ' ,
600
+ $ transactionDetail
601
+ ->getRemittanceInformation ()
602
+ ->getStructuredBlocks ()[1 ]
603
+ ->getCreditorReferenceInformation ()
604
+ ->getRef ()
605
+ );
606
+
607
+ // Code from the first structured block
608
+ self ::assertEquals (
609
+ 'SCOR ' ,
610
+ $ transactionDetail
611
+ ->getRemittanceInformation ()
612
+ ->getStructuredBlocks ()[0 ]
613
+ ->getCreditorReferenceInformation ()
614
+ ->getCode ()
615
+ );
616
+
617
+ // Code from the second structured block
618
+ self ::assertEquals (
619
+ 'SCOR ' ,
620
+ $ transactionDetail
621
+ ->getRemittanceInformation ()
622
+ ->getStructuredBlocks ()[1 ]
623
+ ->getCreditorReferenceInformation ()
624
+ ->getCode ()
625
+ );
626
+
627
+ // Additional remittance information from the first structured block
628
+ self ::assertEquals (
629
+ 'Additional Remittance Information V3 block 1 ' ,
630
+ $ transactionDetail
631
+ ->getRemittanceInformation ()
632
+ ->getStructuredBlocks ()[0 ]
633
+ ->getAdditionalRemittanceInformation ()
634
+ );
635
+
636
+ // Additional remittance information from the second structured block
637
+ self ::assertEquals (
638
+ 'Additional Remittance Information V3 block 2 ' ,
639
+ $ transactionDetail
640
+ ->getRemittanceInformation ()
641
+ ->getStructuredBlocks ()[1 ]
642
+ ->getAdditionalRemittanceInformation ()
643
+ );
644
+
645
+ break ;
646
+ default :
647
+ break ;
648
+ }
649
+ }
650
+ }
651
+ }
652
+ }
379
653
}
0 commit comments