1919import com .truelayer .java .http .entities .Headers ;
2020import com .truelayer .java .http .entities .ProblemDetails ;
2121import com .truelayer .java .payments .entities .*;
22+ import com .truelayer .java .payments .entities .StartAuthorizationFlowRequest .Consent .Requirements .AisRequirements .Scope ;
2223import com .truelayer .java .payments .entities .StartAuthorizationFlowRequest .ProviderSelection .Icon ;
2324import com .truelayer .java .payments .entities .StartAuthorizationFlowRequest .ProviderSelection .Icon .IconType ;
2425import com .truelayer .java .payments .entities .beneficiary .MerchantAccount ;
2526import com .truelayer .java .payments .entities .paymentdetail .PaymentDetail ;
2627import com .truelayer .java .payments .entities .paymentdetail .Status ;
28+ import com .truelayer .java .payments .entities .paymentdetail .forminput .Input ;
2729import com .truelayer .java .payments .entities .paymentmethod .PaymentMethod ;
2830import com .truelayer .java .payments .entities .paymentrefund .PaymentRefund ;
2931import com .truelayer .java .payments .entities .providerselection .ProviderSelection ;
3032import com .truelayer .java .payments .entities .providerselection .UserSelectedProviderSelection ;
3133import com .truelayer .java .payments .entities .schemeselection .userselected .SchemeSelection ;
34+ import com .truelayer .java .payments .entities .submerchants .SubMerchants ;
35+ import com .truelayer .java .payments .entities .submerchants .UltimateCounterparty ;
3236import com .truelayer .java .payments .entities .verification .AutomatedVerification ;
3337import java .net .URI ;
3438import java .util .*;
@@ -636,7 +640,6 @@ public void shouldCreatePaymentWithAuthorizationFlowDeprecated() {
636640 .withRequestBody (matchingJsonPath ("$.authorization_flow.provider_selection" , equalToJson ("{}" ))));
637641 }
638642
639- @ Deprecated
640643 @ Test
641644 @ DisplayName ("It should create a payment with authorization_flow" )
642645 @ SneakyThrows
@@ -664,25 +667,35 @@ public void shouldCreatePaymentWithAuthorizationFlow() {
664667 .authorizationFlow (StartAuthorizationFlowRequest .builder ()
665668 .redirect (StartAuthorizationFlowRequest .Redirect .builder ()
666669 .returnUri (URI .create ("https://example.com/return" ))
667- .directReturnUri (URI .create ("http ://example.com/direct-return" ))
670+ .directReturnUri (URI .create ("https ://example.com/direct-return" ))
668671 .build ())
669672 .schemeSelection (Collections .singletonMap ("foo" , "bar" ))
670673 .providerSelection (StartAuthorizationFlowRequest .ProviderSelection .builder ()
671674 .icon (new Icon (IconType .EXTENDED ))
672675 .build ())
673- .form (StartAuthorizationFlowRequest .Form .builder ().build ())
676+ .form (StartAuthorizationFlowRequest .Form .builder ()
677+ .inputTypes (Arrays .asList (Input .Type .TEXT , Input .Type .TEXT_WITH_IMAGE ))
678+ .build ())
674679 .consent (StartAuthorizationFlowRequest .Consent .builder ()
675680 .actionType (StartAuthorizationFlowRequest .Consent .ActionType .ADJACENT )
676681 .requirements (StartAuthorizationFlowRequest .Consent .Requirements .builder ()
677682 .pis (Collections .singletonMap ("req1" , "foo" ))
678683 .ais (
679684 StartAuthorizationFlowRequest .Consent .Requirements .AisRequirements
680685 .builder ()
681- // scopes
686+ . scopes ( Arrays . asList ( Scope . ACCOUNTS , Scope . BALANCE ))
682687 .build ())
683688 .build ())
684689 .build ())
690+ .userAccountSelection (Collections .singletonMap ("bar" , "baz" ))
691+ .build ())
692+ .subMerchants (SubMerchants .builder ()
693+ .ultimateCounterparty (UltimateCounterparty .businessDivision ()
694+ .id ("an-id" )
695+ .name ("business-name" )
696+ .build ())
685697 .build ())
698+ .riskAssessment (RiskAssessment .builder ().segment ("Flights" ).build ())
686699 .build ();
687700
688701 tlClient .payments ().createPayment (paymentRequest ).get ();
@@ -694,7 +707,28 @@ public void shouldCreatePaymentWithAuthorizationFlow() {
694707 .withRequestBody (matchingJsonPath ("$.payment_method.type" , equalTo ("bank_transfer" )))
695708 .withRequestBody (matchingJsonPath (
696709 "$.authorization_flow.redirect.return_uri" , equalTo ("https://example.com/return" )))
710+ .withRequestBody (matchingJsonPath (
711+ "$.authorization_flow.redirect.direct_return_uri" ,
712+ equalTo ("https://example.com/direct-return" )))
713+ .withRequestBody (
714+ matchingJsonPath ("$.authorization_flow.provider_selection.icon.type" , equalTo ("extended" )))
715+ .withRequestBody (
716+ matchingJsonPath ("$.authorization_flow.scheme_selection" , equalToJson ("{\" foo\" : \" bar\" }" )))
717+ .withRequestBody (matchingJsonPath (
718+ "$.authorization_flow.form.input_types" , equalToJson ("[\" text\" , \" text_with_image\" ]" )))
719+ .withRequestBody (matchingJsonPath ("$.authorization_flow.consent.action_type" , equalTo ("adjacent" )))
720+ .withRequestBody (matchingJsonPath (
721+ "$.authorization_flow.consent.requirements.pis" , equalToJson ("{\" req1\" : \" foo\" }" )))
722+ .withRequestBody (matchingJsonPath (
723+ "$.authorization_flow.consent.requirements.ais.scopes" ,
724+ equalToJson ("[\" accounts\" , \" balance\" ]" )))
725+ .withRequestBody (matchingJsonPath (
726+ "$.authorization_flow.user_account_selection" , equalToJson ("{\" bar\" : \" baz\" }" )))
727+ .withRequestBody (
728+ matchingJsonPath ("$.sub_merchants.ultimate_counterparty.type" , equalTo ("business_division" )))
729+ .withRequestBody (matchingJsonPath ("$.sub_merchants.ultimate_counterparty.id" , equalTo ("an-id" )))
697730 .withRequestBody (
698- matchingJsonPath ("$.authorization_flow.provider_selection.icon.type" , equalTo ("extended" ))));
731+ matchingJsonPath ("$.sub_merchants.ultimate_counterparty.name" , equalTo ("business-name" )))
732+ .withRequestBody (matchingJsonPath ("$.risk_assessment.segment" , equalTo ("Flights" ))));
699733 }
700734}
0 commit comments