@@ -47,6 +47,7 @@ public abstract class BaseTest {
47
47
private static UboDeclaration UBO_DECLARATION ;
48
48
private static PayInTemplateURLOptions PAYIN_TEMPLATE_URL_OPTIONS ;
49
49
private static VirtualAccount JOHNS_VIRTUAL_ACCOUNT ;
50
+ private static Mandate MANDATE ;
50
51
51
52
public BaseTest () {
52
53
this .api = buildNewMangoPayApi ();
@@ -259,32 +260,6 @@ protected UserNaturalSca getJohnScaPayer(Boolean recreate, Boolean termsAccepted
259
260
return BaseTest .JOHN_SCA_PAYER ;
260
261
}
261
262
262
- protected UserNatural getNewDeclarativeJohn () throws Exception {
263
- return getNewJohn (true );
264
- }
265
-
266
- protected UserNatural getNewJohn (boolean declarative ) throws Exception {
267
-
268
- Calendar c = Calendar .getInstance ();
269
- c .set (1975 , 12 , 21 , 0 , 0 , 0 );
270
-
271
- UserNatural user = new UserNatural ();
272
- user .setFirstName ("John" );
273
- user .setLastName ("Doe" );
274
- user .setEmail ("john.doe@sample.org" );
275
- user .setAddress (this .getNewAddress ());
276
- user .setBirthday (c .getTimeInMillis () / 1000 );
277
- user .setNationality (CountryIso .FR );
278
- user .setCountryOfResidence (CountryIso .FR );
279
- user .setOccupation ("programmer" );
280
- user .setIncomeRange (3 );
281
- user .setUserCategory (UserCategory .OWNER );
282
- if (declarative ) {
283
- user .setCapacity (NaturalUserCapacity .DECLARATIVE );
284
- }
285
- return (UserNatural ) this .api .getUserApi ().create (user );
286
- }
287
-
288
263
protected UserLegal getMatrix (UserCategory userCategory ) throws Exception {
289
264
switch (userCategory ) {
290
265
case OWNER :
@@ -471,7 +446,7 @@ protected Wallet getJohnsWallet() throws Exception {
471
446
* @return Wallet instance loaded with 10k EUR.
472
447
*/
473
448
protected Wallet getJohnsWalletWithMoney () throws Exception {
474
- return getJohnsWalletWithMoney (500 );
449
+ return getJohnsWalletWithMoney (1000 );
475
450
}
476
451
477
452
/**
@@ -1912,13 +1887,15 @@ protected Conversion createQuotedConversion() throws Exception {
1912
1887
1913
1888
Wallet debitedWallet = getJohnsWalletWithMoney ();
1914
1889
ConversionQuote quote = createConversionQuote ();
1890
+ System .out .println ("quote created" );
1915
1891
1916
1892
CreateQuotedConversion quotedConversion = new CreateQuotedConversion ();
1917
1893
quotedConversion .setQuoteId (quote .getId ());
1918
1894
quotedConversion .setAuthorId (debitedWallet .getOwners ().get (0 ));
1919
1895
quotedConversion .setCreditedWalletId (creditedWallet .getId ());
1920
1896
quotedConversion .setDebitedWalletId (debitedWallet .getId ());
1921
1897
1898
+ System .out .println ("creating conversion quote" );
1922
1899
return this .api .getConversionsApi ().createQuotedConversion (quotedConversion , null );
1923
1900
}
1924
1901
@@ -1937,12 +1914,48 @@ protected ConversionQuote createConversionQuote() throws Exception {
1937
1914
1938
1915
Money debitedFunds = new Money ();
1939
1916
debitedFunds .setCurrency (CurrencyIso .EUR );
1940
- debitedFunds .setAmount (50 );
1917
+ debitedFunds .setAmount (1 );
1941
1918
conversionQuote .setDebitedFunds (debitedFunds );
1942
1919
1943
- conversionQuote .setDuration (90 );
1920
+ conversionQuote .setDuration (300 );
1944
1921
conversionQuote .setTag ("Created using the Mangopay PHP SDK" );
1945
1922
1946
1923
return this .api .getConversionsApi ().createConversionQuote (conversionQuote , null );
1947
1924
}
1925
+
1926
+ protected Mandate createMandate (Boolean recreate ) throws Exception {
1927
+ if (BaseTest .MANDATE == null || recreate ) {
1928
+ Mandate mandatePost = new Mandate ();
1929
+ mandatePost .setBankAccountId (this .getJohnsAccount ().getId ());
1930
+ mandatePost .setReturnUrl ("http://test.test" );
1931
+ mandatePost .setCulture (CultureCode .EN );
1932
+
1933
+ BaseTest .MANDATE = this .api .getMandateApi ().create (mandatePost );
1934
+ }
1935
+ return BaseTest .MANDATE ;
1936
+ }
1937
+
1938
+ public PayIn createDirectDebitDirect () throws Exception {
1939
+ Wallet wallet = this .getJohnsWallet ();
1940
+ UserNatural user = this .getJohn ();
1941
+
1942
+ Mandate mandate = this .createMandate (false );
1943
+
1944
+ PayIn payIn = new PayIn ();
1945
+ payIn .setAuthorId (user .getId ());
1946
+ payIn .setDebitedFunds (new Money ());
1947
+ payIn .getDebitedFunds ().setAmount (10 );
1948
+ payIn .getDebitedFunds ().setCurrency (CurrencyIso .EUR );
1949
+ payIn .setFees (new Money ());
1950
+ payIn .getFees ().setAmount (0 );
1951
+ payIn .getFees ().setCurrency (CurrencyIso .EUR );
1952
+ payIn .setCreditedWalletId (wallet .getId ());
1953
+ PayInPaymentDetailsDirectDebit paymentDetails = new PayInPaymentDetailsDirectDebit ();
1954
+ paymentDetails .setMandateId (mandate .getId ());
1955
+ payIn .setPaymentDetails (paymentDetails );
1956
+ PayInExecutionDetailsDirect executionDetails = new PayInExecutionDetailsDirect ();
1957
+ payIn .setExecutionDetails (executionDetails );
1958
+
1959
+ return this .api .getPayInApi ().create (payIn );
1960
+ }
1948
1961
}
0 commit comments