diff --git a/src/main/java/com/iyzipay/model/ThreedsPayment.java b/src/main/java/com/iyzipay/model/ThreedsPayment.java index fc129c9..416c038 100644 --- a/src/main/java/com/iyzipay/model/ThreedsPayment.java +++ b/src/main/java/com/iyzipay/model/ThreedsPayment.java @@ -3,6 +3,7 @@ import com.iyzipay.HttpClient; import com.iyzipay.Options; import com.iyzipay.request.CreateThreedsPaymentRequest; +import com.iyzipay.request.CreateThreedsPaymentRequestV2; import com.iyzipay.request.RetrievePaymentRequest; public class ThreedsPayment extends PaymentResource { @@ -15,6 +16,14 @@ public static ThreedsPayment create(CreateThreedsPaymentRequest request, Options ThreedsPayment.class); } + public static ThreedsPayment createV2(CreateThreedsPaymentRequestV2 request, Options options) { + return HttpClient.create().post(options.getBaseUrl() + "/payment/v2/3dsecure/auth", + getHttpProxy(options), + getHttpHeaders(request, options), + request, + ThreedsPayment.class); + } + public static ThreedsPayment retrieve(RetrievePaymentRequest request, Options options) { return HttpClient.create().post(options.getBaseUrl() + "/payment/detail", getHttpProxy(options), diff --git a/src/main/java/com/iyzipay/request/CreateThreedsPaymentRequestV2.java b/src/main/java/com/iyzipay/request/CreateThreedsPaymentRequestV2.java new file mode 100644 index 0000000..84669f1 --- /dev/null +++ b/src/main/java/com/iyzipay/request/CreateThreedsPaymentRequestV2.java @@ -0,0 +1,46 @@ +package com.iyzipay.request; + +import com.iyzipay.ToStringRequestBuilder; + +import java.math.BigDecimal; + +public class CreateThreedsPaymentRequestV2 extends CreateThreedsPaymentRequest { + + private String basketId; + private BigDecimal paidPrice; + private String currency; + + public String getBasketId() { + return basketId; + } + + public void setBasketId(String basketId) { + this.basketId = basketId; + } + + public BigDecimal getPaidPrice() { + return paidPrice; + } + + public void setPaidPrice(BigDecimal paidPrice) { + this.paidPrice = paidPrice; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + @Override + public String toString() { + return new ToStringRequestBuilder(this) + .appendSuper(super.toString()) + .append("basketId", basketId) + .append("paidPrice", paidPrice) + .append("currency", currency) + .toString(); + } +} diff --git a/src/test/java/com/iyzipay/sample/ThreedsSample.java b/src/test/java/com/iyzipay/sample/ThreedsSample.java index fd96401..08cdaf5 100644 --- a/src/test/java/com/iyzipay/sample/ThreedsSample.java +++ b/src/test/java/com/iyzipay/sample/ThreedsSample.java @@ -15,6 +15,7 @@ import com.iyzipay.model.loyalty.Loyalty; import com.iyzipay.request.CreatePaymentRequest; import com.iyzipay.request.CreateThreedsPaymentRequest; +import com.iyzipay.request.CreateThreedsPaymentRequestV2; import org.junit.Test; import java.math.BigDecimal; @@ -147,6 +148,30 @@ public void should_create_threeds_payment() { assertNull(threedsPayment.getErrorGroup()); } + @Test + public void should_create_threeds_payment_v2() { + CreateThreedsPaymentRequestV2 request = new CreateThreedsPaymentRequestV2(); + request.setLocale(Locale.TR.getValue()); + request.setConversationId("123456789"); + request.setPaymentId("1"); + request.setConversationData("conversation data"); + request.setBasketId("B67832"); + request.setCurrency("TRY"); + request.setPaidPrice(new BigDecimal("1.2")); + + ThreedsPayment threedsPayment = ThreedsPayment.createV2(request, options); + + System.out.println(threedsPayment); + + assertEquals(Status.SUCCESS.getValue(), threedsPayment.getStatus()); + assertEquals(Locale.TR.getValue(), threedsPayment.getLocale()); + assertEquals("123456789", threedsPayment.getConversationId()); + assertNotEquals(0, threedsPayment.getSystemTime()); + assertNull(threedsPayment.getErrorCode()); + assertNull(threedsPayment.getErrorMessage()); + assertNull(threedsPayment.getErrorGroup()); + } + @Test public void should_initialize_mock_threeds_loyalty_ykb_world() { CreatePaymentRequest request = new CreatePaymentRequest();