From 60a73df2c14f3184dcd983f1a604aee0fb94d771 Mon Sep 17 00:00:00 2001 From: abdurrahman <57454378+abdurrahman98@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:09:44 +0300 Subject: [PATCH] Feature/DEV-23903 Changes getHeadersV2 parameter to path instead of url (#155) * DEV-23903 Transition from header V1 to header V2 * DEV-23903 remove unused import * DEV-23903 Changes getHeadersV2 parameter to path instead of uri * DEV-23903 Changes parameter name uri to path * DEV-23903 Adds response checksum signature * DEV-23903 Changes response field checksum to signature --------- Co-authored-by: Abdurrahman Basgoynuk --- src/main/java/com/iyzipay/HashValidator.java | 13 +++++ .../java/com/iyzipay/IyziAuthV2Generator.java | 15 +++--- .../java/com/iyzipay/IyzipayResource.java | 12 +++-- .../iyzipay/ResponseSignatureGenerator.java | 50 +++++++++++++++++++ src/main/java/com/iyzipay/model/Apm.java | 29 +++++++++-- .../java/com/iyzipay/model/ApmResource.java | 9 ++++ src/main/java/com/iyzipay/model/Approval.java | 5 +- src/main/java/com/iyzipay/model/BasicBkm.java | 5 +- .../com/iyzipay/model/BasicBkmInitialize.java | 5 +- .../java/com/iyzipay/model/BasicPayment.java | 5 +- .../iyzipay/model/BasicPaymentPostAuth.java | 5 +- .../iyzipay/model/BasicPaymentPreAuth.java | 5 +- .../iyzipay/model/BasicThreedsInitialize.java | 5 +- .../model/BasicThreedsInitializePreAuth.java | 5 +- .../iyzipay/model/BasicThreedsPayment.java | 5 +- .../java/com/iyzipay/model/BinNumber.java | 5 +- src/main/java/com/iyzipay/model/Bkm.java | 19 +++++-- .../java/com/iyzipay/model/BkmInitialize.java | 25 ++++++++-- .../model/BouncedBankTransferList.java | 5 +- src/main/java/com/iyzipay/model/Cancel.java | 5 +- src/main/java/com/iyzipay/model/Card.java | 10 ++-- .../java/com/iyzipay/model/CardBlacklist.java | 15 +++--- src/main/java/com/iyzipay/model/CardList.java | 5 +- .../iyzipay/model/CardManagementPageCard.java | 5 +- .../model/CardManagementPageInitialize.java | 5 +- .../java/com/iyzipay/model/CheckoutForm.java | 19 +++++-- .../iyzipay/model/CheckoutFormInitialize.java | 17 +++++-- .../model/CheckoutFormInitializePreAuth.java | 17 +++++-- .../model/CheckoutFormInitializeResource.java | 9 ++++ .../model/CrossBookingFromSubMerchant.java | 5 +- .../model/CrossBookingToSubMerchant.java | 5 +- .../java/com/iyzipay/model/Disapproval.java | 5 +- .../com/iyzipay/model/InstallmentInfo.java | 5 +- .../java/com/iyzipay/model/IyziupForm.java | 5 +- .../iyzipay/model/IyziupFormInitialize.java | 5 +- .../model/PayWithIyzicoInitialize.java | 19 +++++-- .../PayWithIyzicoInitializeResource.java | 9 ++++ src/main/java/com/iyzipay/model/Payment.java | 23 +++++++-- .../java/com/iyzipay/model/PaymentItem.java | 5 +- .../com/iyzipay/model/PaymentPostAuth.java | 18 +++++-- .../com/iyzipay/model/PaymentPreAuth.java | 24 +++++++-- .../com/iyzipay/model/PaymentResource.java | 9 ++++ .../model/PayoutCompletedTransactionList.java | 5 +- src/main/java/com/iyzipay/model/Refund.java | 5 +- .../model/RefundChargedFromMerchant.java | 5 +- .../iyzipay/model/ReportingPaymentDetail.java | 5 +- .../model/ReportingPaymentTransaction.java | 5 +- .../java/com/iyzipay/model/SubMerchant.java | 15 +++--- .../com/iyzipay/model/ThreedsInitialize.java | 35 +++++++++++-- .../model/ThreedsInitializePreAuth.java | 35 +++++++++++-- .../com/iyzipay/model/ThreedsPayment.java | 28 ++++++++--- .../com/iyzipay/model/iyzilink/IyziLink.java | 19 ++++--- .../iyzipay/model/loyalty/LoyaltyInquire.java | 5 +- .../SubMerchantOnboardingInitialize.java | 5 +- .../SubMerchantOnboardingVerify.java | 5 +- .../model/subscription/Subscription.java | 5 +- ...ptionCardUpdateCheckoutFormInitialize.java | 10 ++-- .../SubscriptionCheckoutForm.java | 5 +- .../SubscriptionCheckoutFormInitialize.java | 5 +- .../subscription/SubscriptionCustomer.java | 20 +++++--- .../SubscriptionCustomerList.java | 5 +- .../subscription/SubscriptionInitialize.java | 10 ++-- .../subscription/SubscriptionOperation.java | 20 +++++--- .../model/subscription/SubscriptionOrder.java | 5 +- .../subscription/SubscriptionPricingPlan.java | 20 +++++--- .../SubscriptionPricingPlanList.java | 5 +- .../subscription/SubscriptionProduct.java | 20 +++++--- .../subscription/SubscriptionProductList.java | 5 +- .../subscription/SubscriptionSearch.java | 5 +- .../universalcardstorage/UcsInitResource.java | 5 +- .../com/iyzipay/functional/ApprovalTest.java | 2 + .../java/com/iyzipay/functional/BkmTest.java | 1 + .../iyzipay/functional/CheckoutFormTest.java | 2 + .../iyzipay/functional/DisapproveTest.java | 2 + .../com/iyzipay/functional/IyziLinkTest.java | 1 - .../com/iyzipay/functional/PaymentTest.java | 5 ++ .../com/iyzipay/functional/RefundTest.java | 2 + .../com/iyzipay/functional/ThreedsTest.java | 3 ++ .../java/com/iyzipay/sample/ApmSample.java | 2 + .../java/com/iyzipay/sample/BkmSample.java | 3 ++ .../iyzipay/sample/CheckoutFormSample.java | 3 ++ .../iyzipay/sample/PayWithIyzicoSample.java | 2 + .../com/iyzipay/sample/PaymentSample.java | 7 +++ .../com/iyzipay/sample/ThreedsSample.java | 5 ++ 84 files changed, 624 insertions(+), 204 deletions(-) create mode 100644 src/main/java/com/iyzipay/HashValidator.java create mode 100644 src/main/java/com/iyzipay/ResponseSignatureGenerator.java diff --git a/src/main/java/com/iyzipay/HashValidator.java b/src/main/java/com/iyzipay/HashValidator.java new file mode 100644 index 00000000..89f667e2 --- /dev/null +++ b/src/main/java/com/iyzipay/HashValidator.java @@ -0,0 +1,13 @@ +package com.iyzipay; + + +import org.apache.commons.lang3.StringUtils; + +public class HashValidator { + private HashValidator() { + } + + public static boolean hashValid(String calculatedHash, String hash) { + return StringUtils.equals(calculatedHash, hash); + } +} diff --git a/src/main/java/com/iyzipay/IyziAuthV2Generator.java b/src/main/java/com/iyzipay/IyziAuthV2Generator.java index a126a557..4a8d4336 100644 --- a/src/main/java/com/iyzipay/IyziAuthV2Generator.java +++ b/src/main/java/com/iyzipay/IyziAuthV2Generator.java @@ -15,18 +15,18 @@ public final class IyziAuthV2Generator { private IyziAuthV2Generator() { } - public static String generateAuthContent(String uri, String apiKey, String secretKey, String randomString, Object request) { + public static String generateAuthContent(String path, String apiKey, String secretKey, String randomString, Object request) { try { - String input = "apiKey:" + apiKey + "&randomKey:" + randomString + "&signature:" + getHmacSHA256Signature(uri, secretKey, randomString, request); + String input = "apiKey:" + apiKey + "&randomKey:" + randomString + "&signature:" + getHmacSHA256Signature(path, secretKey, randomString, request); return DatatypeConverter.printBase64Binary(input.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new HttpClientException("Authentication content couldn't be generated", e); } } - private static String getHmacSHA256Signature(String uri, String secretKey, String randomString, Object request) { + private static String getHmacSHA256Signature(String path, String secretKey, String randomString, Object request) { try { - String dataToSign = randomString + getPayload(uri, request); + String dataToSign = randomString + getPayload(path, request); Mac mac = Mac.getInstance("HmacSHA256"); mac.init(new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256")); return DatatypeConverter.printHexBinary(mac.doFinal(dataToSign.getBytes("UTF-8"))).toLowerCase(); @@ -39,10 +39,7 @@ private static String getHmacSHA256Signature(String uri, String secretKey, Strin } } - private static String getPayload(String uri, Object request) { - int startIndex = uri.indexOf("/v2"); - int endIndex = uri.indexOf("?"); - String uriPath = endIndex == -1 ? uri.substring(startIndex) : uri.substring(startIndex, endIndex); - return request == null ? uriPath : uriPath + new Gson().toJson(request); + private static String getPayload(String path, Object request) { + return request == null ? path : path + new Gson().toJson(request); } } \ No newline at end of file diff --git a/src/main/java/com/iyzipay/IyzipayResource.java b/src/main/java/com/iyzipay/IyzipayResource.java index ef46ef94..7eb61b23 100644 --- a/src/main/java/com/iyzipay/IyzipayResource.java +++ b/src/main/java/com/iyzipay/IyzipayResource.java @@ -20,6 +20,7 @@ public class IyzipayResource { private static final String CLIENT_VERSION_HEADER_NAME = "x-iyzi-client-version"; private static final String IYZIWS_HEADER_NAME = "IYZWS "; private static final String IYZIWS_V2_HEADER_NAME = "IYZWSv2 "; + private static final String AUTHORIZATION_FALLBACK_HEADER = "Authorization_Fallback"; private static final String CLIENT_VERSION = IyzipayResource.class.getPackage().getImplementationVersion(); private static final String CLIENT_TITLE = IyzipayResource.class.getPackage().getImplementationTitle(); private static final String COLON = ":"; @@ -36,6 +37,7 @@ public class IyzipayResource { public IyzipayResource() { } + @Deprecated protected static Map getHttpHeaders(Request request, Options options) { Map headers = new HashMap(); @@ -47,11 +49,13 @@ protected static Map getHttpHeaders(Request request, Options opt return headers; } - protected static Map getHttpHeadersV2(String uri, Request request, Options options) { + protected static Map getHttpHeadersV2(String path, Request request, Options options) { Map headers = new HashMap(); String randomString = UUID.randomUUID().toString(); - headers.put(AUTHORIZATION, prepareAuthorizationStringV2(uri, request, randomString, options)); + headers.put(AUTHORIZATION, prepareAuthorizationStringV2(path, request, randomString, options)); + headers.put(RANDOM_HEADER_NAME, randomString); + headers.put(AUTHORIZATION_FALLBACK_HEADER, prepareAuthorizationString(request, randomString, options)); putClientVersionHeader(headers); return headers; @@ -75,8 +79,8 @@ private static String prepareAuthorizationString(Request request, String randomS return IYZIWS_HEADER_NAME + options.getApiKey() + COLON + hash; } - private static String prepareAuthorizationStringV2(String uri, Request request, String randomString, Options options) { - String authContent = IyziAuthV2Generator.generateAuthContent(uri, options.getApiKey(), options.getSecretKey(), randomString, request); + private static String prepareAuthorizationStringV2(String path, Request request, String randomString, Options options) { + String authContent = IyziAuthV2Generator.generateAuthContent(path, options.getApiKey(), options.getSecretKey(), randomString, request); return IYZIWS_V2_HEADER_NAME + authContent; } diff --git a/src/main/java/com/iyzipay/ResponseSignatureGenerator.java b/src/main/java/com/iyzipay/ResponseSignatureGenerator.java new file mode 100644 index 00000000..bebeaca4 --- /dev/null +++ b/src/main/java/com/iyzipay/ResponseSignatureGenerator.java @@ -0,0 +1,50 @@ +package com.iyzipay; + +import com.iyzipay.exception.HttpClientException; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; +import javax.xml.bind.DatatypeConverter; +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.stream.Collectors; + +public interface ResponseSignatureGenerator { + String SEPARATOR = ":"; + String HMAC_SHA_256 = "HmacSHA256"; + String EMPTY_PARAM = ""; + + default String generateSignature(String secretKey, List params) { + try { + String dataToSign = appendSignatureParams(params); + Mac mac = Mac.getInstance(HMAC_SHA_256); + mac.init(new SecretKeySpec(secretKey.getBytes(StandardCharsets.UTF_8), HMAC_SHA_256)); + return DatatypeConverter.printHexBinary(mac.doFinal(dataToSign.getBytes(StandardCharsets.UTF_8))).toLowerCase(Locale.ENGLISH); + } catch (NoSuchAlgorithmException e) { + throw new HttpClientException("HMAC couldn't be generated", e); + } catch (InvalidKeyException e) { + throw new HttpClientException("Authentication content couldn't be generated", e); + } + } + + default String appendSignatureParams(List signatureParameters) { + return signatureParameters.stream() + .map(this::convertParamToString) + .collect(Collectors.joining(SEPARATOR)); + } + + default String convertParamToString(Object parameter) { + if (Objects.isNull(parameter)) { + return EMPTY_PARAM; + } else if (parameter instanceof BigDecimal) { + return ((BigDecimal) parameter).stripTrailingZeros().toPlainString(); + } else { + return parameter.toString(); + } + } +} diff --git a/src/main/java/com/iyzipay/model/Apm.java b/src/main/java/com/iyzipay/model/Apm.java index b6de2d60..1ac2600a 100644 --- a/src/main/java/com/iyzipay/model/Apm.java +++ b/src/main/java/com/iyzipay/model/Apm.java @@ -1,24 +1,43 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreateApmInitializeRequest; import com.iyzipay.request.RetrieveApmRequest; -public class Apm extends ApmResource { +import java.util.Arrays; + +public class Apm extends ApmResource implements ResponseSignatureGenerator { + + public boolean verifySignatureForCreate(String secretKey) { + String calculated = generateSignature(secretKey, Arrays.asList(getPaymentId(), getRedirectUrl())); + return HashValidator.hashValid(getSignature(), calculated); + } public static Apm create(CreateApmInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/apm/initialize", + String path = "/payment/apm/initialize"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Apm.class); } + public boolean verifySignatureForRetrieve(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getCurrency(), getBasketId(), + getConversationId(), getPaidPrice(), + getPrice(), getPaymentId(), getRedirectUrl())); + return HashValidator.hashValid(getSignature(), calculated); + } + public static Apm retrieve(RetrieveApmRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/apm/retrieve", + String path = "/payment/apm/retrieve"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Apm.class); } diff --git a/src/main/java/com/iyzipay/model/ApmResource.java b/src/main/java/com/iyzipay/model/ApmResource.java index 5e25e130..1a5f8e9b 100644 --- a/src/main/java/com/iyzipay/model/ApmResource.java +++ b/src/main/java/com/iyzipay/model/ApmResource.java @@ -34,6 +34,7 @@ public class ApmResource extends IyzipayResource { private String apm; private String mobilePhone; private String paymentStatus; + private String signature; public String getRedirectUrl() { return redirectUrl; @@ -219,6 +220,14 @@ public void setPaymentStatus(String paymentStatus) { this.paymentStatus = paymentStatus; } + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); diff --git a/src/main/java/com/iyzipay/model/Approval.java b/src/main/java/com/iyzipay/model/Approval.java index 40b6291e..78601f75 100644 --- a/src/main/java/com/iyzipay/model/Approval.java +++ b/src/main/java/com/iyzipay/model/Approval.java @@ -10,9 +10,10 @@ public class Approval extends IyzipayResource { private String paymentTransactionId; public static Approval create(CreateApprovalRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/item/approve", + String path = "/payment/iyzipos/item/approve"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Approval.class); } diff --git a/src/main/java/com/iyzipay/model/BasicBkm.java b/src/main/java/com/iyzipay/model/BasicBkm.java index f6445d09..d34eb87b 100644 --- a/src/main/java/com/iyzipay/model/BasicBkm.java +++ b/src/main/java/com/iyzipay/model/BasicBkm.java @@ -11,9 +11,10 @@ public class BasicBkm extends BasicPaymentResource { private String paymentStatus; public static BasicBkm retrieve(RetrieveBkmRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/bkm/auth/detail/basic", + String path = "/payment/bkm/auth/detail/basic"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicBkm.class); } diff --git a/src/main/java/com/iyzipay/model/BasicBkmInitialize.java b/src/main/java/com/iyzipay/model/BasicBkmInitialize.java index d65157d0..cb2c65bc 100644 --- a/src/main/java/com/iyzipay/model/BasicBkmInitialize.java +++ b/src/main/java/com/iyzipay/model/BasicBkmInitialize.java @@ -12,9 +12,10 @@ public class BasicBkmInitialize extends IyzipayResource { private String token; public static BasicBkmInitialize create(CreateBasicBkmInitializeRequest request, Options options) { - BasicBkmInitialize response = HttpClient.create().post(options.getBaseUrl() + "/payment/bkm/initialize/basic", + String path = "/payment/bkm/initialize/basic"; + BasicBkmInitialize response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicBkmInitialize.class); if (response != null) { diff --git a/src/main/java/com/iyzipay/model/BasicPayment.java b/src/main/java/com/iyzipay/model/BasicPayment.java index d7176a4f..f1e5a569 100644 --- a/src/main/java/com/iyzipay/model/BasicPayment.java +++ b/src/main/java/com/iyzipay/model/BasicPayment.java @@ -7,9 +7,10 @@ public class BasicPayment extends BasicPaymentResource { public static BasicPayment create(CreateBasicPaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/auth/basic", + String path = "/payment/auth/basic"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicPayment.class); } diff --git a/src/main/java/com/iyzipay/model/BasicPaymentPostAuth.java b/src/main/java/com/iyzipay/model/BasicPaymentPostAuth.java index f3fedd82..30641bba 100644 --- a/src/main/java/com/iyzipay/model/BasicPaymentPostAuth.java +++ b/src/main/java/com/iyzipay/model/BasicPaymentPostAuth.java @@ -7,9 +7,10 @@ public class BasicPaymentPostAuth extends BasicPaymentResource { public static BasicPaymentPostAuth create(CreatePaymentPostAuthRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/postauth/basic", + String path = "/payment/postauth/basic"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicPaymentPostAuth.class); } diff --git a/src/main/java/com/iyzipay/model/BasicPaymentPreAuth.java b/src/main/java/com/iyzipay/model/BasicPaymentPreAuth.java index d6953cdf..6ec4438f 100644 --- a/src/main/java/com/iyzipay/model/BasicPaymentPreAuth.java +++ b/src/main/java/com/iyzipay/model/BasicPaymentPreAuth.java @@ -7,9 +7,10 @@ public class BasicPaymentPreAuth extends BasicPaymentResource { public static BasicPaymentPreAuth create(CreateBasicPaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/preauth/basic", + String path = "/payment/preauth/basic"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicPaymentPreAuth.class); } diff --git a/src/main/java/com/iyzipay/model/BasicThreedsInitialize.java b/src/main/java/com/iyzipay/model/BasicThreedsInitialize.java index 9dd85140..7721493c 100644 --- a/src/main/java/com/iyzipay/model/BasicThreedsInitialize.java +++ b/src/main/java/com/iyzipay/model/BasicThreedsInitialize.java @@ -13,9 +13,10 @@ public class BasicThreedsInitialize extends IyzipayResource { private String htmlContent; public static BasicThreedsInitialize create(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitialize response = HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/initialize/basic", + String path = "/payment/3dsecure/initialize/basic"; + BasicThreedsInitialize response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicThreedsInitialize.class); if (response != null) { diff --git a/src/main/java/com/iyzipay/model/BasicThreedsInitializePreAuth.java b/src/main/java/com/iyzipay/model/BasicThreedsInitializePreAuth.java index 3258cb2a..d09d32d2 100644 --- a/src/main/java/com/iyzipay/model/BasicThreedsInitializePreAuth.java +++ b/src/main/java/com/iyzipay/model/BasicThreedsInitializePreAuth.java @@ -13,9 +13,10 @@ public class BasicThreedsInitializePreAuth extends IyzipayResource { private String htmlContent; public static BasicThreedsInitializePreAuth create(CreateBasicPaymentRequest request, Options options) { - BasicThreedsInitializePreAuth response = HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/initialize/preauth/basic", + String path = "/payment/3dsecure/initialize/preauth/basic"; + BasicThreedsInitializePreAuth response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicThreedsInitializePreAuth.class); if (response != null) { diff --git a/src/main/java/com/iyzipay/model/BasicThreedsPayment.java b/src/main/java/com/iyzipay/model/BasicThreedsPayment.java index 5fbf83ab..a7af323a 100644 --- a/src/main/java/com/iyzipay/model/BasicThreedsPayment.java +++ b/src/main/java/com/iyzipay/model/BasicThreedsPayment.java @@ -7,9 +7,10 @@ public class BasicThreedsPayment extends BasicPaymentResource { public static BasicThreedsPayment create(CreateThreedsPaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/auth/basic", + String path = "/payment/3dsecure/auth/basic"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BasicThreedsPayment.class); } diff --git a/src/main/java/com/iyzipay/model/BinNumber.java b/src/main/java/com/iyzipay/model/BinNumber.java index 59ee8aab..24e4f194 100644 --- a/src/main/java/com/iyzipay/model/BinNumber.java +++ b/src/main/java/com/iyzipay/model/BinNumber.java @@ -16,9 +16,10 @@ public class BinNumber extends IyzipayResource { private Integer commercial; public static BinNumber retrieve(RetrieveBinNumberRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/bin/check", + String path = "/payment/bin/check"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BinNumber.class); } diff --git a/src/main/java/com/iyzipay/model/Bkm.java b/src/main/java/com/iyzipay/model/Bkm.java index 83805d39..d6cf5c44 100644 --- a/src/main/java/com/iyzipay/model/Bkm.java +++ b/src/main/java/com/iyzipay/model/Bkm.java @@ -1,18 +1,31 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.RetrieveBkmRequest; -public class Bkm extends PaymentResource { +import java.util.Arrays; + +public class Bkm extends PaymentResource implements ResponseSignatureGenerator { private String token; private String callbackUrl; + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getPaymentStatus(), + getBasketId(), getConversationId(), getCurrency(), + getPaidPrice(), getPrice(), getToken())); + return HashValidator.hashValid(getSignature(), calculated); + } + public static Bkm retrieve(RetrieveBkmRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/bkm/auth/detail", + String path = "/payment/bkm/auth/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Bkm.class); } diff --git a/src/main/java/com/iyzipay/model/BkmInitialize.java b/src/main/java/com/iyzipay/model/BkmInitialize.java index bb45c4ac..92df7550 100644 --- a/src/main/java/com/iyzipay/model/BkmInitialize.java +++ b/src/main/java/com/iyzipay/model/BkmInitialize.java @@ -1,20 +1,31 @@ package com.iyzipay.model; import com.iyzipay.DigestHelper; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.IyzipayResource; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreateBkmInitializeRequest; -public class BkmInitialize extends IyzipayResource { +import java.util.Arrays; + +public class BkmInitialize extends IyzipayResource implements ResponseSignatureGenerator { private String htmlContent; private String token; + private String signature; + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, Arrays.asList(getToken(), getConversationId())); + return HashValidator.hashValid(getSignature(), calculated); + } public static BkmInitialize create(CreateBkmInitializeRequest request, Options options) { - BkmInitialize response = HttpClient.create().post(options.getBaseUrl() + "/payment/bkm/initialize", + String path = "/payment/bkm/initialize"; + BkmInitialize response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BkmInitialize.class); if (response != null) { @@ -38,4 +49,12 @@ public String getToken() { public void setToken(String token) { this.token = token; } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } } diff --git a/src/main/java/com/iyzipay/model/BouncedBankTransferList.java b/src/main/java/com/iyzipay/model/BouncedBankTransferList.java index a95b8a71..e34993d3 100644 --- a/src/main/java/com/iyzipay/model/BouncedBankTransferList.java +++ b/src/main/java/com/iyzipay/model/BouncedBankTransferList.java @@ -14,9 +14,10 @@ public class BouncedBankTransferList extends IyzipayResource { private List bankTransfers; public static BouncedBankTransferList retrieve(RetrieveTransactionsRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/reporting/settlement/bounced", + String path = "/reporting/settlement/bounced"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, BouncedBankTransferList.class); } diff --git a/src/main/java/com/iyzipay/model/Cancel.java b/src/main/java/com/iyzipay/model/Cancel.java index e8ef6e15..238a9a7b 100644 --- a/src/main/java/com/iyzipay/model/Cancel.java +++ b/src/main/java/com/iyzipay/model/Cancel.java @@ -17,9 +17,10 @@ public class Cancel extends IyzipayResource { private String hostReference; public static Cancel create(CreateCancelRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/cancel", + String path = "/payment/cancel"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Cancel.class); } diff --git a/src/main/java/com/iyzipay/model/Card.java b/src/main/java/com/iyzipay/model/Card.java index 7523e190..5f6e82ac 100644 --- a/src/main/java/com/iyzipay/model/Card.java +++ b/src/main/java/com/iyzipay/model/Card.java @@ -28,17 +28,19 @@ public class Card extends IyzipayResource { private Map metadata; public static Card create(CreateCardRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/cardstorage/card", + String path = "/cardstorage/card"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Card.class); } public static Card delete(DeleteCardRequest request, Options options) { - return HttpClient.create().delete(options.getBaseUrl() + "/cardstorage/card", + String path = "/cardstorage/card"; + return HttpClient.create().delete(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Card.class); } diff --git a/src/main/java/com/iyzipay/model/CardBlacklist.java b/src/main/java/com/iyzipay/model/CardBlacklist.java index 88abade3..5baca37f 100644 --- a/src/main/java/com/iyzipay/model/CardBlacklist.java +++ b/src/main/java/com/iyzipay/model/CardBlacklist.java @@ -11,25 +11,28 @@ public class CardBlacklist extends IyzipayResource { private boolean blacklisted; public static IyzipayResource create(CardBlacklistRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/cardstorage/blacklist/card", + String path = "/cardstorage/blacklist/card"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, IyzipayResource.class); } public static IyzipayResource update(CardBlacklistRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/cardstorage/blacklist/card/inactive", + String path = "/cardstorage/blacklist/card/inactive"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, IyzipayResource.class); } public static CardBlacklist retrieve(RetrieveCardBlacklistRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/cardstorage/blacklist/card/retrieve", + String path = "/cardstorage/blacklist/card/retrieve"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CardBlacklist.class); } diff --git a/src/main/java/com/iyzipay/model/CardList.java b/src/main/java/com/iyzipay/model/CardList.java index 5e7f15c1..50652fd9 100644 --- a/src/main/java/com/iyzipay/model/CardList.java +++ b/src/main/java/com/iyzipay/model/CardList.java @@ -13,9 +13,10 @@ public class CardList extends IyzipayResource { private List cardDetails; public static CardList retrieve(RetrieveCardListRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/cardstorage/cards", + String path = "/cardstorage/cards"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CardList.class); } diff --git a/src/main/java/com/iyzipay/model/CardManagementPageCard.java b/src/main/java/com/iyzipay/model/CardManagementPageCard.java index 9387192e..d816b708 100644 --- a/src/main/java/com/iyzipay/model/CardManagementPageCard.java +++ b/src/main/java/com/iyzipay/model/CardManagementPageCard.java @@ -16,7 +16,7 @@ public class CardManagementPageCard extends IyzipayResource { public static CardManagementPageCard retrieve(RetrieveCardManagementPageCardRequest request, Options options) { return HttpClient.create().get(prepareRetrieveCardManagementPageCardRequest(request, options), getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(prepareRequestPath(request), request, options), request, CardManagementPageCard.class); } @@ -54,4 +54,7 @@ private static String prepareRetrieveCardManagementPageCardRequest(RetrieveCardM return sb.toString(); } + private static String prepareRequestPath(RetrieveCardManagementPageCardRequest request) { + return "/v1/card-management/pages/" + request.getPageToken() + "/cards"; + } } diff --git a/src/main/java/com/iyzipay/model/CardManagementPageInitialize.java b/src/main/java/com/iyzipay/model/CardManagementPageInitialize.java index de523d55..ff1a81bd 100644 --- a/src/main/java/com/iyzipay/model/CardManagementPageInitialize.java +++ b/src/main/java/com/iyzipay/model/CardManagementPageInitialize.java @@ -12,9 +12,10 @@ public class CardManagementPageInitialize extends IyzipayResource { private String cardPageUrl; public static CardManagementPageInitialize create(CreateCardManagementPageInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/v1/card-management/pages", + String path = "/v1/card-management/pages"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CardManagementPageInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/CheckoutForm.java b/src/main/java/com/iyzipay/model/CheckoutForm.java index 0529b9cb..4c80cdd0 100644 --- a/src/main/java/com/iyzipay/model/CheckoutForm.java +++ b/src/main/java/com/iyzipay/model/CheckoutForm.java @@ -1,18 +1,31 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.RetrieveCheckoutFormRequest; -public class CheckoutForm extends PaymentResource { +import java.util.Arrays; + +public class CheckoutForm extends PaymentResource implements ResponseSignatureGenerator { private String token; private String callbackUrl; + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentStatus(), getPaymentId(), + getCurrency(), getBasketId(), getConversationId(), + getPaidPrice(), getPrice(), getToken())); + return HashValidator.hashValid(getSignature(), calculated); + } + public static CheckoutForm retrieve(RetrieveCheckoutFormRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/checkoutform/auth/ecom/detail", + String path = "/payment/iyzipos/checkoutform/auth/ecom/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CheckoutForm.class); } diff --git a/src/main/java/com/iyzipay/model/CheckoutFormInitialize.java b/src/main/java/com/iyzipay/model/CheckoutFormInitialize.java index 70e28801..0d5ed58e 100644 --- a/src/main/java/com/iyzipay/model/CheckoutFormInitialize.java +++ b/src/main/java/com/iyzipay/model/CheckoutFormInitialize.java @@ -1,15 +1,26 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreateCheckoutFormInitializeRequest; -public class CheckoutFormInitialize extends CheckoutFormInitializeResource { +import java.util.Arrays; + +public class CheckoutFormInitialize extends CheckoutFormInitializeResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getConversationId(), getToken())); + return HashValidator.hashValid(getSignature(), calculated); + } public static CheckoutFormInitialize create(CreateCheckoutFormInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/checkoutform/initialize/auth/ecom", + String path = "/payment/iyzipos/checkoutform/initialize/auth/ecom"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CheckoutFormInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/CheckoutFormInitializePreAuth.java b/src/main/java/com/iyzipay/model/CheckoutFormInitializePreAuth.java index 8df9113a..368212eb 100644 --- a/src/main/java/com/iyzipay/model/CheckoutFormInitializePreAuth.java +++ b/src/main/java/com/iyzipay/model/CheckoutFormInitializePreAuth.java @@ -1,15 +1,26 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreateCheckoutFormInitializeRequest; -public class CheckoutFormInitializePreAuth extends CheckoutFormInitializeResource { +import java.util.Arrays; + +public class CheckoutFormInitializePreAuth extends CheckoutFormInitializeResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey){ + String calculated = generateSignature(secretKey, + Arrays.asList(getConversationId(), getToken())); + return HashValidator.hashValid(getSignature(), calculated); + } public static CheckoutFormInitializePreAuth create(CreateCheckoutFormInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/checkoutform/initialize/preauth/ecom", + String path = "/payment/iyzipos/checkoutform/initialize/preauth/ecom"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CheckoutFormInitializePreAuth.class); } diff --git a/src/main/java/com/iyzipay/model/CheckoutFormInitializeResource.java b/src/main/java/com/iyzipay/model/CheckoutFormInitializeResource.java index a8aff0a2..8401a33c 100644 --- a/src/main/java/com/iyzipay/model/CheckoutFormInitializeResource.java +++ b/src/main/java/com/iyzipay/model/CheckoutFormInitializeResource.java @@ -9,6 +9,7 @@ public class CheckoutFormInitializeResource extends IyzipayResource { private Long tokenExpireTime; private String paymentPageUrl; private String payWithIyzicoPageUrl; + private String signature; public String getToken() { return token; @@ -49,4 +50,12 @@ public String getPayWithIyzicoPageUrl() { public void setPayWithIyzicoPageUrl(String payWithIyzicoPageUrl) { this.payWithIyzicoPageUrl = payWithIyzicoPageUrl; } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } } diff --git a/src/main/java/com/iyzipay/model/CrossBookingFromSubMerchant.java b/src/main/java/com/iyzipay/model/CrossBookingFromSubMerchant.java index 74c130cd..7948f4b3 100644 --- a/src/main/java/com/iyzipay/model/CrossBookingFromSubMerchant.java +++ b/src/main/java/com/iyzipay/model/CrossBookingFromSubMerchant.java @@ -8,9 +8,10 @@ public class CrossBookingFromSubMerchant extends IyzipayResource { public static CrossBookingFromSubMerchant create(CreateCrossBookingRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/crossbooking/receive", + String path = "/crossbooking/receive"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CrossBookingFromSubMerchant.class); } diff --git a/src/main/java/com/iyzipay/model/CrossBookingToSubMerchant.java b/src/main/java/com/iyzipay/model/CrossBookingToSubMerchant.java index 71ddd125..2697ad7e 100644 --- a/src/main/java/com/iyzipay/model/CrossBookingToSubMerchant.java +++ b/src/main/java/com/iyzipay/model/CrossBookingToSubMerchant.java @@ -8,9 +8,10 @@ public class CrossBookingToSubMerchant extends IyzipayResource { public static CrossBookingToSubMerchant create(CreateCrossBookingRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/crossbooking/send", + String path = "/crossbooking/send"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, CrossBookingToSubMerchant.class); } diff --git a/src/main/java/com/iyzipay/model/Disapproval.java b/src/main/java/com/iyzipay/model/Disapproval.java index 1881c440..1f5fc372 100644 --- a/src/main/java/com/iyzipay/model/Disapproval.java +++ b/src/main/java/com/iyzipay/model/Disapproval.java @@ -10,9 +10,10 @@ public class Disapproval extends IyzipayResource { private String paymentTransactionId; public static Disapproval create(CreateApprovalRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/item/disapprove", + String path = "/payment/iyzipos/item/disapprove"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Disapproval.class); } diff --git a/src/main/java/com/iyzipay/model/InstallmentInfo.java b/src/main/java/com/iyzipay/model/InstallmentInfo.java index c4522ac2..bee4436d 100644 --- a/src/main/java/com/iyzipay/model/InstallmentInfo.java +++ b/src/main/java/com/iyzipay/model/InstallmentInfo.java @@ -12,9 +12,10 @@ public class InstallmentInfo extends IyzipayResource { private List installmentDetails; public static InstallmentInfo retrieve(RetrieveInstallmentInfoRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/installment", + String path = "/payment/iyzipos/installment"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, InstallmentInfo.class); } diff --git a/src/main/java/com/iyzipay/model/IyziupForm.java b/src/main/java/com/iyzipay/model/IyziupForm.java index 583f89ff..80d57018 100644 --- a/src/main/java/com/iyzipay/model/IyziupForm.java +++ b/src/main/java/com/iyzipay/model/IyziupForm.java @@ -16,9 +16,10 @@ public class IyziupForm extends IyzipayResource { private IyziupPayment paymentDetail; public static IyziupForm retrieve(RetrieveIyziupFormRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/v1/iyziup/form/order/retrieve", + String path = "/v1/iyziup/form/order/retrieve"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, IyziupForm.class); } diff --git a/src/main/java/com/iyzipay/model/IyziupFormInitialize.java b/src/main/java/com/iyzipay/model/IyziupFormInitialize.java index 66c1c37e..4b992443 100644 --- a/src/main/java/com/iyzipay/model/IyziupFormInitialize.java +++ b/src/main/java/com/iyzipay/model/IyziupFormInitialize.java @@ -7,9 +7,10 @@ public class IyziupFormInitialize extends IyziupFormInitializeResource { public static IyziupFormInitialize create(CreateIyziupFormInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/v1/iyziup/form/initialize", + String path = "/v1/iyziup/form/initialize"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, IyziupFormInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/PayWithIyzicoInitialize.java b/src/main/java/com/iyzipay/model/PayWithIyzicoInitialize.java index 3821a172..a1a1d27e 100644 --- a/src/main/java/com/iyzipay/model/PayWithIyzicoInitialize.java +++ b/src/main/java/com/iyzipay/model/PayWithIyzicoInitialize.java @@ -1,13 +1,26 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; + +import java.util.Arrays; + + +public class PayWithIyzicoInitialize extends PayWithIyzicoInitializeResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getConversationId(), getToken())); + return HashValidator.hashValid(getSignature(), calculated); + } -public class PayWithIyzicoInitialize extends PayWithIyzicoInitializeResource { public static PayWithIyzicoInitialize create(PayWithIyzicoInitializeRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/pay-with-iyzico/initialize", + String path = "/payment/pay-with-iyzico/initialize"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PayWithIyzicoInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/PayWithIyzicoInitializeResource.java b/src/main/java/com/iyzipay/model/PayWithIyzicoInitializeResource.java index 615b95dd..583d79f1 100644 --- a/src/main/java/com/iyzipay/model/PayWithIyzicoInitializeResource.java +++ b/src/main/java/com/iyzipay/model/PayWithIyzicoInitializeResource.java @@ -6,6 +6,7 @@ public class PayWithIyzicoInitializeResource extends IyzipayResource { private String token; private Long tokenExpireTime; private String payWithIyzicoPageUrl; + private String signature; public String getToken() { return token; @@ -30,4 +31,12 @@ public String getPayWithIyzicoPageUrl() { public void setPayWithIyzicoPageUrl(String payWithIyzicoPageUrl) { this.payWithIyzicoPageUrl = payWithIyzicoPageUrl; } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } } diff --git a/src/main/java/com/iyzipay/model/Payment.java b/src/main/java/com/iyzipay/model/Payment.java index bd5528c6..4f4e8ca6 100644 --- a/src/main/java/com/iyzipay/model/Payment.java +++ b/src/main/java/com/iyzipay/model/Payment.java @@ -1,24 +1,37 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreatePaymentRequest; import com.iyzipay.request.RetrievePaymentRequest; -public class Payment extends PaymentResource { +import java.util.Arrays; + +public class Payment extends PaymentResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getCurrency(), getBasketId(), + getConversationId(), getPaidPrice(), getPrice())); + return HashValidator.hashValid(getSignature(), calculated); + } public static Payment create(CreatePaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/auth", + String path = "/payment/auth"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Payment.class); } public static Payment retrieve(RetrievePaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/detail", + String path = "/payment/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Payment.class); } diff --git a/src/main/java/com/iyzipay/model/PaymentItem.java b/src/main/java/com/iyzipay/model/PaymentItem.java index 56c0b47f..89b85dc6 100644 --- a/src/main/java/com/iyzipay/model/PaymentItem.java +++ b/src/main/java/com/iyzipay/model/PaymentItem.java @@ -33,9 +33,10 @@ public class PaymentItem extends IyzipayResource { private ConvertedPayout convertedPayout; public static PaymentItem update(UpdatePaymentItemRequest request, Options options) { - return HttpClient.create().put(options.getBaseUrl() + "/payment/item", + String path = "/payment/item"; + return HttpClient.create().put(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PaymentItem.class); } diff --git a/src/main/java/com/iyzipay/model/PaymentPostAuth.java b/src/main/java/com/iyzipay/model/PaymentPostAuth.java index 6a4eb8a7..41cf02c9 100644 --- a/src/main/java/com/iyzipay/model/PaymentPostAuth.java +++ b/src/main/java/com/iyzipay/model/PaymentPostAuth.java @@ -1,15 +1,27 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreatePaymentPostAuthRequest; -public class PaymentPostAuth extends PaymentResource { +import java.util.Arrays; + +public class PaymentPostAuth extends PaymentResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getCurrency(), getBasketId(), + getConversationId(), getPaidPrice(), getPrice())); + return HashValidator.hashValid(getSignature(), calculated); + } public static PaymentPostAuth create(CreatePaymentPostAuthRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/postauth", + String path = "/payment/postauth"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PaymentPostAuth.class); } diff --git a/src/main/java/com/iyzipay/model/PaymentPreAuth.java b/src/main/java/com/iyzipay/model/PaymentPreAuth.java index 9a4e0b58..732bef79 100644 --- a/src/main/java/com/iyzipay/model/PaymentPreAuth.java +++ b/src/main/java/com/iyzipay/model/PaymentPreAuth.java @@ -1,24 +1,38 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreatePaymentRequest; import com.iyzipay.request.RetrievePaymentRequest; -public class PaymentPreAuth extends PaymentResource { +import java.util.Arrays; + +public class PaymentPreAuth extends PaymentResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey){ + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getCurrency(), getBasketId(), + getConversationId(), getPaidPrice(), getPrice())); + return HashValidator.hashValid(getSignature(), calculated); + } + public static PaymentPreAuth create(CreatePaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/preauth", + String path = "/payment/preauth"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PaymentPreAuth.class); } public static PaymentPreAuth retrieve(RetrievePaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/detail", + String path = "/payment/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PaymentPreAuth.class); } diff --git a/src/main/java/com/iyzipay/model/PaymentResource.java b/src/main/java/com/iyzipay/model/PaymentResource.java index 93013ddd..36c63223 100644 --- a/src/main/java/com/iyzipay/model/PaymentResource.java +++ b/src/main/java/com/iyzipay/model/PaymentResource.java @@ -41,6 +41,7 @@ public class PaymentResource extends IyzipayResource { private String bankName; private String referenceCode; private Integer mdStatus; + private String signature; public BigDecimal getPrice() { return price; @@ -282,6 +283,14 @@ public void setMdStatus(Integer mdStatus) { this.mdStatus = mdStatus; } + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); diff --git a/src/main/java/com/iyzipay/model/PayoutCompletedTransactionList.java b/src/main/java/com/iyzipay/model/PayoutCompletedTransactionList.java index 173b939f..c77a9636 100644 --- a/src/main/java/com/iyzipay/model/PayoutCompletedTransactionList.java +++ b/src/main/java/com/iyzipay/model/PayoutCompletedTransactionList.java @@ -12,9 +12,10 @@ public class PayoutCompletedTransactionList extends IyzipayResource { private List payoutCompletedTransactions; public static PayoutCompletedTransactionList retrieve(RetrieveTransactionsRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/reporting/settlement/payoutcompleted", + String path = "/reporting/settlement/payoutcompleted"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, PayoutCompletedTransactionList.class); } diff --git a/src/main/java/com/iyzipay/model/Refund.java b/src/main/java/com/iyzipay/model/Refund.java index cb03cc3a..51b3dab0 100644 --- a/src/main/java/com/iyzipay/model/Refund.java +++ b/src/main/java/com/iyzipay/model/Refund.java @@ -18,9 +18,10 @@ public class Refund extends IyzipayResource { private String hostReference; public static Refund create(CreateRefundRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/refund", + String path = "/payment/refund"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, Refund.class); } diff --git a/src/main/java/com/iyzipay/model/RefundChargedFromMerchant.java b/src/main/java/com/iyzipay/model/RefundChargedFromMerchant.java index a9aceaa8..47db6a52 100644 --- a/src/main/java/com/iyzipay/model/RefundChargedFromMerchant.java +++ b/src/main/java/com/iyzipay/model/RefundChargedFromMerchant.java @@ -15,9 +15,10 @@ public class RefundChargedFromMerchant extends IyzipayResource { private String hostReference; public static RefundChargedFromMerchant create(CreateRefundRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/iyzipos/refund/merchant/charge", + String path = "/payment/iyzipos/refund/merchant/charge"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, RefundChargedFromMerchant.class); } diff --git a/src/main/java/com/iyzipay/model/ReportingPaymentDetail.java b/src/main/java/com/iyzipay/model/ReportingPaymentDetail.java index 570c1b13..d08e84e6 100644 --- a/src/main/java/com/iyzipay/model/ReportingPaymentDetail.java +++ b/src/main/java/com/iyzipay/model/ReportingPaymentDetail.java @@ -16,10 +16,11 @@ public class ReportingPaymentDetail extends IyzipayResource { private List payments; public static ReportingPaymentDetail create(ReportingPaymentDetailRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/reporting/payment/details" + getQueryParams(request); + String path = "/v2/reporting/payment/details"; + String uri = options.getBaseUrl() + path + getQueryParams(request); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, ReportingPaymentDetail.class); } diff --git a/src/main/java/com/iyzipay/model/ReportingPaymentTransaction.java b/src/main/java/com/iyzipay/model/ReportingPaymentTransaction.java index 7bf03607..f384c51f 100644 --- a/src/main/java/com/iyzipay/model/ReportingPaymentTransaction.java +++ b/src/main/java/com/iyzipay/model/ReportingPaymentTransaction.java @@ -18,10 +18,11 @@ public class ReportingPaymentTransaction extends IyzipayResource { private Integer totalPageCount; public static ReportingPaymentTransaction create(ReportingPaymentTransactionRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/reporting/payment/transactions" + getQueryParams(request); + String path = "/v2/reporting/payment/transactions"; + String uri = options.getBaseUrl() + path + getQueryParams(request); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, ReportingPaymentTransaction.class); } diff --git a/src/main/java/com/iyzipay/model/SubMerchant.java b/src/main/java/com/iyzipay/model/SubMerchant.java index f8eb623f..77912ae2 100644 --- a/src/main/java/com/iyzipay/model/SubMerchant.java +++ b/src/main/java/com/iyzipay/model/SubMerchant.java @@ -27,25 +27,28 @@ public class SubMerchant extends IyzipayResource { private String subMerchantKey; public static SubMerchant create(CreateSubMerchantRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/onboarding/submerchant", + String path = "/onboarding/submerchant"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, SubMerchant.class); } public static SubMerchant update(UpdateSubMerchantRequest request, Options options) { - return HttpClient.create().put(options.getBaseUrl() + "/onboarding/submerchant", + String path = "/onboarding/submerchant"; + return HttpClient.create().put(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, SubMerchant.class); } public static SubMerchant retrieve(RetrieveSubMerchantRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/onboarding/submerchant/detail", + String path = "/onboarding/submerchant/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, SubMerchant.class); } diff --git a/src/main/java/com/iyzipay/model/ThreedsInitialize.java b/src/main/java/com/iyzipay/model/ThreedsInitialize.java index c875b738..5431a245 100644 --- a/src/main/java/com/iyzipay/model/ThreedsInitialize.java +++ b/src/main/java/com/iyzipay/model/ThreedsInitialize.java @@ -2,20 +2,33 @@ import com.google.gson.annotations.SerializedName; import com.iyzipay.DigestHelper; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.IyzipayResource; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreatePaymentRequest; -public class ThreedsInitialize extends IyzipayResource { +import java.util.Arrays; + +public class ThreedsInitialize extends IyzipayResource implements ResponseSignatureGenerator { @SerializedName("threeDSHtmlContent") private String htmlContent; + private String paymentId; + private String signature; + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getConversationId())); + return HashValidator.hashValid(getSignature(), calculated); + } public static ThreedsInitialize create(CreatePaymentRequest request, Options options) { - ThreedsInitialize response = HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/initialize", + String path = "/payment/3dsecure/initialize"; + ThreedsInitialize response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, ThreedsInitialize.class); if (response != null) { @@ -31,4 +44,20 @@ public String getHtmlContent() { public void setHtmlContent(String htmlContent) { this.htmlContent = htmlContent; } + + public String getPaymentId() { + return paymentId; + } + + public void setPaymentId(String paymentId) { + this.paymentId = paymentId; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } } diff --git a/src/main/java/com/iyzipay/model/ThreedsInitializePreAuth.java b/src/main/java/com/iyzipay/model/ThreedsInitializePreAuth.java index 7e7684ea..885ccf05 100644 --- a/src/main/java/com/iyzipay/model/ThreedsInitializePreAuth.java +++ b/src/main/java/com/iyzipay/model/ThreedsInitializePreAuth.java @@ -2,20 +2,33 @@ import com.google.gson.annotations.SerializedName; import com.iyzipay.DigestHelper; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.IyzipayResource; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreatePaymentRequest; -public class ThreedsInitializePreAuth extends IyzipayResource { +import java.util.Arrays; + +public class ThreedsInitializePreAuth extends IyzipayResource implements ResponseSignatureGenerator { @SerializedName("threeDSHtmlContent") private String htmlContent; + private String paymentId; + private String signature; + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getConversationId())); + return HashValidator.hashValid(getSignature(), calculated); + } public static ThreedsInitializePreAuth create(CreatePaymentRequest request, Options options) { - ThreedsInitializePreAuth response = HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/initialize/preauth", + String path = "/payment/3dsecure/initialize/preauth"; + ThreedsInitializePreAuth response = HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, ThreedsInitializePreAuth.class); if (response != null) { @@ -31,4 +44,20 @@ public String getHtmlContent() { public void setHtmlContent(String htmlContent) { this.htmlContent = htmlContent; } + + public String getPaymentId() { + return paymentId; + } + + public void setPaymentId(String paymentId) { + this.paymentId = paymentId; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } } diff --git a/src/main/java/com/iyzipay/model/ThreedsPayment.java b/src/main/java/com/iyzipay/model/ThreedsPayment.java index 416c0383..8137c104 100644 --- a/src/main/java/com/iyzipay/model/ThreedsPayment.java +++ b/src/main/java/com/iyzipay/model/ThreedsPayment.java @@ -1,33 +1,47 @@ package com.iyzipay.model; +import com.iyzipay.HashValidator; import com.iyzipay.HttpClient; import com.iyzipay.Options; +import com.iyzipay.ResponseSignatureGenerator; import com.iyzipay.request.CreateThreedsPaymentRequest; import com.iyzipay.request.CreateThreedsPaymentRequestV2; import com.iyzipay.request.RetrievePaymentRequest; -public class ThreedsPayment extends PaymentResource { +import java.util.Arrays; + +public class ThreedsPayment extends PaymentResource implements ResponseSignatureGenerator { + + public boolean verifySignature(String secretKey) { + String calculated = generateSignature(secretKey, + Arrays.asList(getPaymentId(), getCurrency(), getBasketId(), + getConversationId(), getPaidPrice(), getPrice())); + return HashValidator.hashValid(getSignature(), calculated); + } public static ThreedsPayment create(CreateThreedsPaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/3dsecure/auth", + String path = "/payment/3dsecure/auth"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, ThreedsPayment.class); } public static ThreedsPayment createV2(CreateThreedsPaymentRequestV2 request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/v2/3dsecure/auth", + String path = "/payment/v2/3dsecure/auth"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, ThreedsPayment.class); } public static ThreedsPayment retrieve(RetrievePaymentRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/detail", + String path = "/payment/detail"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, ThreedsPayment.class); } diff --git a/src/main/java/com/iyzipay/model/iyzilink/IyziLink.java b/src/main/java/com/iyzipay/model/iyzilink/IyziLink.java index b64ff14d..44069be1 100644 --- a/src/main/java/com/iyzipay/model/iyzilink/IyziLink.java +++ b/src/main/java/com/iyzipay/model/iyzilink/IyziLink.java @@ -17,16 +17,17 @@ public static IyziLinkSaveResource create(IyziLinkSaveRequest request, Options o String uri = options.getBaseUrl() + V2_IYZILINK_PRODUCTS + getQueryParams(request); return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(V2_IYZILINK_PRODUCTS, request, options), request, IyziLinkSaveResource.class); } public static IyziLinkSaveResource update(String token, IyziLinkSaveRequest request, Options options) { - String uri = options.getBaseUrl() + V2_IYZILINK_PRODUCTS + "/" + token + getQueryParams(request); + String path = V2_IYZILINK_PRODUCTS + "/" + token; + String uri = options.getBaseUrl() + path + getQueryParams(request); return HttpClient.create().put(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, IyziLinkSaveResource.class); } @@ -38,25 +39,27 @@ public static IyziLinkPagingResource retrieveAll(PagingRequest pagingRequest, Op String uri = options.getBaseUrl() + V2_IYZILINK_PRODUCTS + queryParams; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(V2_IYZILINK_PRODUCTS, null, options), null, IyziLinkPagingResource.class); } public static IyziLinkResource retrieve(String token, Request request, Options options) { - String uri = options.getBaseUrl() + V2_IYZILINK_PRODUCTS + "/" + token + getQueryParams(request); + String path = V2_IYZILINK_PRODUCTS + "/" + token; + String uri = options.getBaseUrl() + path + getQueryParams(request); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, IyziLinkResource.class); } public static IyzipayResource delete(String token, Request request, Options options) { - String uri = options.getBaseUrl() + V2_IYZILINK_PRODUCTS + "/" + token + getQueryParams(request); + String path = V2_IYZILINK_PRODUCTS + "/" + token; + String uri = options.getBaseUrl() + path + getQueryParams(request); return HttpClient.create().delete(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, IyzipayResource.class); } diff --git a/src/main/java/com/iyzipay/model/loyalty/LoyaltyInquire.java b/src/main/java/com/iyzipay/model/loyalty/LoyaltyInquire.java index 4bc0d887..74cb8728 100644 --- a/src/main/java/com/iyzipay/model/loyalty/LoyaltyInquire.java +++ b/src/main/java/com/iyzipay/model/loyalty/LoyaltyInquire.java @@ -7,9 +7,10 @@ public class LoyaltyInquire extends LoyaltyResource { public static LoyaltyInquire create(LoyaltyInquireRequest request, Options options) { - return HttpClient.create().post(options.getBaseUrl() + "/payment/loyalty/inquire", + String path = "/payment/loyalty/inquire"; + return HttpClient.create().post(options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, LoyaltyInquire.class); } diff --git a/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingInitialize.java b/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingInitialize.java index 2d6b0cde..c7d10764 100644 --- a/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingInitialize.java +++ b/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingInitialize.java @@ -6,10 +6,11 @@ public class SubMerchantOnboardingInitialize extends SubmerchantOnboardingInitializeResource { public static SubMerchantOnboardingInitialize initialize(SubMerchantOnboardingInitializeRequest request, Options options) { + String path = "/onboarding/settlement-to-balance/submerchant"; return HttpClient.create().post( - options.getBaseUrl() + "/onboarding/settlement-to-balance/submerchant", + options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, SubMerchantOnboardingInitialize.class ); diff --git a/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingVerify.java b/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingVerify.java index 6818df98..9f24c9ba 100644 --- a/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingVerify.java +++ b/src/main/java/com/iyzipay/model/marketplace/onboarding/settlementtobalance/SubMerchantOnboardingVerify.java @@ -6,10 +6,11 @@ public class SubMerchantOnboardingVerify extends SubMerchantOnboardingVerifyResource { public static SubMerchantOnboardingVerify verify(SubMerchantOnboardingVerifyRequest request, Options options) { + String path = "/onboarding/settlement-to-balance/submerchant/verify"; return HttpClient.create().post( - options.getBaseUrl() + "/onboarding/settlement-to-balance/submerchant/verify", + options.getBaseUrl() + path, getHttpProxy(options), - getHttpHeaders(request, options), + getHttpHeadersV2(path, request, options), request, SubMerchantOnboardingVerify.class ); diff --git a/src/main/java/com/iyzipay/model/subscription/Subscription.java b/src/main/java/com/iyzipay/model/subscription/Subscription.java index fd065ab5..6f06cc40 100644 --- a/src/main/java/com/iyzipay/model/subscription/Subscription.java +++ b/src/main/java/com/iyzipay/model/subscription/Subscription.java @@ -12,10 +12,11 @@ public class Subscription extends IyzipayResource { private SubscriptionData subscriptionData; public static Subscription retrieve(String subscriptionReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/subscriptions/" + subscriptionReferenceCode; + String path = "/v2/subscription/subscriptions/" + subscriptionReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, Subscription.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionCardUpdateCheckoutFormInitialize.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionCardUpdateCheckoutFormInitialize.java index 775a91ae..d9417165 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionCardUpdateCheckoutFormInitialize.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionCardUpdateCheckoutFormInitialize.java @@ -13,19 +13,21 @@ public class SubscriptionCardUpdateCheckoutFormInitialize extends IyzipayResourc private Long tokenExpireTime; public static SubscriptionCardUpdateCheckoutFormInitialize create(InitializeSubscriptionCardUpdateCheckoutFormRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/card-update/checkoutform/initialize"; + String path = "/v2/subscription/card-update/checkoutform/initialize"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionCardUpdateCheckoutFormInitialize.class); } public static SubscriptionCardUpdateCheckoutFormInitialize createWithSubscription(InitializeCardUpdateWithSubscriptionCheckoutFormRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/card-update/checkoutform/initialize/with-subscription"; + String path = "/v2/subscription/card-update/checkoutform/initialize/with-subscription"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionCardUpdateCheckoutFormInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutForm.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutForm.java index 61298e19..970ad0b6 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutForm.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutForm.java @@ -12,10 +12,11 @@ public class SubscriptionCheckoutForm extends IyzipayResource { private CreatedSubscriptionData createdSubscriptionData; public static SubscriptionCheckoutForm retrieve(String subscriptionCheckoutFormToken, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/checkoutform/" + subscriptionCheckoutFormToken; + String path = "/v2/subscription/checkoutform/" + subscriptionCheckoutFormToken; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionCheckoutForm.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutFormInitialize.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutFormInitialize.java index 88ddce4e..720725df 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutFormInitialize.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionCheckoutFormInitialize.java @@ -12,10 +12,11 @@ public class SubscriptionCheckoutFormInitialize extends IyzipayResource { private Long tokenExpireTime; public static SubscriptionCheckoutFormInitialize create(InitializeSubscriptionCheckoutFormRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/checkoutform/initialize"; + String path = "/v2/subscription/checkoutform/initialize"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionCheckoutFormInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomer.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomer.java index f2d8f941..ecef0edc 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomer.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomer.java @@ -14,37 +14,41 @@ public class SubscriptionCustomer extends IyzipayResource { private SubscriptionCustomerData subscriptionCustomerData; public static SubscriptionCustomer create(CreateSubscriptionCustomerRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/customers"; + String path = "/v2/subscription/customers"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionCustomer.class); } public static SubscriptionCustomer update(String subscriptionCustomerReferenceCode, UpdateSubscriptionCustomerRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String path = "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionCustomer.class); } public static SubscriptionCustomer retrieve(String subscriptionCustomerReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String path = "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionCustomer.class); } public static IyzipayResource delete(String subscriptionCustomerReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String path = "/v2/subscription/customers/" + subscriptionCustomerReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().delete(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, IyzipayResource.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomerList.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomerList.java index ce4b497d..b81441db 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomerList.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionCustomerList.java @@ -14,13 +14,14 @@ public class SubscriptionCustomerList extends IyzipayResource { private SubscriptionCustomerListData subscriptionCustomerListData; public static SubscriptionCustomerList retrieve(PagingRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/customers/" + new PageRequestQueryParamBuilder() + String path = "/v2/subscription/customers"; + String uri = options.getBaseUrl() + path + "/" + new PageRequestQueryParamBuilder() .page(request.getPage()) .count(request.getCount()) .build(); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionCustomerList.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionInitialize.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionInitialize.java index f3874b31..63ea2d1d 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionInitialize.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionInitialize.java @@ -14,19 +14,21 @@ public class SubscriptionInitialize extends IyzipayResource { private CreatedSubscriptionData createdSubscriptionData; public static SubscriptionInitialize create(InitializeSubscriptionRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/initialize"; + String path = "/v2/subscription/initialize"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionInitialize.class); } public static SubscriptionInitialize createWithExistingCustomer(InitializeSubscriptionWithExistingCustomerRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/initialize/with-customer"; + String path = "/v2/subscription/initialize/with-customer"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionInitialize.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionOperation.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionOperation.java index c54007a3..35777dae 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionOperation.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionOperation.java @@ -14,37 +14,41 @@ public class SubscriptionOperation extends IyzipayResource { private SubscriptionUpgradeData subscriptionUpgradeData; public static SubscriptionOperation cancel(String subscriptionReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/cancel"; + String path = "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/cancel"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionOperation.class); } public static SubscriptionOperation activate(String subscriptionReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/activate"; + String path = "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/activate"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionOperation.class); } public static SubscriptionOperation upgrade(String subscriptionReferenceCode, UpgradeSubscriptionRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/upgrade"; + String path = "/v2/subscription/subscriptions/" + subscriptionReferenceCode + "/upgrade"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionOperation.class); } public static SubscriptionOperation retryPayment(SubscriptionOrderOperationRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/operation/retry"; + String path = "/v2/subscription/operation/retry"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionOperation.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionOrder.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionOrder.java index 32e7093c..5de027e8 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionOrder.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionOrder.java @@ -12,10 +12,11 @@ public class SubscriptionOrder extends IyzipayResource { private SubscriptionOrderData subscriptionOrderData; public static SubscriptionOrder retrieve(String subscriptionOrderReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/orders/" + subscriptionOrderReferenceCode; + String path = "/v2/subscription/orders/" + subscriptionOrderReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionOrder.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlan.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlan.java index 89361bae..98df58ed 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlan.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlan.java @@ -14,37 +14,41 @@ public class SubscriptionPricingPlan extends IyzipayResource { private SubscriptionPricingPlanData subscriptionPricingPlanData; public static SubscriptionPricingPlan retrieve(String subscriptionPricingPlanReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode; + String path = "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode;; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionPricingPlan.class); } public static SubscriptionPricingPlan create(String subscriptionProductReferenceCode, CreateSubscriptionPricingPlanRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + subscriptionProductReferenceCode + "/pricing-plans"; + String path = "/v2/subscription/products/" + subscriptionProductReferenceCode + "/pricing-plans"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionPricingPlan.class); } public static SubscriptionPricingPlan update(String subscriptionPricingPlanReferenceCode, UpdateSubscriptionPricingPlanRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode; + String path = "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionPricingPlan.class); } public static IyzipayResource delete(String subscriptionPricingPlanReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode; + String path = "/v2/subscription/pricing-plans/" + subscriptionPricingPlanReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().delete(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, IyzipayResource.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlanList.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlanList.java index c3c5d900..cd7d376f 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlanList.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionPricingPlanList.java @@ -14,13 +14,14 @@ public class SubscriptionPricingPlanList extends IyzipayResource { private SubscriptionPricingPlanListData subscriptionPricingPlanListData; public static SubscriptionPricingPlanList retrieve(String subscriptionPricingPlanReferenceCode, PagingRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + subscriptionPricingPlanReferenceCode + "/pricing-plans/" + new PageRequestQueryParamBuilder() + String path = "/v2/subscription/products/" + subscriptionPricingPlanReferenceCode + "/pricing-plans"; + String uri = options.getBaseUrl() + path + "/" + new PageRequestQueryParamBuilder() .page(request.getPage()) .count(request.getCount()) .build(); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionPricingPlanList.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionProduct.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionProduct.java index 6802370a..3b92bdd9 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionProduct.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionProduct.java @@ -14,37 +14,41 @@ public class SubscriptionProduct extends IyzipayResource { private SubscriptionProductData subscriptionProductData; public static SubscriptionProduct retrieve(String subscriptionProductReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + subscriptionProductReferenceCode; + String path = "/v2/subscription/products/" + subscriptionProductReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionProduct.class); } public static SubscriptionProduct create(CreateSubscriptionProductRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products"; + String path = "/v2/subscription/products"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionProduct.class); } public static SubscriptionProduct update(String subscriptionProductReferenceCode, SubscriptionUpdateProductRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + subscriptionProductReferenceCode; + String path = "/v2/subscription/products/" + subscriptionProductReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, SubscriptionProduct.class); } public static IyzipayResource delete(String subscriptionProductReferenceCode, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + subscriptionProductReferenceCode; + String path = "/v2/subscription/products/" + subscriptionProductReferenceCode; + String uri = options.getBaseUrl() + path; return HttpClient.create().delete(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, IyzipayResource.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionProductList.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionProductList.java index 6bfe4171..8694ea3f 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionProductList.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionProductList.java @@ -14,13 +14,14 @@ public class SubscriptionProductList extends IyzipayResource { private SubscriptionProductListData subscriptionProductListData; public static SubscriptionProductList retrieve(PagingRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/products/" + new PageRequestQueryParamBuilder() + String path = "/v2/subscription/products"; + String uri = options.getBaseUrl() + path + "/" + new PageRequestQueryParamBuilder() .page(request.getPage()) .count(request.getCount()) .build(); return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionProductList.class); } diff --git a/src/main/java/com/iyzipay/model/subscription/SubscriptionSearch.java b/src/main/java/com/iyzipay/model/subscription/SubscriptionSearch.java index 30f012c2..9a2a2d92 100644 --- a/src/main/java/com/iyzipay/model/subscription/SubscriptionSearch.java +++ b/src/main/java/com/iyzipay/model/subscription/SubscriptionSearch.java @@ -13,7 +13,8 @@ public class SubscriptionSearch extends IyzipayResource { public static SubscriptionSearch search(SearchSubscriptionRequest request, PagingRequest pagingRequest, Options options) { - String uri = options.getBaseUrl() + "/v2/subscription/subscriptions" + new SubscriptionSearchQueryParamBuilder().page(pagingRequest.getPage()) + String path = "/v2/subscription/subscriptions"; + String uri = options.getBaseUrl() + path + new SubscriptionSearchQueryParamBuilder().page(pagingRequest.getPage()) .count(pagingRequest.getCount()) .page(pagingRequest.getPage()) .subscriptionReferenceCode(request.getSubscriptionReferenceCode()) @@ -27,7 +28,7 @@ public static SubscriptionSearch search(SearchSubscriptionRequest request, Pagin return HttpClient.create().get(uri, getHttpProxy(options), - getHttpHeadersV2(uri, null, options), + getHttpHeadersV2(path, null, options), null, SubscriptionSearch.class); } diff --git a/src/main/java/com/iyzipay/model/universalcardstorage/UcsInitResource.java b/src/main/java/com/iyzipay/model/universalcardstorage/UcsInitResource.java index d5380bcc..49f36c7d 100644 --- a/src/main/java/com/iyzipay/model/universalcardstorage/UcsInitResource.java +++ b/src/main/java/com/iyzipay/model/universalcardstorage/UcsInitResource.java @@ -15,10 +15,11 @@ public class UcsInitResource extends IyzipayResource { private String scriptType; public static UcsInitResource create(InitUcsRequest request, Options options) { - String uri = options.getBaseUrl() + "/v2/ucs/init"; + String path = "/v2/ucs/init"; + String uri = options.getBaseUrl() + path; return HttpClient.create().post(uri, getHttpProxy(options), - getHttpHeadersV2(uri, request, options), + getHttpHeadersV2(path, request, options), request, UcsInitResource.class); } diff --git a/src/test/java/com/iyzipay/functional/ApprovalTest.java b/src/test/java/com/iyzipay/functional/ApprovalTest.java index d8ca5411..b23d784c 100644 --- a/src/test/java/com/iyzipay/functional/ApprovalTest.java +++ b/src/test/java/com/iyzipay/functional/ApprovalTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ApprovalTest extends BaseTest { @@ -44,6 +45,7 @@ public void should_approve_payment_item() { assertEquals(paymentTransactionId, approval.getPaymentTransactionId()); assertEquals(Locale.TR.getValue(), payment.getLocale()); assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); assertNull(payment.getErrorMessage()); diff --git a/src/test/java/com/iyzipay/functional/BkmTest.java b/src/test/java/com/iyzipay/functional/BkmTest.java index ac331b55..ec9dad82 100644 --- a/src/test/java/com/iyzipay/functional/BkmTest.java +++ b/src/test/java/com/iyzipay/functional/BkmTest.java @@ -23,6 +23,7 @@ public void should_initialize_bkm() { System.out.println(bkmInitialize); + assertTrue(bkmInitialize.verifySignature(options.getSecretKey())); assertNotNull(bkmInitialize.getHtmlContent()); assertNotNull(bkmInitialize.getToken()); assertTrue(bkmInitialize.getHtmlContent().contains(bkmInitialize.getToken())); diff --git a/src/test/java/com/iyzipay/functional/CheckoutFormTest.java b/src/test/java/com/iyzipay/functional/CheckoutFormTest.java index 9106ed27..83a5bcea 100644 --- a/src/test/java/com/iyzipay/functional/CheckoutFormTest.java +++ b/src/test/java/com/iyzipay/functional/CheckoutFormTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class CheckoutFormTest extends BaseTest { @@ -40,6 +41,7 @@ public void should_initialize_checkout_form_for_standard_merchant() { assertEquals(Status.SUCCESS.getValue(), checkoutFormInitialize.getStatus()); assertEquals(Locale.TR.getValue(), checkoutFormInitialize.getLocale()); + assertTrue(checkoutFormInitialize.verifySignature(options.getSecretKey())); assertNotEquals(0, checkoutFormInitialize.getSystemTime()); assertNotNull(checkoutFormInitialize.getToken()); assertNotNull(checkoutFormInitialize.getCheckoutFormContent()); diff --git a/src/test/java/com/iyzipay/functional/DisapproveTest.java b/src/test/java/com/iyzipay/functional/DisapproveTest.java index f10bb8ab..cfe7571c 100644 --- a/src/test/java/com/iyzipay/functional/DisapproveTest.java +++ b/src/test/java/com/iyzipay/functional/DisapproveTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class DisapproveTest extends BaseTest { @@ -47,6 +48,7 @@ public void should_disapprove_payment() { assertEquals(paymentTransactionId, disapproval.getPaymentTransactionId()); assertEquals(Status.SUCCESS.getValue(), disapproval.getStatus()); assertEquals(Locale.TR.getValue(), disapproval.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertNotEquals(0, disapproval.getSystemTime()); assertNull(disapproval.getErrorCode()); assertNull(disapproval.getErrorMessage()); diff --git a/src/test/java/com/iyzipay/functional/IyziLinkTest.java b/src/test/java/com/iyzipay/functional/IyziLinkTest.java index db47682d..1f00e844 100644 --- a/src/test/java/com/iyzipay/functional/IyziLinkTest.java +++ b/src/test/java/com/iyzipay/functional/IyziLinkTest.java @@ -1,7 +1,6 @@ package com.iyzipay.functional; import com.iyzipay.FileBase64Encoder; -import com.iyzipay.IyzipayResource; import com.iyzipay.PagingRequest; import com.iyzipay.Request; import com.iyzipay.model.Currency; diff --git a/src/test/java/com/iyzipay/functional/PaymentTest.java b/src/test/java/com/iyzipay/functional/PaymentTest.java index 3132c101..63260eb7 100644 --- a/src/test/java/com/iyzipay/functional/PaymentTest.java +++ b/src/test/java/com/iyzipay/functional/PaymentTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class PaymentTest extends BaseTest { @@ -41,6 +42,7 @@ public void should_create_listing_payment() { assertNull(payment.getConnectorName()); assertEquals(Locale.TR.getValue(), payment.getLocale()); assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); assertNull(payment.getErrorMessage()); @@ -74,6 +76,7 @@ public void should_create_marketplace_payment() { assertNull(payment.getConnectorName()); assertEquals(Locale.TR.getValue(), payment.getLocale()); assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); assertNull(payment.getErrorMessage()); @@ -119,6 +122,7 @@ public void should_create_payment_with_registered_card() { assertNull(payment.getConnectorName()); assertEquals(Locale.TR.getValue(), payment.getLocale()); assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertNotEquals(0, payment.getSystemTime()); assertEquals("123456789", payment.getConversationId()); assertNull(payment.getErrorCode()); @@ -155,6 +159,7 @@ public void should_retrieve_payment() { Payment payment = Payment.retrieve(retrievePaymentRequest, options); assertEquals(Locale.TR.getValue(), payment.getLocale()); assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); + assertTrue(createdPayment.verifySignature(options.getSecretKey())); assertEquals(new Integer(1), payment.getInstallment()); assertEquals("123456789", payment.getConversationId()); assertEquals(createdPayment.getPaymentId(), payment.getPaymentId()); diff --git a/src/test/java/com/iyzipay/functional/RefundTest.java b/src/test/java/com/iyzipay/functional/RefundTest.java index 4de55072..41d0c15f 100644 --- a/src/test/java/com/iyzipay/functional/RefundTest.java +++ b/src/test/java/com/iyzipay/functional/RefundTest.java @@ -34,6 +34,7 @@ public void should_refund_payment() { assertEquals(Status.SUCCESS.getValue(), refund.getStatus()); assertEquals(Locale.TR.getValue(), refund.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", refund.getConversationId()); assertEquals(payment.getPaymentId(), refund.getPaymentId()); assertEquals(payment.getPaymentItems().get(0).getPaymentTransactionId(), refund.getPaymentTransactionId()); @@ -69,6 +70,7 @@ public void should_refund_fraudulent_payment() { assertEquals(Status.SUCCESS.getValue(), refund.getStatus()); assertEquals(Locale.TR.getValue(), refund.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", refund.getConversationId()); assertEquals(payment.getPaymentId(), refund.getPaymentId()); assertEquals(payment.getPaymentItems().get(0).getPaymentTransactionId(), refund.getPaymentTransactionId()); diff --git a/src/test/java/com/iyzipay/functional/ThreedsTest.java b/src/test/java/com/iyzipay/functional/ThreedsTest.java index 8992f1f1..885ae600 100644 --- a/src/test/java/com/iyzipay/functional/ThreedsTest.java +++ b/src/test/java/com/iyzipay/functional/ThreedsTest.java @@ -16,6 +16,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ThreedsTest extends BaseTest { @@ -32,6 +33,7 @@ public void should_create_payment_with_physical_and_virtual_item_for_standard_me assertEquals(Locale.TR.getValue(), threedsInitialize.getLocale()); assertEquals(Status.SUCCESS.getValue(), threedsInitialize.getStatus()); + assertTrue(threedsInitialize.verifySignature(options.getSecretKey())); assertNotEquals(0, threedsInitialize.getSystemTime()); assertNotNull(threedsInitialize.getHtmlContent()); assertNull(threedsInitialize.getErrorCode()); @@ -58,6 +60,7 @@ public void should_create_threeds_payment_with_physical_and_virtual_item_for_mar assertEquals(Locale.TR.getValue(), threedsInitialize.getLocale()); assertEquals(Status.SUCCESS.getValue(), threedsInitialize.getStatus()); + assertTrue(threedsInitialize.verifySignature(options.getSecretKey())); assertNotEquals(0, threedsInitialize.getSystemTime()); assertNotNull(threedsInitialize.getHtmlContent()); assertNull(threedsInitialize.getErrorCode()); diff --git a/src/test/java/com/iyzipay/sample/ApmSample.java b/src/test/java/com/iyzipay/sample/ApmSample.java index ee67220f..1e33df1a 100644 --- a/src/test/java/com/iyzipay/sample/ApmSample.java +++ b/src/test/java/com/iyzipay/sample/ApmSample.java @@ -97,6 +97,7 @@ public void should_initialize_apm_payment() { assertEquals(Status.SUCCESS.getValue(), apmInitialize.getStatus()); assertEquals(Locale.TR.getValue(), apmInitialize.getLocale()); + assertTrue(apmInitialize.verifySignatureForCreate(options.getSecretKey())); assertEquals("123456789", apmInitialize.getConversationId()); assertNotNull(apmInitialize.getRedirectUrl()); assertNull(apmInitialize.getErrorCode()); @@ -117,6 +118,7 @@ public void should_retrieve_apm_result() { assertEquals(Status.SUCCESS.getValue(), retrieve.getStatus()); assertEquals(Locale.TR.getValue(), retrieve.getLocale()); + assertTrue(retrieve.verifySignatureForRetrieve(options.getSecretKey())); assertEquals("123456789", retrieve.getConversationId()); } } diff --git a/src/test/java/com/iyzipay/sample/BkmSample.java b/src/test/java/com/iyzipay/sample/BkmSample.java index 8ffc647a..41a46cc3 100644 --- a/src/test/java/com/iyzipay/sample/BkmSample.java +++ b/src/test/java/com/iyzipay/sample/BkmSample.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class BkmSample extends Sample { @@ -108,6 +109,7 @@ public void should_initialize_bkm() { assertEquals(Status.SUCCESS.getValue(), bkmInitialize.getStatus()); assertEquals(Locale.TR.getValue(), bkmInitialize.getLocale()); + assertTrue(bkmInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", bkmInitialize.getConversationId()); assertNotEquals(0, bkmInitialize.getSystemTime()); assertNull(bkmInitialize.getErrorCode()); @@ -129,6 +131,7 @@ public void should_retrieve_bkm_result() { assertEquals(Status.SUCCESS.getValue(), bkm.getStatus()); assertEquals(Locale.TR.getValue(), bkm.getLocale()); + assertTrue(bkm.verifySignature(options.getSecretKey())); assertEquals("123456789", bkm.getConversationId()); assertNotEquals(0, bkm.getSystemTime()); assertNull(bkm.getErrorCode()); diff --git a/src/test/java/com/iyzipay/sample/CheckoutFormSample.java b/src/test/java/com/iyzipay/sample/CheckoutFormSample.java index fe7f9602..6cd7b520 100644 --- a/src/test/java/com/iyzipay/sample/CheckoutFormSample.java +++ b/src/test/java/com/iyzipay/sample/CheckoutFormSample.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class CheckoutFormSample extends Sample { @@ -103,6 +104,7 @@ public void should_initialize_checkout_form() { assertEquals(Status.SUCCESS.getValue(), checkoutFormInitialize.getStatus()); assertEquals(Locale.TR.getValue(), checkoutFormInitialize.getLocale()); + assertTrue(checkoutFormInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", checkoutFormInitialize.getConversationId()); assertNotEquals(0, checkoutFormInitialize.getSystemTime()); assertNull(checkoutFormInitialize.getErrorCode()); @@ -125,6 +127,7 @@ public void should_retrieve_checkout_form_result() { assertEquals(Status.SUCCESS.getValue(), checkoutForm.getStatus()); assertEquals(Locale.TR.getValue(), checkoutForm.getLocale()); + assertTrue(checkoutForm.verifySignature(options.getSecretKey())); assertEquals("123456789", checkoutForm.getConversationId()); assertNotEquals(0, checkoutForm.getSystemTime()); assertNull(checkoutForm.getErrorCode()); diff --git a/src/test/java/com/iyzipay/sample/PayWithIyzicoSample.java b/src/test/java/com/iyzipay/sample/PayWithIyzicoSample.java index 6ebdc19a..2bd11a76 100644 --- a/src/test/java/com/iyzipay/sample/PayWithIyzicoSample.java +++ b/src/test/java/com/iyzipay/sample/PayWithIyzicoSample.java @@ -101,6 +101,7 @@ public void should_initialize_pay_with_iyzico() { assertEquals(Status.SUCCESS.getValue(), payWithIyzicoInitialize.getStatus()); assertEquals(Locale.TR.getValue(), payWithIyzicoInitialize.getLocale()); + assertTrue(payWithIyzicoInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", payWithIyzicoInitialize.getConversationId()); assertNotEquals(0, payWithIyzicoInitialize.getSystemTime()); assertNull(payWithIyzicoInitialize.getErrorCode()); @@ -210,6 +211,7 @@ public void should_initialize_pay_with_iyzico_marketplace() { assertEquals(Status.SUCCESS.getValue(), payWithIyzicoInitialize.getStatus()); assertEquals(Locale.TR.getValue(), payWithIyzicoInitialize.getLocale()); + assertTrue(payWithIyzicoInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", payWithIyzicoInitialize.getConversationId()); assertNotEquals(0, payWithIyzicoInitialize.getSystemTime()); assertNull(payWithIyzicoInitialize.getErrorCode()); diff --git a/src/test/java/com/iyzipay/sample/PaymentSample.java b/src/test/java/com/iyzipay/sample/PaymentSample.java index 9d1f9922..b6163273 100644 --- a/src/test/java/com/iyzipay/sample/PaymentSample.java +++ b/src/test/java/com/iyzipay/sample/PaymentSample.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class PaymentSample extends Sample { @@ -115,6 +116,7 @@ public void should_create_payment() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); @@ -217,6 +219,7 @@ public void should_create_marketplace_payment() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); @@ -309,6 +312,7 @@ public void should_create_payment_with_registered_card() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); @@ -330,6 +334,7 @@ public void should_retrieve_payment_result() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); @@ -433,6 +438,7 @@ public void should_create_mock_payment_with_loyalty_ykb_world() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); @@ -536,6 +542,7 @@ public void should_create_mock_payment_with_loyalty_denizbank_bonus() { assertEquals(Status.SUCCESS.getValue(), payment.getStatus()); assertEquals(Locale.TR.getValue(), payment.getLocale()); + assertTrue(payment.verifySignature(options.getSecretKey())); assertEquals("123456789", payment.getConversationId()); assertNotEquals(0, payment.getSystemTime()); assertNull(payment.getErrorCode()); diff --git a/src/test/java/com/iyzipay/sample/ThreedsSample.java b/src/test/java/com/iyzipay/sample/ThreedsSample.java index 08cdaf5f..d3119ea1 100644 --- a/src/test/java/com/iyzipay/sample/ThreedsSample.java +++ b/src/test/java/com/iyzipay/sample/ThreedsSample.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ThreedsSample extends Sample { @@ -119,6 +120,7 @@ public void should_initialize_threeds() { assertEquals(Status.SUCCESS.getValue(), threedsInitialize.getStatus()); assertEquals(Locale.TR.getValue(), threedsInitialize.getLocale()); + assertTrue(threedsInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", threedsInitialize.getConversationId()); assertNotEquals(0, threedsInitialize.getSystemTime()); assertNull(threedsInitialize.getErrorCode()); @@ -141,6 +143,7 @@ public void should_create_threeds_payment() { assertEquals(Status.SUCCESS.getValue(), threedsPayment.getStatus()); assertEquals(Locale.TR.getValue(), threedsPayment.getLocale()); + assertTrue(threedsPayment.verifySignature(options.getSecretKey())); assertEquals("123456789", threedsPayment.getConversationId()); assertNotEquals(0, threedsPayment.getSystemTime()); assertNull(threedsPayment.getErrorCode()); @@ -267,6 +270,7 @@ public void should_initialize_mock_threeds_loyalty_ykb_world() { assertEquals(Status.SUCCESS.getValue(), threedsInitialize.getStatus()); assertEquals(Locale.TR.getValue(), threedsInitialize.getLocale()); + assertTrue(threedsInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", threedsInitialize.getConversationId()); assertNotEquals(0, threedsInitialize.getSystemTime()); assertNull(threedsInitialize.getErrorCode()); @@ -370,6 +374,7 @@ public void should_initialize_mock_threeds_loyalty_deniz_bonus() { assertEquals(Status.SUCCESS.getValue(), threedsInitialize.getStatus()); assertEquals(Locale.TR.getValue(), threedsInitialize.getLocale()); + assertTrue(threedsInitialize.verifySignature(options.getSecretKey())); assertEquals("123456789", threedsInitialize.getConversationId()); assertNotEquals(0, threedsInitialize.getSystemTime()); assertNull(threedsInitialize.getErrorCode());