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

feat: 0.29.2 Add payment service token methods, update open api spec, fix ci #53

Merged
merged 6 commits into from
Jul 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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
java-version: '18'

- name: Install dependencies & run tests
env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
run: mvn install -DskipTests
run: mvn install
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>gr4vy</artifactId>
<packaging>jar</packaging>
<name>gr4vy</name>
<version>0.29.1</version>
<version>0.29.2</version>
<url>https://gr4vy.com</url>
<description>Gr4vy Java SDK</description>

Expand Down Expand Up @@ -259,7 +259,7 @@
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<gson-fire-version>1.8.5</gson-fire-version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Additional options for Cybersource payment gateway.
Expand All @@ -34,6 +37,14 @@ public class ConnectionOptionsCybersourceCard {
@SerializedName(SERIALIZED_NAME_META_KEY_MERCHANT_ID)
private String metaKeyMerchantId;

public static final String SERIALIZED_NAME_MERCHANT_DEFINED_INFORMATION = "merchant_defined_information";
@SerializedName(SERIALIZED_NAME_MERCHANT_DEFINED_INFORMATION)
private Map<String, String> merchantDefinedInformation = null;

public static final String SERIALIZED_NAME_SHIP_TO_METHOD = "ship_to_method";
@SerializedName(SERIALIZED_NAME_SHIP_TO_METHOD)
private String shipToMethod;


public ConnectionOptionsCybersourceCard metaKeyMerchantId(String metaKeyMerchantId) {

Expand All @@ -58,6 +69,60 @@ public void setMetaKeyMerchantId(String metaKeyMerchantId) {
}


public ConnectionOptionsCybersourceCard merchantDefinedInformation(Map<String, String> merchantDefinedInformation) {

this.merchantDefinedInformation = merchantDefinedInformation;
return this;
}

public ConnectionOptionsCybersourceCard putMerchantDefinedInformationItem(String key, String merchantDefinedInformationItem) {
if (this.merchantDefinedInformation == null) {
this.merchantDefinedInformation = new HashMap<String, String>();
}
this.merchantDefinedInformation.put(key, merchantDefinedInformationItem);
return this;
}

/**
* This is a key-value object for merchant defined information. Each key needs to be a numeric string identifying the MDI field to set. For example, for field 1 set the key to \&quot;1\&quot;.
* @return merchantDefinedInformation
**/
@javax.annotation.Nullable
@ApiModelProperty(example = "{\"1\":\"John Doe\",\"2\":\"trusted\",\"99\":\"recurring\"}", value = "This is a key-value object for merchant defined information. Each key needs to be a numeric string identifying the MDI field to set. For example, for field 1 set the key to \"1\".")

public Map<String, String> getMerchantDefinedInformation() {
return merchantDefinedInformation;
}


public void setMerchantDefinedInformation(Map<String, String> merchantDefinedInformation) {
this.merchantDefinedInformation = merchantDefinedInformation;
}


public ConnectionOptionsCybersourceCard shipToMethod(String shipToMethod) {

this.shipToMethod = shipToMethod;
return this;
}

/**
* Shipping method for the order.
* @return shipToMethod
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Shipping method for the order.")

public String getShipToMethod() {
return shipToMethod;
}


public void setShipToMethod(String shipToMethod) {
this.shipToMethod = shipToMethod;
}


@Override
public boolean equals(Object o) {
if (this == o) {
Expand All @@ -67,19 +132,23 @@ public boolean equals(Object o) {
return false;
}
ConnectionOptionsCybersourceCard connectionOptionsCybersourceCard = (ConnectionOptionsCybersourceCard) o;
return Objects.equals(this.metaKeyMerchantId, connectionOptionsCybersourceCard.metaKeyMerchantId);
return Objects.equals(this.metaKeyMerchantId, connectionOptionsCybersourceCard.metaKeyMerchantId) &&
Objects.equals(this.merchantDefinedInformation, connectionOptionsCybersourceCard.merchantDefinedInformation) &&
Objects.equals(this.shipToMethod, connectionOptionsCybersourceCard.shipToMethod);
}

@Override
public int hashCode() {
return Objects.hash(metaKeyMerchantId);
return Objects.hash(metaKeyMerchantId, merchantDefinedInformation, shipToMethod);
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ConnectionOptionsCybersourceCard {\n");
sb.append(" metaKeyMerchantId: ").append(toIndentedString(metaKeyMerchantId)).append("\n");
sb.append(" merchantDefinedInformation: ").append(toIndentedString(merchantDefinedInformation)).append("\n");
sb.append(" shipToMethod: ").append(toIndentedString(shipToMethod)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/gr4vy/api/model/PaymentOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public enum MethodEnum {
SMARTPAY("smartpay"),

SOFORT("sofort"),

SPEI("spei"),

STRIPEDD("stripedd"),

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gr4vy/sdk/Gr4vyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,9 @@ public PaymentServiceToken newPaymentServiceToken(String paymentMethodId, Paymen
return this.gson.fromJson(response, PaymentServiceToken.class);
}

public PaymentServiceToken getPaymentServiceTokens(String paymentMethodId) {
public PaymentServiceTokens getPaymentServiceTokens(String paymentMethodId) {
String response = this.get("/payment-methods/" + paymentMethodId + "/payment-service-tokens");
return this.gson.fromJson(response, PaymentServiceToken.class);
return this.gson.fromJson(response, PaymentServiceTokens.class);
}

public boolean deletePaymentServiceToken(String paymentMethodId, String paymentServiceTokenId) {
Expand Down
21 changes: 14 additions & 7 deletions src/test/java/com/gr4vy/sdk/Gr4vyClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ public void addShippingDetailsToBuyerTest() throws Gr4vyException {
shippingDetails.emailAddress("shipping@test.com");

ShippingDetail shippingResponse = shared.addShippingDetailsToBuyer(response.getId().toString(), shippingDetails);
System.out.println(shippingResponse);
assert shippingResponse.getId() != null;

ShippingDetails details = shared.listShippingDetailsForBuyer(response.getId().toString());
Expand Down Expand Up @@ -211,7 +210,7 @@ public void newFailTransactionTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23");
.expirationDate("12/26");

TransactionRequest request = new TransactionRequest()
.amount(100)
Expand All @@ -234,7 +233,7 @@ public void newTransactionTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23");
.expirationDate("12/26");

TransactionRequest request = new TransactionRequest()
.amount(100)
Expand All @@ -251,7 +250,7 @@ public void newTransactionWithIdempotencyTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23");
.expirationDate("12/26");

TransactionRequest request = new TransactionRequest()
.amount(100)
Expand Down Expand Up @@ -293,7 +292,7 @@ public void captureTransactionTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23")
.expirationDate("12/26")
.redirectUrl("https://gr4vy.com");

TransactionRequest request = new TransactionRequest()
Expand All @@ -317,7 +316,7 @@ public void voidTransactionTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23")
.expirationDate("12/26")
.redirectUrl("https://gr4vy.com");

TransactionRequest request = new TransactionRequest()
Expand All @@ -339,7 +338,7 @@ public void refundTransactionTest() throws Gr4vyException {
.method(MethodEnum.CARD)
.number("4111111111111111")
.securityCode("123")
.expirationDate("12/23")
.expirationDate("12/26")
.redirectUrl("https://gr4vy.com");

TransactionRequest request = new TransactionRequest()
Expand Down Expand Up @@ -483,4 +482,12 @@ public void listPaymentOptionsTest() throws Gr4vyException {
assert response != null;
}

@Test
public void getPaymentServiceTokensTest() throws Gr4vyException {
PaymentMethods paymentMethods = shared.listPaymentMethods();
PaymentMethod paymentMethod = paymentMethods.getItems().get(0);
PaymentServiceTokens response = shared.getPaymentServiceTokens(paymentMethod.getId().toString());
assert response != null;
}

}
Loading