-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds merchant adapter for pos and merchant operations (#148)
- Loading branch information
1 parent
fdf6dee
commit d2da746
Showing
29 changed files
with
712 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package io.craftgate.adapter; | ||
|
||
import io.craftgate.model.PosStatus; | ||
import io.craftgate.net.HttpClient; | ||
import io.craftgate.request.CreateMerchantPosRequest; | ||
import io.craftgate.request.SearchMerchantPosRequest; | ||
import io.craftgate.request.UpdateMerchantPosCommissionsRequest; | ||
import io.craftgate.request.UpdateMerchantPosRequest; | ||
import io.craftgate.request.common.RequestOptions; | ||
import io.craftgate.request.common.RequestQueryParamsBuilder; | ||
import io.craftgate.response.MerchantPosCommissionListResponse; | ||
import io.craftgate.response.MerchantPosListResponse; | ||
import io.craftgate.response.MerchantPosResponse; | ||
|
||
public class MerchantAdapter extends BaseAdapter { | ||
|
||
public MerchantAdapter(RequestOptions requestOptions) { | ||
super(requestOptions); | ||
} | ||
|
||
public MerchantPosResponse createMerchantPos(CreateMerchantPosRequest createMerchantPosRequest) { | ||
String path = "/merchant/v1/merchant-poses"; | ||
return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(createMerchantPosRequest, path, requestOptions), | ||
createMerchantPosRequest, MerchantPosResponse.class); | ||
} | ||
|
||
public MerchantPosResponse updateMerchantPos(Long merchantPosId, UpdateMerchantPosRequest updateMerchantPosRequest) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId; | ||
return HttpClient.put(requestOptions.getBaseUrl() + path, createHeaders(updateMerchantPosRequest, path, requestOptions), | ||
updateMerchantPosRequest, MerchantPosResponse.class); | ||
} | ||
|
||
public void updateMerchantPosStatus(Long merchantPosId, PosStatus posStatus) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId + "/status/" + posStatus.name(); | ||
HttpClient.put(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), Void.class); | ||
} | ||
|
||
public MerchantPosListResponse searchMerchantPos(SearchMerchantPosRequest searchMerchantPosRequest) { | ||
String query = RequestQueryParamsBuilder.buildQueryParam(searchMerchantPosRequest); | ||
String path = "/merchant/v1/merchant-poses" + query; | ||
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), MerchantPosListResponse.class); | ||
} | ||
|
||
public MerchantPosResponse retrieve(Long merchantPosId) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId; | ||
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), MerchantPosResponse.class); | ||
} | ||
|
||
public void deleteMerchantPos(Long merchantPosId) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId; | ||
HttpClient.delete(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions)); | ||
} | ||
|
||
public MerchantPosCommissionListResponse retrieveMerchantPosCommissions(Long merchantPosId) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId + "/commissions"; | ||
return HttpClient.get(requestOptions.getBaseUrl() + path, createHeaders(path, requestOptions), MerchantPosCommissionListResponse.class); | ||
} | ||
/* | ||
* This endpoint using for creating and updating merchant pos commissions. The HTTP method is POST due to this requirement. | ||
* */ | ||
public MerchantPosCommissionListResponse updateMerchantPosCommissions(Long merchantPosId, UpdateMerchantPosCommissionsRequest updateMerchantPosCommissionsRequest) { | ||
String path = "/merchant/v1/merchant-poses/" + merchantPosId + "/commissions"; | ||
return HttpClient.post(requestOptions.getBaseUrl() + path, createHeaders(updateMerchantPosCommissionsRequest, path, requestOptions), updateMerchantPosCommissionsRequest, MerchantPosCommissionListResponse.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.craftgate.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class AutopilotState { | ||
private Boolean isThreeDsUp; | ||
private Boolean isNonThreeDsUp; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.craftgate.model; | ||
|
||
public enum CardBrand { | ||
BONUS("Bonus"), | ||
AXESS("Axess"), | ||
MAXIMUM("Maximum"), | ||
WORLD("World"), | ||
PARAF("Paraf"), | ||
CARD_FINANS("CardFinans"), | ||
BANKKART_COMBO("Bankkart Combo"), | ||
ADVANTAGE("Advantage"), | ||
SAGLAM_KART("Sağlam Kart"); | ||
|
||
private final String cardBrandName; | ||
|
||
CardBrand(String cardBrandName) { | ||
this.cardBrandName = cardBrandName; | ||
} | ||
|
||
public String toName() { | ||
return this.cardBrandName; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/io/craftgate/model/PaymentAuthenticationType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.craftgate.model; | ||
|
||
public enum PaymentAuthenticationType { | ||
|
||
THREE_DS, | ||
NON_THREE_DS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.craftgate.model; | ||
|
||
public enum PosIntegrator { | ||
|
||
YKB, | ||
GARANTI, | ||
ISBANK, | ||
AKBANK, | ||
ZIRAATBANK, | ||
ZIRAATBANK_INNOVA, | ||
ZIRAATKATILIM, | ||
KUVEYTTURK, | ||
HALKBANK, | ||
DENIZBANK, | ||
VAKIFBANK, | ||
VAKIFKATILIM, | ||
FINANSBANK, | ||
FIBABANK, | ||
FIBABANK_ASSECO, | ||
ANADOLUBANK, | ||
PARAM_POS, | ||
IYZICO, | ||
SIPAY, | ||
PAYNET, | ||
PAYTR, | ||
BIRLESIK_ODEME, | ||
MOKA, | ||
STRIPE, | ||
TEB, | ||
IPARA, | ||
OZAN, | ||
BRAINTREE, | ||
NKOLAY, | ||
PAYTABS, | ||
PAYBULL, | ||
ELEKSE, | ||
ALGORITMA, | ||
PAYCELL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.craftgate.model; | ||
|
||
public enum PosOperationType { | ||
|
||
STANDARD, | ||
PROVAUT, | ||
PROVRFN, | ||
PAYMENT, | ||
REFUND, | ||
INQUIRY | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.craftgate.model; | ||
|
||
public enum PosStatus { | ||
|
||
DELETED, | ||
PASSIVE, | ||
ACTIVE, | ||
REFUND_ONLY, | ||
AUTOPILOT; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package io.craftgate.model; | ||
|
||
public enum PosUserType { | ||
API | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/io/craftgate/request/CreateMerchantPosRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.craftgate.request; | ||
|
||
import io.craftgate.model.Currency; | ||
import io.craftgate.model.PaymentAuthenticationType; | ||
import io.craftgate.model.PosIntegrator; | ||
import io.craftgate.model.PosStatus; | ||
import io.craftgate.request.dto.CreateMerchantPosUser; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
public class CreateMerchantPosRequest { | ||
|
||
@Builder.Default | ||
private PosStatus status = PosStatus.AUTOPILOT; | ||
private String name; | ||
private String clientId; | ||
private Currency currency; | ||
private String posnetId; | ||
private String terminalId; | ||
private String threedsPosnetId; | ||
private String threedsTerminalId; | ||
private String threedsKey; | ||
private Boolean enableForeignCard; | ||
private Boolean enableInstallment; | ||
private Boolean enablePaymentWithoutCvc; | ||
private Boolean newIntegration; | ||
private Integer orderNumber; | ||
private PosIntegrator posIntegrator; | ||
private List<PaymentAuthenticationType> enabledPaymentAuthenticationTypes; | ||
private List<CreateMerchantPosUser> merchantPosUsers; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/craftgate/request/CreateMerchantRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.craftgate.request; | ||
|
||
import lombok.Data; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Data | ||
@SuperBuilder | ||
public class CreateMerchantRequest { | ||
|
||
private String name; | ||
private String legalCompanyTitle; | ||
private String email; | ||
private String secretWord; | ||
private String website; | ||
private String phoneNumber; | ||
private String contactName; | ||
private String contactSurname; | ||
private String contactPhoneNumber; | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/io/craftgate/request/SearchMerchantPosRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.craftgate.request; | ||
|
||
import io.craftgate.model.Currency; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class SearchMerchantPosRequest { | ||
private String name; | ||
private String alias; | ||
private Currency currency; | ||
private Boolean enableInstallment; | ||
private Boolean enableForeignCard; | ||
private String bankName; | ||
private Integer page; | ||
private Integer size; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/io/craftgate/request/UpdateMerchantPosCommissionsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.craftgate.request; | ||
|
||
import io.craftgate.request.dto.UpdateMerchantPosCommission; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
public class UpdateMerchantPosCommissionsRequest { | ||
|
||
private List<UpdateMerchantPosCommission> commissions; | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/io/craftgate/request/UpdateMerchantPosRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.craftgate.request; | ||
|
||
import io.craftgate.model.CardAssociation; | ||
import io.craftgate.model.PaymentAuthenticationType; | ||
import io.craftgate.request.dto.UpdateMerchantPosUser; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
public class UpdateMerchantPosRequest { | ||
private String name; | ||
private String hostname; | ||
private String clientId; | ||
private String mode; | ||
private String path; | ||
private Integer port; | ||
private String posnetId; | ||
private String terminalId; | ||
private String threedsPosnetId; | ||
private String threedsTerminalId; | ||
private String threedsKey; | ||
private String threedsPath; | ||
private Boolean enableForeignCard; | ||
private Boolean enableInstallment; | ||
private Boolean enablePaymentWithoutCvc; | ||
private Boolean newIntegration; | ||
private Integer orderNumber; | ||
private List<CardAssociation> supportedCardAssociations; | ||
private List<PaymentAuthenticationType> enabledPaymentAuthenticationTypes; | ||
private List<UpdateMerchantPosUser> merchantPosUsers; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/io/craftgate/request/dto/CreateMerchantPosUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.craftgate.request.dto; | ||
|
||
import io.craftgate.model.PosOperationType; | ||
import io.craftgate.model.PosUserType; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class CreateMerchantPosUser { | ||
private String posUsername; | ||
private String posPassword; | ||
private PosUserType posUserType; | ||
private PosOperationType posOperationType; | ||
} |
Oops, something went wrong.