@@ -1124,6 +1124,110 @@ void complete_edenred_apm_payment() {
11241124 assertEquals (PaymentStatus .SUCCESS , response .getPaymentStatus ());
11251125 }
11261126
1127+ @ Test
1128+ void init_tokenflex_apm_payment () {
1129+ List <PaymentItem > items = new ArrayList <>();
1130+
1131+ items .add (PaymentItem .builder ()
1132+ .name ("item 1" )
1133+ .externalId (UUID .randomUUID ().toString ())
1134+ .price (BigDecimal .valueOf (0.60 ))
1135+ .build ());
1136+
1137+ items .add (PaymentItem .builder ()
1138+ .name ("item 2" )
1139+ .externalId (UUID .randomUUID ().toString ())
1140+ .price (BigDecimal .valueOf (0.40 ))
1141+ .build ());
1142+
1143+ InitApmPaymentRequest request = InitApmPaymentRequest .builder ()
1144+ .apmType (ApmType .TOKENFLEX )
1145+ .price (BigDecimal .valueOf (1 ))
1146+ .paidPrice (BigDecimal .valueOf (1 ))
1147+ .currency (Currency .TRY )
1148+ .paymentGroup (PaymentGroup .LISTING_OR_SUBSCRIPTION )
1149+ .conversationId ("456d1297-908e-4bd6-a13b-4be31a6e47d5" )
1150+ .externalId ("optional-externalId" )
1151+ .callbackUrl ("https://www.your-website.com/craftgate-apm-callback" )
1152+ .additionalParams (new HashMap <String , String >() {{
1153+ put ("paymentCode" , "123456" );
1154+ }})
1155+ .items (items )
1156+ .build ();
1157+
1158+ ApmPaymentInitResponse response = craftgate .payment ().initApmPayment (request );
1159+ assertNotNull (response .getPaymentId ());
1160+ assertNull (response .getRedirectUrl ());
1161+ assertEquals (PaymentStatus .WAITING , response .getPaymentStatus ());
1162+ assertEquals (ApmAdditionalAction .OTP_REQUIRED , response .getAdditionalAction ());
1163+ }
1164+
1165+ @ Test
1166+ void complete_tokenflex_apm_payment () {
1167+ CompleteApmPaymentRequest request = CompleteApmPaymentRequest .builder ()
1168+ .paymentId (1L )
1169+ .additionalParams (new HashMap <String , String >() {{
1170+ put ("otpCode" , "784294" );
1171+ }})
1172+ .build ();
1173+
1174+ ApmPaymentCompleteResponse response = craftgate .payment ().completeApmPayment (request );
1175+ assertNotNull (response .getPaymentId ());
1176+ assertEquals (PaymentStatus .SUCCESS , response .getPaymentStatus ());
1177+ }
1178+
1179+ @ Test
1180+ void init_tokenflex_gift_apm_payment () {
1181+ List <PaymentItem > items = new ArrayList <>();
1182+
1183+ items .add (PaymentItem .builder ()
1184+ .name ("item 1" )
1185+ .externalId (UUID .randomUUID ().toString ())
1186+ .price (BigDecimal .valueOf (0.60 ))
1187+ .build ());
1188+
1189+ items .add (PaymentItem .builder ()
1190+ .name ("item 2" )
1191+ .externalId (UUID .randomUUID ().toString ())
1192+ .price (BigDecimal .valueOf (0.40 ))
1193+ .build ());
1194+
1195+ InitApmPaymentRequest request = InitApmPaymentRequest .builder ()
1196+ .apmType (ApmType .TOKENFLEX_GIFT )
1197+ .price (BigDecimal .valueOf (1 ))
1198+ .paidPrice (BigDecimal .valueOf (1 ))
1199+ .currency (Currency .TRY )
1200+ .paymentGroup (PaymentGroup .LISTING_OR_SUBSCRIPTION )
1201+ .conversationId ("456d1297-908e-4bd6-a13b-4be31a6e47d5" )
1202+ .externalId ("optional-externalId" )
1203+ .callbackUrl ("https://www.your-website.com/craftgate-apm-callback" )
1204+ .additionalParams (new HashMap <String , String >() {{
1205+ put ("paymentCode" , "123456" );
1206+ }})
1207+ .items (items )
1208+ .build ();
1209+
1210+ ApmPaymentInitResponse response = craftgate .payment ().initApmPayment (request );
1211+ assertNotNull (response .getPaymentId ());
1212+ assertNull (response .getRedirectUrl ());
1213+ assertEquals (PaymentStatus .WAITING , response .getPaymentStatus ());
1214+ assertEquals (ApmAdditionalAction .OTP_REQUIRED , response .getAdditionalAction ());
1215+ }
1216+
1217+ @ Test
1218+ void complete_tokenflex_gift_apm_payment () {
1219+ CompleteApmPaymentRequest request = CompleteApmPaymentRequest .builder ()
1220+ .paymentId (1L )
1221+ .additionalParams (new HashMap <String , String >() {{
1222+ put ("otpCode" , "784294" );
1223+ }})
1224+ .build ();
1225+
1226+ ApmPaymentCompleteResponse response = craftgate .payment ().completeApmPayment (request );
1227+ assertNotNull (response .getPaymentId ());
1228+ assertEquals (PaymentStatus .SUCCESS , response .getPaymentStatus ());
1229+ }
1230+
11271231 @ Test
11281232 void init_paypal_apm_payment () {
11291233 List <PaymentItem > items = new ArrayList <>();
0 commit comments