@@ -635,7 +635,7 @@ public function testAssemblePayFinalize(): void
635635 'orderTransaction ' => [
636636 'id ' => 'bar ' ,
637637 ],
638- 'queryParameters ' => [
638+ 'requestData ' => [
639639 'returnId ' => '123 ' ,
640640 ],
641641 'recurring ' => [
@@ -658,11 +658,106 @@ public function testAssemblePayFinalize(): void
658658 static ::assertFalse ($ paymentPayResponse ->source ->inAppPurchases ->has ('baz ' ));
659659 static ::assertSame ('bar ' , $ paymentPayResponse ->orderTransaction ->getId ());
660660 static ::assertSame (['returnId ' => '123 ' ], $ paymentPayResponse ->queryParameters );
661+ static ::assertSame (['returnId ' => '123 ' ], $ paymentPayResponse ->getRequestData ());
662+ static ::assertSame (['returnId ' => '123 ' ], $ paymentPayResponse ->getQueryParameters ());
663+ static ::assertNotNull ($ paymentPayResponse ->recurring );
664+ static ::assertSame ('baz ' , $ paymentPayResponse ->recurring ->getSubscriptionId ());
665+ static ::assertEquals (new \DateTime ('2023-07-18T17:00:00.000+00:00 ' ), $ paymentPayResponse ->recurring ->getNextSchedule ());
666+ }
667+
668+ public function testAssemblePayFinalizeWithQueryParameters (): void
669+ {
670+ $ collection = new Collection ([
671+ 'foo ' => new InAppPurchase ('foo ' , 1 ),
672+ 'bar ' => new InAppPurchase ('bar ' , 2 ),
673+ ]);
674+
675+ $ provider = $ this ->createMock (InAppPurchaseProvider::class);
676+ $ provider
677+ ->method ('decodePurchases ' )
678+ ->willReturn ($ collection );
679+
680+ $ contextResolver = new ContextResolver ($ provider );
681+
682+ $ body = [
683+ 'source ' => [
684+ 'url ' => 'https://example.com ' ,
685+ 'appVersion ' => 'foo ' ,
686+ 'inAppPurchases ' => 'ey ' ,
687+ ],
688+ 'orderTransaction ' => [
689+ 'id ' => 'bar ' ,
690+ ],
691+ 'queryParameters ' => [
692+ 'returnId ' => '123 ' ,
693+ ],
694+ 'recurring ' => [
695+ 'subscriptionId ' => 'baz ' ,
696+ 'nextSchedule ' => '2023-07-18T17:00:00.000+00:00 ' ,
697+ ],
698+ ];
699+
700+ $ paymentPayResponse = $ contextResolver ->assemblePaymentFinalize (
701+ new Request ('POST ' , '/ ' , [], \json_encode ($ body , JSON_THROW_ON_ERROR )),
702+ $ this ->getShop ()
703+ );
704+
705+ static ::assertInstanceOf (PaymentFinalizeAction::class, $ paymentPayResponse );
706+ static ::assertSame ('https://example.com ' , $ paymentPayResponse ->source ->url );
707+ static ::assertSame ('foo ' , $ paymentPayResponse ->source ->appVersion );
708+ static ::assertSame ('bar ' , $ paymentPayResponse ->orderTransaction ->getId ());
709+ static ::assertSame (['returnId ' => '123 ' ], $ paymentPayResponse ->getRequestData ());
710+ static ::assertSame (['returnId ' => '123 ' ], $ paymentPayResponse ->getQueryParameters ());
661711 static ::assertNotNull ($ paymentPayResponse ->recurring );
662712 static ::assertSame ('baz ' , $ paymentPayResponse ->recurring ->getSubscriptionId ());
663713 static ::assertEquals (new \DateTime ('2023-07-18T17:00:00.000+00:00 ' ), $ paymentPayResponse ->recurring ->getNextSchedule ());
664714 }
665715
716+ public function testAssemblePayFinalizeWithBothParameters (): void
717+ {
718+ $ collection = new Collection ([
719+ 'foo ' => new InAppPurchase ('foo ' , 1 ),
720+ 'bar ' => new InAppPurchase ('bar ' , 2 ),
721+ ]);
722+
723+ $ provider = $ this ->createMock (InAppPurchaseProvider::class);
724+ $ provider
725+ ->method ('decodePurchases ' )
726+ ->willReturn ($ collection );
727+
728+ $ contextResolver = new ContextResolver ($ provider );
729+
730+ $ body = [
731+ 'source ' => [
732+ 'url ' => 'https://example.com ' ,
733+ 'appVersion ' => 'foo ' ,
734+ 'inAppPurchases ' => 'ey ' ,
735+ ],
736+ 'orderTransaction ' => [
737+ 'id ' => 'bar ' ,
738+ ],
739+ 'requestData ' => [
740+ 'newParam ' => 'newValue ' ,
741+ ],
742+ 'queryParameters ' => [
743+ 'oldParam ' => 'oldValue ' ,
744+ ],
745+ 'recurring ' => [
746+ 'subscriptionId ' => 'baz ' ,
747+ 'nextSchedule ' => '2023-07-18T17:00:00.000+00:00 ' ,
748+ ],
749+ ];
750+
751+ $ paymentPayResponse = $ contextResolver ->assemblePaymentFinalize (
752+ new Request ('POST ' , '/ ' , [], \json_encode ($ body , JSON_THROW_ON_ERROR )),
753+ $ this ->getShop ()
754+ );
755+
756+ static ::assertInstanceOf (PaymentFinalizeAction::class, $ paymentPayResponse );
757+ static ::assertSame ('bar ' , $ paymentPayResponse ->orderTransaction ->getId ());
758+ static ::assertSame (['newParam ' => 'newValue ' ], $ paymentPayResponse ->getRequestData ());
759+ }
760+
666761 public function testPaymentPayCapture (): void
667762 {
668763 $ collection = new Collection ([
0 commit comments