Skip to content

Commit

Permalink
DEV-22397 adds threeds auth v2 integration and sample
Browse files Browse the repository at this point in the history
  • Loading branch information
recaifurkan committed Jan 8, 2024
1 parent 428c6a1 commit 6213610
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/iyzipay/model/ThreedsPayment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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),
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
25 changes: 25 additions & 0 deletions src/test/java/com/iyzipay/sample/ThreedsSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6213610

Please sign in to comment.