Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-22397 adds threeds auth v2 integration and sample #153

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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