66using Checkout . Common ;
77using Checkout . Instruments ;
88using Shouldly ;
9- using System ;
109using System . Collections . Generic ;
11- using System . Linq ;
1210using System . Net ;
1311using System . Net . Mime ;
14- using System . Reflection . Metadata ;
1512using System . Threading . Tasks ;
1613using Xunit ;
1714
1815namespace Checkout . Accounts
1916{
2017 public class AccountsIntegrationTest : SandboxTestFixture
2118 {
22- private static readonly Random Random = new Random ( ) ;
23-
2419 public AccountsIntegrationTest ( ) : base ( PlatformType . DefaultOAuth )
2520 {
2621 }
2722
28- [ Fact ( Skip = "beta" ) ]
23+ [ Fact ]
2924 public async Task ShouldCreateHostedOnboardingInvitationRequest ( )
3025 {
3126 string randomReference = RandomString ( 15 ) ;
3227 var entityRequest = new OnboardEntityRequest
3328 {
3429 Reference = randomReference ,
35- IsDraft = false ,
36- ContactDetails = new ContactDetails { Invitee = new Invitee { Email = "[email protected] " } } 30+ IsDraft = true ,
31+ ContactDetails = new ContactDetails { Invitee = new Invitee { Email = GenerateRandomEmail ( ) } }
3732 } ;
3833
3934 var response = await DefaultApi . AccountsClient ( ) . CreateEntity ( entityRequest ) ;
@@ -44,62 +39,170 @@ public async Task ShouldCreateHostedOnboardingInvitationRequest()
4439 }
4540
4641 [ Fact ]
47- public async Task ShouldCreateCompany ( )
42+ public async Task ShouldCreateCompanyV2 ( )
4843 {
4944 string randomReference = RandomString ( 15 ) ;
50- var entityRequest = new OnboardEntityRequest
45+ var request = new OnboardEntityRequest
5146 {
5247 Reference = randomReference ,
53- Draft = true ,
54- Profile =
55- new Profile
56- {
57- Urls = new List < string > { "http://example.com" } ,
58- Mccs = new List < string > { "4814" } ,
59- HoldingCurrencies = new List < Currency > { Currency . GBP }
60- } ,
61- ContactDetails =
62- new ContactDetails
48+ Company =
49+ new Company
6350 {
64- Phone = new Phone { CountryCode = "GI" , Number = "656453654" } ,
65- EmailAddresses = new EmailAddresses { Primary = null } ,
66- Invitee = new Invitee { Email = null }
51+ LegalName = "Company " + RandomString ( 3 ) ,
52+ TradingName = "Trading " + RandomString ( 3 ) ,
53+ PrincipalAddress = GetAddress ( ) ,
54+ RegisteredAddress = GetAddress ( ) ,
55+ Representatives =
56+ new List < Representative >
57+ {
58+ new Representative
59+ {
60+ FirstName = RandomString ( 5 ) ,
61+ LastName = RandomString ( 5 ) ,
62+ Address = GetAddress ( ) ,
63+ Roles = new List < EntityRoles > { EntityRoles . Ubo } ,
64+ DateOfBirth = new DateOfBirth { Day = 1 , Month = 1 , Year = 1980 } ,
65+ } ,
66+ } ,
67+ BusinessRegistrationNumber = RandomBusinessRegistrationNumber ( ) ,
68+ DateOfIncorporation = new DateOfIncorporation { Day = 1 , Month = 1 , Year = 2001 } ,
69+
6770 } ,
71+ ContactDetails = new ContactDetails
72+ {
73+ Phone = new Phone { CountryCode = "GB" , Number = RandomDigits ( 9 ) } ,
74+ EmailAddresses = new EmailAddresses { Primary = GenerateRandomEmail ( ) } ,
75+ Invitee = new Invitee { Email = GenerateRandomEmail ( ) }
76+ } ,
77+ Profile = new Profile
78+ {
79+ Urls = new List < string > { "http://example.com" } ,
80+ Mccs = new List < string > { "4814" } ,
81+ DefaultHoldingCurrency = Currency . GBP ,
82+ HoldingCurrencies = new List < Currency > { Currency . GBP }
83+ } ,
84+ IsDraft = true
85+ } ;
86+
87+ var api = CheckoutSdk . Builder ( ) . OAuth ( )
88+ . ClientCredentials (
89+ System . Environment . GetEnvironmentVariable ( "CHECKOUT_DEFAULT_OAUTH_CLIENT_ID" ) ,
90+ System . Environment . GetEnvironmentVariable ( "CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET" ) )
91+ . Scopes ( OAuthScope . Accounts )
92+ . Environment ( Environment . Sandbox )
93+ . HttpClientFactory ( new CustomClientFactory ( "2.0" ) )
94+ . Build ( ) ;
95+
96+ var response = await api . AccountsClient ( ) . CreateEntity ( request ) ;
97+
98+ response . ShouldNotBeNull ( ) ;
99+ response . Id . ShouldNotBeNullOrEmpty ( ) ;
100+ response . Reference . ShouldBe ( randomReference ) ;
101+ }
102+
103+ [ Fact ( Skip = "temporarily unavailable" ) ]
104+ public async Task ShouldCreateCompanyV3 ( )
105+ {
106+ string randomReference = RandomString ( 15 ) ;
107+ var request = new OnboardEntityRequest
108+ {
109+ Reference = randomReference ,
68110 Company =
69111 new Company
70112 {
71- LegalName = "string" ,
72- TradingName = "string" ,
73- BusinessRegistrationNumber = "AC123456" ,
113+ LegalName = "Company " + RandomString ( 3 ) ,
114+ TradingName = "Trading " + RandomString ( 3 ) ,
115+ BusinessRegistrationNumber = RandomBusinessRegistrationNumber ( ) ,
74116 DateOfIncorporation = new DateOfIncorporation { Day = 1 , Month = 1 , Year = 2001 } ,
75117 PrincipalAddress = GetAddress ( ) ,
76118 RegisteredAddress = GetAddress ( ) ,
77- BusinessType = BusinessType . IndividualOrSoleProprietorship
78- } ,
79- ProcessingDetails =
80- new ProcessingDetails
81- {
82- SettlementCountry = "GB" ,
83- TargetCountries = new List < string > { "GB" } ,
84- Currency = Currency . GBP
119+ Representatives =
120+ new List < Representative >
121+ {
122+ new Representative
123+ {
124+ Company = new Company
125+ {
126+ LegalName = "Company " + RandomString ( 3 ) ,
127+ TradingName = "Trading " + RandomString ( 3 ) ,
128+ RegisteredAddress = GetAddress ( )
129+ } ,
130+ OwnershipPercentage = 100 ,
131+ } ,
132+ new Representative
133+ {
134+ Individual = new Individual
135+ {
136+ FirstName = "FirstName " + RandomString ( 3 ) ,
137+ LastName = "LastName " + RandomString ( 3 ) ,
138+ DateOfBirth = new DateOfBirth { Day = 1 , Month = 1 , Year = 1980 } ,
139+ PlaceOfBirth = new PlaceOfBirth { Country = CountryCode . GB } ,
140+ Address = GetAddress ( ) ,
141+ EmailAddress = GenerateRandomEmail ( ) ,
142+ } ,
143+ Roles = new List < EntityRoles > { EntityRoles . AuthorisedSignatory , EntityRoles . Director } ,
144+ Documents = new Documents
145+ {
146+ IdentityVerification = new IdentityVerification ( )
147+ {
148+ Type = IdentityVerificationType . Passport ,
149+ Front = "file_bonwzndueqrlwvv3kfcokug5iu"
150+ }
151+ } ,
152+ } ,
153+ } ,
154+ BusinessType = BusinessType . PublicLimitedCompany
85155 } ,
86- Documents = new Documents
156+ Profile = new Profile
157+ {
158+ Urls = new List < string > { "http://example.com" } ,
159+ Mccs = new List < string > { "4814" } ,
160+ DefaultHoldingCurrency = Currency . GBP ,
161+ HoldingCurrencies = new List < Currency > { Currency . GBP }
162+ } ,
163+ ContactDetails = new ContactDetails
164+ {
165+ Phone = new Phone { CountryCode = "GB" , Number = RandomDigits ( 9 ) } ,
166+ EmailAddresses = new EmailAddresses { Primary = GenerateRandomEmail ( ) } ,
167+ Invitee = new Invitee { Email = GenerateRandomEmail ( ) }
168+ } ,
169+ Documents = new Documents ( )
87170 {
88171 ArticlesOfAssociation =
89172 new ArticlesOfAssociation ( )
90173 {
91174 Type = ArticlesOfAssociationType . ArticlesOfAssociation ,
92- Front = "stringstringstringstringstrings "
175+ Front = "file_aacb27em7gmj6e7dhxabazucqi "
93176 } ,
94- ShareholderStructure = new ShareholderStructure ( )
95- {
96- Type = ShareholderStructureType . CertifiedShareholderStructure ,
97- Front = "stringstringstringstringstrings"
98- } ,
99- }
177+ ShareholderStructure =
178+ new ShareholderStructure ( )
179+ {
180+ Type = ShareholderStructureType . CertifiedShareholderStructure ,
181+ Front = "file_bpme2tii3lsgshx4ghj3i4672q"
182+ } ,
183+ } ,
184+ ProcessingDetails = new ProcessingDetails
185+ {
186+ SettlementCountry = "GB" ,
187+ TargetCountries = new List < string > { "GB" } ,
188+ AnnualProcessingVolume = 0 ,
189+ AverageTransactionValue = 0 ,
190+ HighestTransactionValue = 0 ,
191+ Currency = Currency . GBP
192+ } ,
193+ IsDraft = false
100194 } ;
101195
102- var response = await DefaultApi . AccountsClient ( ) . CreateEntity ( entityRequest ) ;
196+ var api = CheckoutSdk . Builder ( ) . OAuth ( )
197+ . ClientCredentials (
198+ System . Environment . GetEnvironmentVariable ( "CHECKOUT_DEFAULT_OAUTH_CLIENT_ID" ) ,
199+ System . Environment . GetEnvironmentVariable ( "CHECKOUT_DEFAULT_OAUTH_CLIENT_SECRET" ) )
200+ . Scopes ( OAuthScope . Accounts )
201+ . Environment ( Environment . Sandbox )
202+ . HttpClientFactory ( new CustomClientFactory ( "3.0" ) )
203+ . Build ( ) ;
204+
205+ var response = await api . AccountsClient ( ) . CreateEntity ( request ) ;
103206
104207 response . ShouldNotBeNull ( ) ;
105208 response . Id . ShouldNotBeNullOrEmpty ( ) ;
@@ -412,13 +515,6 @@ private async Task ShouldCreateAndRetrievePaymentInstrumentCompany()
412515 queryResponse . Data . ShouldNotBeNull ( ) ;
413516 }
414517
415- private static string RandomString ( int length )
416- {
417- const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
418- return new string ( Enumerable . Repeat ( chars , length )
419- . Select ( s => s [ Random . Next ( s . Length ) ] ) . ToArray ( ) ) ;
420- }
421-
422518 private static ContactDetails BuildContactDetails ( )
423519 {
424520 return new ContactDetails
0 commit comments