diff --git a/README.md b/README.md
index c6ea6b6..5730cb8 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@ To install, add the following dependency to your pom.xml:
mx.openpay
openpay-api-client
- 1.7.0
+ 1.8.0
```
diff --git a/pom.xml b/pom.xml
index eb0979d..7d46169 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,18 +3,12 @@
4.0.0
mx.openpay
openpay-api-client
- 1.7.0
+ 1.9.9-SNAPSHOT
jar
+
openpay-api-client
Java client for Openpay Services
http://github.com/open-pay/openpay-java
-
-
-
- org.sonatype.oss
- oss-parent
- 7
-
@@ -24,12 +18,6 @@
-
- scm:git:https://github.com/open-pay/openpay-java.git
- scm:git:https://github.com/open-pay/openpay-java.git
- http://github.com/open-pay/openpay-java
-
-
Heber Lazcano
@@ -45,11 +33,28 @@
+
+
com.google.code.gson
gson
- 2.2.4
+ 2.9.0
compile
@@ -110,11 +115,21 @@
slf4j-api
1.7.5
-
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.17.2
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.17.2
org.slf4j
@@ -134,6 +149,7 @@
20020423
test
+
@@ -192,10 +208,32 @@
+
+
+
org.apache.maven.plugins
maven-source-plugin
- 2.2.1
+ 3.2.1
attach-sources
@@ -209,7 +247,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.9.1
+ 3.2.0
attach-javadoc
@@ -262,10 +300,10 @@
org.apache.maven.plugins
maven-gpg-plugin
- 1.4
+ 1.6
${gpg.keyname}
- ${gpg.passphrase}
+ ${gpg.passphrase}
@@ -285,4 +323,4 @@
Openpay
-
+
\ No newline at end of file
diff --git a/src/main/java/mx/openpay/client/Checkout.java b/src/main/java/mx/openpay/client/Checkout.java
index 2edfa01..da67540 100644
--- a/src/main/java/mx/openpay/client/Checkout.java
+++ b/src/main/java/mx/openpay/client/Checkout.java
@@ -34,7 +34,13 @@ public class Checkout {
@SerializedName("expiration_date")
private Date expirationDate;
+ @SerializedName("plan_id")
+ private Integer planId;
+
private Customer customer;
private Transaction transaction;
+
+ @SerializedName("origin")
+ private String originChannel;
}
diff --git a/src/main/java/mx/openpay/client/CheckoutResponse.java b/src/main/java/mx/openpay/client/CheckoutResponse.java
new file mode 100644
index 0000000..2c64383
--- /dev/null
+++ b/src/main/java/mx/openpay/client/CheckoutResponse.java
@@ -0,0 +1,48 @@
+package mx.openpay.client;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.math.BigDecimal;
+
+
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class CheckoutResponse {
+
+
+ private String id;
+
+ private BigDecimal amount;
+
+ private String description;
+
+ @SerializedName("order_id")
+ private String orderId;
+
+ private String currency;
+
+ private String iva;
+
+ private String status;
+
+ @SerializedName("checkout_link")
+ private String checkoutLink;
+
+ @SerializedName("creation_date")
+ private String creationDate;
+
+ @SerializedName("expiration_date")
+ private String expirationDate;
+
+ @SerializedName("plan_id")
+ private Integer planId;
+
+ private Customer customer;
+
+ private Transaction transaction;
+}
+
diff --git a/src/main/java/mx/openpay/client/DeferralPayments.java b/src/main/java/mx/openpay/client/DeferralPayments.java
index 7b53eb3..fc2cb6a 100644
--- a/src/main/java/mx/openpay/client/DeferralPayments.java
+++ b/src/main/java/mx/openpay/client/DeferralPayments.java
@@ -1,7 +1,9 @@
package mx.openpay.client;
+import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Data;
+import mx.openpay.client.enums.PaymentType;
/**
* The Class DeferralPayments.
@@ -13,4 +15,10 @@ public class DeferralPayments {
/** The payments. */
private Integer payments;
+ @SerializedName("payments_type")
+ private PaymentType paymentsType;
+
+ public DeferralPayments(Integer payments) {
+ this.payments = payments;
+ }
}
diff --git a/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponse.java b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponse.java
new file mode 100644
index 0000000..11a4dd0
--- /dev/null
+++ b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponse.java
@@ -0,0 +1,35 @@
+package mx.openpay.client;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.math.BigDecimal;
+
+@Getter
+@Setter
+@ToString
+
+public class OpenCheckoutConfigurationResponse {
+
+ private String id;
+ private String name;
+ private BigDecimal amount;
+ private BigDecimal iva;
+ private String currency;
+ private String description;
+ @SerializedName("redirect_url")
+ private String redirectUrl;
+ @SerializedName("open_checkout_configuration_link")
+ private String openCheckoutConfigurationLink;
+ @SerializedName("expiration_date")
+ private String expirationDate;
+ @SerializedName("creation_date")
+ private String creationDate;
+ @SerializedName("deletion_date")
+ private String deletionDate;
+ private String status;
+ @SerializedName("sales_number")
+ private int salesNumber;
+}
diff --git a/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponseLight.java b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponseLight.java
new file mode 100644
index 0000000..a006b1e
--- /dev/null
+++ b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponseLight.java
@@ -0,0 +1,20 @@
+package mx.openpay.client;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class OpenCheckoutConfigurationResponseLight {
+
+ @SerializedName("id")
+ private String id;
+
+ @SerializedName("name")
+ private String name;
+
+ }
+
diff --git a/src/main/java/mx/openpay/client/OpenCheckoutConfigurationSearchResponse.java b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationSearchResponse.java
new file mode 100644
index 0000000..3b2dc88
--- /dev/null
+++ b/src/main/java/mx/openpay/client/OpenCheckoutConfigurationSearchResponse.java
@@ -0,0 +1,22 @@
+package mx.openpay.client;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.List;
+@Getter
+@Setter
+@ToString
+public class OpenCheckoutConfigurationSearchResponse {
+ @SerializedName("configurations")
+ private List configurations;
+ @SerializedName("search_details")
+ private SearchDetails searchDetails;
+
+
+
+
+
+}
diff --git a/src/main/java/mx/openpay/client/SearchDetails.java b/src/main/java/mx/openpay/client/SearchDetails.java
new file mode 100644
index 0000000..b02910c
--- /dev/null
+++ b/src/main/java/mx/openpay/client/SearchDetails.java
@@ -0,0 +1,17 @@
+package mx.openpay.client;
+
+import com.google.gson.annotations.SerializedName;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class SearchDetails {
+
+ @SerializedName("returned_elements")
+ private Integer returnedElements;
+ @SerializedName("total_elements")
+ private Integer totalElements;
+}
diff --git a/src/main/java/mx/openpay/client/Subscription.java b/src/main/java/mx/openpay/client/Subscription.java
index 367a41f..402a45e 100644
--- a/src/main/java/mx/openpay/client/Subscription.java
+++ b/src/main/java/mx/openpay/client/Subscription.java
@@ -62,6 +62,9 @@ public class Subscription {
@SerializedName("source_id")
private String sourceId;
+ @SerializedName("order_id")
+ private String orderId;
+
private Card card;
private Transaction transaction;
diff --git a/src/main/java/mx/openpay/client/Transaction.java b/src/main/java/mx/openpay/client/Transaction.java
index 40e15cb..ee41c20 100644
--- a/src/main/java/mx/openpay/client/Transaction.java
+++ b/src/main/java/mx/openpay/client/Transaction.java
@@ -90,4 +90,6 @@ public class Transaction {
/** Optional gateway affiliation information. */
private GatewayResponse gateway;
+ @SerializedName("origin_channel")
+ private String originChannel;
}
diff --git a/src/main/java/mx/openpay/client/core/HttpServiceClient.java b/src/main/java/mx/openpay/client/core/HttpServiceClient.java
index 6337dc5..584b343 100644
--- a/src/main/java/mx/openpay/client/core/HttpServiceClient.java
+++ b/src/main/java/mx/openpay/client/core/HttpServiceClient.java
@@ -28,6 +28,8 @@ public interface HttpServiceClient {
public void setKey(final String key);
+ public void setPublicIp(final String publicIp);
+
/**
* Optional method to set connection timeout. Should do nothing if not implemented.
* @param timeoutMillis
diff --git a/src/main/java/mx/openpay/client/core/JsonServiceClient.java b/src/main/java/mx/openpay/client/core/JsonServiceClient.java
index e61160b..e0c3b38 100644
--- a/src/main/java/mx/openpay/client/core/JsonServiceClient.java
+++ b/src/main/java/mx/openpay/client/core/JsonServiceClient.java
@@ -56,7 +56,18 @@ public class JsonServiceClient {
* @param key Public or private key. Public Key may have limited permissions.
*/
public JsonServiceClient(final String location, final String merchantId, final String key) {
- this(location, merchantId, key, new DefaultSerializer(), new DefaultHttpServiceClient(true));
+ this(location, merchantId, key, null, new DefaultSerializer(), new DefaultHttpServiceClient(true));
+ }
+
+ /**
+ * Initializes a JsonServiceClient with the default JsonSerializer and HttpServiceClient.
+ * @param location Base URL of the Webservice.
+ * @param merchantId Merchant's Id.
+ * @param key Public or private key. Public Key may have limited permissions.
+ * @param publicIp Public IP
+ */
+ public JsonServiceClient(final String location, final String merchantId, final String key, final String publicIp) {
+ this(location, merchantId, key, publicIp, new DefaultSerializer(), new DefaultHttpServiceClient(true));
}
/**
@@ -69,7 +80,7 @@ public JsonServiceClient(final String location, final String merchantId, final S
* @param httpClient
*/
public JsonServiceClient(final String location, final String merchantId, final String key,
- final JsonSerializer serializer, final HttpServiceClient httpClient) {
+ final String publicIp, final JsonSerializer serializer, final HttpServiceClient httpClient) {
this.validateParameters(location, merchantId);
String url = this.getUrl(location);
this.root = url;
@@ -77,6 +88,7 @@ public JsonServiceClient(final String location, final String merchantId, final S
this.serializer = serializer;
this.httpClient = httpClient;
this.httpClient.setKey(key);
+ this.httpClient.setPublicIp(publicIp);
}
private void validateParameters(final String location, final String merchantId) {
diff --git a/src/main/java/mx/openpay/client/core/OpenpayAPI.java b/src/main/java/mx/openpay/client/core/OpenpayAPI.java
index 97652c4..a41ba50 100644
--- a/src/main/java/mx/openpay/client/core/OpenpayAPI.java
+++ b/src/main/java/mx/openpay/client/core/OpenpayAPI.java
@@ -64,10 +64,16 @@ public class OpenpayAPI {
private final CheckoutsOperations checkoutsOperations;
+ private final OpenCheckoutOperations openCheckoutOperations;
+
public OpenpayAPI(final String location, final String apiKey, final String merchantId) {
this(new JsonServiceClient(location, merchantId, apiKey));
}
+ public OpenpayAPI(final String location, final String apiKey, final String merchantId, final String publicIp) {
+ this(new JsonServiceClient(location, merchantId, apiKey, publicIp));
+ }
+
public OpenpayAPI(final JsonServiceClient client) {
this.jsonClient = client;
this.cardOperations = new CardOperations(this.jsonClient);
@@ -87,6 +93,7 @@ public OpenpayAPI(final JsonServiceClient client) {
this.webhookOperations = new WebhookOperations(this.jsonClient);
this.binesOperations = new BinesOperations(this.jsonClient);
this.checkoutsOperations = new CheckoutsOperations(this.jsonClient);
+ this.openCheckoutOperations = new OpenCheckoutOperations(this.jsonClient);
}
public void setTimeout(final int timeout) {
@@ -162,4 +169,6 @@ public CheckoutsOperations checkouts() {
return this.checkoutsOperations;
}
+ public OpenCheckoutOperations openCheckout(){return this.openCheckoutOperations;}
+
}
diff --git a/src/main/java/mx/openpay/client/core/impl/DefaultHttpServiceClient.java b/src/main/java/mx/openpay/client/core/impl/DefaultHttpServiceClient.java
index c5f67eb..8934a67 100644
--- a/src/main/java/mx/openpay/client/core/impl/DefaultHttpServiceClient.java
+++ b/src/main/java/mx/openpay/client/core/impl/DefaultHttpServiceClient.java
@@ -86,6 +86,9 @@ public class DefaultHttpServiceClient implements HttpServiceClient {
@Setter
private String key;
+ @Setter
+ private String publicIp;
+
public DefaultHttpServiceClient(final boolean requirePoolManager) {
this.httpClient = this.initHttpClient(requirePoolManager, DEFAULT_CONNECTION_TIMEOUT,
DEFAULT_CONNECTION_TIMEOUT);
@@ -236,6 +239,9 @@ protected void addHeaders(final HttpRequestBase request) {
request.addHeader(new BasicHeader("User-Agent", this.userAgent));
request.addHeader(new BasicHeader("Accept", "application/json"));
request.setHeader(new BasicHeader("Content-Type", "application/json"));
+ if(this.publicIp != null) {
+ request.setHeader(new BasicHeader("X-Forwarded-For", this.publicIp));
+ }
}
protected void addAuthentication(final HttpRequestBase request) {
diff --git a/src/main/java/mx/openpay/client/core/impl/ListTypes.java b/src/main/java/mx/openpay/client/core/impl/ListTypes.java
index 1122172..36893a1 100644
--- a/src/main/java/mx/openpay/client/core/impl/ListTypes.java
+++ b/src/main/java/mx/openpay/client/core/impl/ListTypes.java
@@ -23,19 +23,7 @@
import com.google.gson.reflect.TypeToken;
-import mx.openpay.client.BankAccount;
-import mx.openpay.client.Card;
-import mx.openpay.client.Charge;
-import mx.openpay.client.Customer;
-import mx.openpay.client.Fee;
-import mx.openpay.client.GenericTransaction;
-import mx.openpay.client.Order;
-import mx.openpay.client.PaymentPlan;
-import mx.openpay.client.Payout;
-import mx.openpay.client.Plan;
-import mx.openpay.client.Subscription;
-import mx.openpay.client.Transfer;
-import mx.openpay.client.Webhook;
+import mx.openpay.client.*;
/**
* @author elopez
@@ -72,6 +60,10 @@ public class ListTypes {
}.getType());
map.put(Webhook.class, new TypeToken>() {
}.getType());
+ map.put(OpenCheckoutConfigurationResponseLight.class, new TypeToken>() {
+ }.getType());
+ map.put(CheckoutResponse.class, new TypeToken>(){
+ }.getType());
TYPES_MAP = Collections.unmodifiableMap(map);
}
diff --git a/src/main/java/mx/openpay/client/core/operations/CheckoutsOperations.java b/src/main/java/mx/openpay/client/core/operations/CheckoutsOperations.java
index e7d9baf..88f4db2 100644
--- a/src/main/java/mx/openpay/client/core/operations/CheckoutsOperations.java
+++ b/src/main/java/mx/openpay/client/core/operations/CheckoutsOperations.java
@@ -1,10 +1,16 @@
package mx.openpay.client.core.operations;
import mx.openpay.client.Checkout;
+import mx.openpay.client.CheckoutResponse;
import mx.openpay.client.core.JsonServiceClient;
import mx.openpay.client.core.requests.RequestBuilder;
import mx.openpay.client.exceptions.OpenpayServiceException;
import mx.openpay.client.exceptions.ServiceUnavailableException;
+import mx.openpay.client.utils.SearchCheckoutParams;
+import mx.openpay.client.utils.SearchOpenCheckoutParams;
+
+import java.util.List;
+import java.util.Map;
import static mx.openpay.client.utils.OpenpayPathComponents.*;
import static mx.openpay.client.utils.OpenpayPathComponents.ID;
@@ -56,4 +62,17 @@ public Checkout getCheckoutByCheckoutIdOrOrderId(final String checkoutOrOrderId)
String path = String.format(FOR_GET_CHECKOUT_PATH, this.getMerchantId(), checkoutOrOrderId);
return this.getJsonClient().get(path, Checkout.class);
}
+
+ /**
+ * Get a specific checkout by merchantid
+ * @param merchantId
+ * @return
+ * @throws OpenpayServiceException
+ * @throws ServiceUnavailableException
+ */
+ public List getCheckoutsByMerchant(final String merchantId, SearchCheckoutParams params) throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(FOR_MERCHANT_PATH, this.getMerchantId(), FOR_MERCHANT_PATH);
+ Map map = params.asMap();
+ return this.getJsonClient().list(path, map,CheckoutResponse.class);
+ }
}
diff --git a/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java b/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java
new file mode 100644
index 0000000..df7b512
--- /dev/null
+++ b/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java
@@ -0,0 +1,134 @@
+package mx.openpay.client.core.operations;
+
+import mx.openpay.client.OpenCheckoutConfigurationResponse;
+import mx.openpay.client.OpenCheckoutConfigurationResponseLight;
+import mx.openpay.client.OpenCheckoutConfigurationSearchResponse;
+import mx.openpay.client.core.JsonServiceClient;
+import mx.openpay.client.core.requests.RequestBuilder;
+import mx.openpay.client.exceptions.OpenpayServiceException;
+import mx.openpay.client.exceptions.ServiceUnavailableException;
+import mx.openpay.client.utils.SearchOpenCheckoutParams;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+public class OpenCheckoutOperations extends ServiceOperations{
+
+ private static final String OPEN_CHECKOUT_CONFIGURATIONS_PAGE = "/open-checkout-configurations";
+
+ private static final String OPEN_CHECKOUT_CONFIGURATION = "/%s/open-checkout-configuration";
+
+ private static final String OPEN_CHECKOUT_CONFIGURATION_DETAIL = "/%s" + OPEN_CHECKOUT_CONFIGURATIONS_PAGE + "/%s";
+
+ private static final String OPEN_CHECKOUT_CONFIGURATION_LIGHT = "/%s" + OPEN_CHECKOUT_CONFIGURATIONS_PAGE + "/light";
+
+
+ private static final String OPEN_CHECKOUT_CONFIGURATION_MERCHANT = "/%s" + OPEN_CHECKOUT_CONFIGURATIONS_PAGE;
+
+
+ public OpenCheckoutOperations(JsonServiceClient client) {
+ super(client);
+ }
+
+
+ /**
+ * Creates open checkout at the Customer level.
+ *
+ * @param request Generic request params.
+ * @return OpenCheckout data returned by Openpay
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+ public OpenCheckoutConfigurationResponse createOpenCheckout( final RequestBuilder request)
+ throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION, this.getMerchantId());
+ return this.getJsonClient().post(path, request.asMap(), OpenCheckoutConfigurationResponse.class);
+ }
+
+
+ /**
+ * Update open checkout at the Customer level.
+ *
+ * @param request Generic request params.
+ * @return OpenCheckout data returned by Openpay
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+ public OpenCheckoutConfigurationResponse updateOpenCheckout( final RequestBuilder request)
+ throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION, this.getMerchantId());
+ return this.getJsonClient().put(path, request.asMap(), OpenCheckoutConfigurationResponse.class);
+ }
+
+
+ /**
+ * Permite consultar las configuraciones del comercio (que no hayan sido eliminadas).
+ *
+ * @param merchantId El identificador público del comercio.
+ * @param params parametros para la busqueda
+ * @return La lista de configuraciones.
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+
+ public OpenCheckoutConfigurationSearchResponse getConfigurationsByMerchant(final String merchantId, SearchOpenCheckoutParams params) throws OpenpayServiceException, ServiceUnavailableException {
+
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION_MERCHANT, this.getMerchantId());
+
+ Map map = params == null ? null : params.asMap();
+ return this.getJsonClient().get(path,map,OpenCheckoutConfigurationSearchResponse.class);
+ }
+
+ /**
+ * Permite consultar una configuracion para un comercio por id
+ *
+ * @param merchantId El identificador público del comercio.
+ * @param idOpenCheckout identificador del open checkput
+ * @return La lista de configuraciones.
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+
+ public OpenCheckoutConfigurationResponse getConfigurationsById(final String merchantId, String idOpenCheckout) throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION_DETAIL, this.getMerchantId(),idOpenCheckout);
+
+ return this.getJsonClient().get(path,OpenCheckoutConfigurationResponse.class);
+ }
+
+
+ /**
+ * Permite borrar una configuracion para un comercio por id
+ *
+ * @param merchantId El identificador público del comercio.
+ * @param idOpenCheckout identificador del open checkput a elmiminar
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+
+ public void deleteOpencheckout(final String merchantId, String idOpenCheckout) throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION_DETAIL, this.getMerchantId(),idOpenCheckout);
+
+ this.getJsonClient().delete(path);
+ }
+ /**
+ * Permite consultar las configuraciones
+ *
+ * @param merchantId El identificador público del comercio.
+ * @return La lista de configuraciones con nombre y id .
+ * @throws OpenpayServiceException When Openpay returns an error response
+ * @throws ServiceUnavailableException When an unexpected communication error occurs.
+ */
+
+ public List getConfigurationsLight(String merchantId) throws OpenpayServiceException, ServiceUnavailableException {
+ String path = String.format(OPEN_CHECKOUT_CONFIGURATION_LIGHT, merchantId);
+
+ Map map = null;
+ return this.getJsonClient().list(path, map, OpenCheckoutConfigurationResponseLight.class);
+ }
+
+
+
+
+
+}
diff --git a/src/main/java/mx/openpay/client/core/requests/transactions/CreateBankChargeParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateBankChargeParams.java
index b001aa3..7bf50a1 100644
--- a/src/main/java/mx/openpay/client/core/requests/transactions/CreateBankChargeParams.java
+++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateBankChargeParams.java
@@ -107,5 +107,9 @@ public CreateBankChargeParams confirm(final Boolean confirm) {
public CreateBankChargeParams redirectUrl(final String redirect_url) {
return this.with("redirect_url", redirect_url);
}
-
+
+ /**
+ * Sends product type
+ */
+ public CreateBankChargeParams productType(final String productType) { return this.with("product_type", productType); }
}
diff --git a/src/main/java/mx/openpay/client/core/requests/transactions/CreateCardChargeParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateCardChargeParams.java
index 2ad0abd..104ae16 100644
--- a/src/main/java/mx/openpay/client/core/requests/transactions/CreateCardChargeParams.java
+++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateCardChargeParams.java
@@ -58,6 +58,10 @@ public CreateCardChargeParams cardId(final String cardId) {
return this.with("source_id", cardId);
}
+ public CreateCardChargeParams originChannel(final String originChannel) {
+ return this.with("origin_channel", originChannel);
+ }
+
/**
* The amount to charge to the card. Required.
*/
@@ -246,4 +250,9 @@ public CreateCardChargeParams products(final List p
public CreateCardChargeParams affiliation(final Affiliation affiliation) {
return this.with("affiliation", affiliation);
}
+
+ /**
+ * Sends product type
+ */
+ public CreateCardChargeParams productType(final String productType) { return this.with("product_type", productType); }
}
diff --git a/src/main/java/mx/openpay/client/core/requests/transactions/CreateCheckoutParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateCheckoutParams.java
index 15c8a18..3047bfb 100644
--- a/src/main/java/mx/openpay/client/core/requests/transactions/CreateCheckoutParams.java
+++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateCheckoutParams.java
@@ -84,6 +84,13 @@ public CreateCheckoutParams redirectStorePayment(Boolean redirectStorePayment) {
return this.with("redirect_store_payment", redirectStorePayment);
}
+ /**
+ * Plan for store checkout
+ */
+ public CreateCheckoutParams planIdPublic(final String planIdPublic) {
+ return this.with("plan_id_public", planIdPublic);
+ }
+
/**
* Customer Information when you want to send info but not create the resource
*/
diff --git a/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java
new file mode 100644
index 0000000..71f67e8
--- /dev/null
+++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java
@@ -0,0 +1,96 @@
+package mx.openpay.client.core.requests.transactions;
+
+import mx.openpay.client.core.requests.RequestBuilder;
+import mx.openpay.client.enums.Currency;
+
+import java.math.BigDecimal;
+
+public class CreateOpenCheckoutParams extends RequestBuilder {
+
+
+ /**
+ * The id to openCheckout for update.
+ */
+ public CreateCheckoutParams id(final String id) {
+ return this.with("id", id);
+ }
+
+ /**
+ * The amount to charge Required.
+ */
+ public CreateCheckoutParams amount(final BigDecimal amount) {
+ return this.with("amount", amount);
+ }
+
+ /**
+ * The amount to charge Required.
+ */
+ public CreateCheckoutParams name(final String name) {
+ return this.with("name", name);
+ }
+
+ /**
+ * A description to give to the charge. Optional.
+ */
+ public CreateCheckoutParams description(final String description) {
+ return this.with("description", description);
+ }
+
+ /**
+ * An unique custom identifier for the charge. Optional.
+ */
+ public CreateCheckoutParams orderId(final String orderId) {
+ return this.with("order_id", orderId);
+ }
+
+ /**
+ * A currency to give to the charge. Optional.
+ * Default value is MXN
+ *
+ * @param currency
+ * @return
+ */
+ public CreateCheckoutParams currency(final Currency currency) {
+ return this.with("currency", currency == null ? Currency.MXN.name() : currency.name());
+ }
+
+ /**
+ * A currency to give to the charge in ISO 4217 alphanumeric code. Optional.
+ * Default value is MXN
+ * @param currency
+ * @return
+ */
+ public CreateCheckoutParams currency(final String currency) {
+ return this.with("currency", currency == null ? Currency.MXN.name() : currency);
+ }
+
+ /**
+ * Sends iva
+ */
+ public CreateCheckoutParams iva(final String iva) {
+ return this.with("iva", iva);
+ }
+
+ /**
+ * Redirect Url indicate the url to redirect after completed the transaction.
+ */
+ public CreateCheckoutParams redirectUrl(final String redirectUrl) {
+ return this.with("redirect_url", redirectUrl);
+ }
+
+ /**
+ * Expiration dato to checkout
+ */
+ public CreateCheckoutParams expirationDate(final String dueDate) { return this.with("expiration_date", dueDate); }
+
+
+
+ /**
+ * Flag do open amount
+ */
+ public CreateCheckoutParams openAmount(Boolean openAmount) {
+ return this.with("open_amount", openAmount);
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/mx/openpay/client/core/requests/transactions/CreateStoreChargeParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateStoreChargeParams.java
index a5d208e..77e5841 100644
--- a/src/main/java/mx/openpay/client/core/requests/transactions/CreateStoreChargeParams.java
+++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateStoreChargeParams.java
@@ -94,5 +94,9 @@ public CreateStoreChargeParams currency(final String currency) {
public CreateStoreChargeParams iva(final String iva) {
return this.with("iva", iva);
}
-
+
+ /**
+ * Sends product type
+ */
+ public CreateStoreChargeParams productType(final String productType) { return this.with("product_type", productType); }
}
diff --git a/src/main/java/mx/openpay/client/enums/Currency.java b/src/main/java/mx/openpay/client/enums/Currency.java
index 875f1b4..9f02661 100644
--- a/src/main/java/mx/openpay/client/enums/Currency.java
+++ b/src/main/java/mx/openpay/client/enums/Currency.java
@@ -26,5 +26,14 @@ public enum Currency {
/**
* Peru peso
*/
- PEN;
+ PEN,
+ /**
+ * Argentina peso
+ */
+ ARS,
+
+ /**
+ * Euros
+ */
+ EUR
}
diff --git a/src/main/java/mx/openpay/client/enums/PaymentType.java b/src/main/java/mx/openpay/client/enums/PaymentType.java
new file mode 100644
index 0000000..c9ae710
--- /dev/null
+++ b/src/main/java/mx/openpay/client/enums/PaymentType.java
@@ -0,0 +1,10 @@
+package mx.openpay.client.enums;
+
+public enum PaymentType {
+
+ /** Months without interest */
+ WITHOUT_INTEREST,
+
+ /** Months with interest */
+ WITH_INTEREST
+}
diff --git a/src/main/java/mx/openpay/client/utils/SearchCheckoutParams.java b/src/main/java/mx/openpay/client/utils/SearchCheckoutParams.java
new file mode 100644
index 0000000..86889fb
--- /dev/null
+++ b/src/main/java/mx/openpay/client/utils/SearchCheckoutParams.java
@@ -0,0 +1,51 @@
+package mx.openpay.client.utils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class SearchCheckoutParams extends SearchParams {
+
+ private static final int DEFAULT_LIMIT_SIZE = 10;
+
+ private final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+
+ public static SearchCheckoutParams search() {
+ return new SearchCheckoutParams();
+ }
+
+ public SearchCheckoutParams() {
+ this.limit(DEFAULT_LIMIT_SIZE);
+ }
+
+
+ public SearchCheckoutParams startDate(final Date date) {
+ this.params.put("startDate", this.format.format(date));
+ return this;
+ }
+
+ public SearchCheckoutParams endDate(final Date date) {
+ this.params.put("endDate", this.format.format(date));
+ return this;
+ }
+
+ @Override
+ public SearchCheckoutParams limit(final int limit) {
+ super.limit(limit);
+ return this;
+ }
+
+ @Override
+ public SearchCheckoutParams offset(final int offset) {
+ super.offset(offset);
+ return this;
+ }
+
+
+ /**
+ * Search by amount, for charges, payouts, fees and transfers.
+ */
+ public SearchCheckoutParams nameOrLastName(final String nameOrLastName) {
+ this.params.put("nameOrLastName", nameOrLastName);
+ return this;
+ }
+}
diff --git a/src/main/java/mx/openpay/client/utils/SearchOpenCheckoutParams.java b/src/main/java/mx/openpay/client/utils/SearchOpenCheckoutParams.java
new file mode 100644
index 0000000..851b556
--- /dev/null
+++ b/src/main/java/mx/openpay/client/utils/SearchOpenCheckoutParams.java
@@ -0,0 +1,56 @@
+package mx.openpay.client.utils;
+
+
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class SearchOpenCheckoutParams extends PaginationParams {
+
+
+ private static final int DEFAULT_LIMIT_SIZE = 10;
+
+ private final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
+
+ public static SearchOpenCheckoutParams search() {
+ return new SearchOpenCheckoutParams();
+ }
+
+ public SearchOpenCheckoutParams() {
+ this.limit(DEFAULT_LIMIT_SIZE);
+ }
+
+
+ public SearchOpenCheckoutParams startDate(final Date date) {
+ this.params.put("startDate", this.format.format(date));
+ return this;
+ }
+
+ public SearchOpenCheckoutParams endDate(final Date date) {
+ this.params.put("endDate", this.format.format(date));
+ return this;
+ }
+
+ @Override
+ public SearchOpenCheckoutParams limit(final int limit) {
+ super.limit(limit);
+ return this;
+ }
+
+ @Override
+ public SearchOpenCheckoutParams offset(final int offset) {
+ super.offset(offset);
+ return this;
+ }
+
+
+ /**
+ * Search by amount, for charges, payouts, fees and transfers.
+ */
+ public SearchOpenCheckoutParams name(final String name) {
+ this.params.put("name", name);
+ return this;
+ }
+
+
+}
diff --git a/src/test/integration/mx/openpay/core/client/TestConstans.java b/src/test/integration/mx/openpay/core/client/TestConstans.java
index 2b81612..5c32d07 100644
--- a/src/test/integration/mx/openpay/core/client/TestConstans.java
+++ b/src/test/integration/mx/openpay/core/client/TestConstans.java
@@ -21,6 +21,8 @@ public class TestConstans {
public static final String MERCHANT_ID = "mtfsdeoulmcoj0xofpfc";
+ public static final String PUBLIC_IP = "127.0.0.1";
+
public static final String API_KEY = "sk_4ec3ef18cd01471487ca719f566d4d3f";
public static final String CUSTOMER_ID = "alqrigidmw9jlgngwlrj";
diff --git a/src/test/integration/mx/openpay/core/client/full/CheckoutTest.java b/src/test/integration/mx/openpay/core/client/full/CheckoutTest.java
new file mode 100644
index 0000000..659f9ae
--- /dev/null
+++ b/src/test/integration/mx/openpay/core/client/full/CheckoutTest.java
@@ -0,0 +1,36 @@
+package mx.openpay.core.client.full;
+
+import mx.openpay.client.Checkout;
+import mx.openpay.client.CheckoutResponse;
+import mx.openpay.client.exceptions.OpenpayServiceException;
+import mx.openpay.client.exceptions.ServiceUnavailableException;
+import mx.openpay.client.utils.SearchCheckoutParams;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CheckoutTest extends BaseTest{
+
+ @Test
+ public void testgetByIdMerchatn() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ String idOpencheckout = "mr6tbtk6xepcsd0ar5yc";
+
+ SearchCheckoutParams searchOpenCheckoutParams = new SearchCheckoutParams();
+
+
+ searchOpenCheckoutParams.nameOrLastName("JORDY OLIVER 2");
+ searchOpenCheckoutParams.limit(1);
+ List response = this.api.checkouts().getCheckoutsByMerchant("mr6tbtk6xepcsd0ar5yc",searchOpenCheckoutParams);
+ System.out.println(response.size());
+ assertNotNull(response);
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+}
diff --git a/src/test/integration/mx/openpay/core/client/full/ConfigurationTest.java b/src/test/integration/mx/openpay/core/client/full/ConfigurationTest.java
index 62ddde1..77d68b4 100644
--- a/src/test/integration/mx/openpay/core/client/full/ConfigurationTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/ConfigurationTest.java
@@ -18,12 +18,15 @@
import static mx.openpay.core.client.TestConstans.API_KEY;
import static mx.openpay.core.client.TestConstans.ENDPOINT;
import static mx.openpay.core.client.TestConstans.MERCHANT_ID;
+import static mx.openpay.core.client.TestConstans.PUBLIC_IP;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.TimeZone;
+import mx.openpay.client.Merchant;
+import org.apache.http.HttpStatus;
import org.junit.Test;
import mx.openpay.client.core.OpenpayAPI;
@@ -86,4 +89,11 @@ public void testNullLocation() throws Exception {
new OpenpayAPI(null, API_KEY, MERCHANT_ID);
}
+ @Test
+ public void testWithPublicIp() throws Exception {
+ OpenpayAPI api = new OpenpayAPI(ENDPOINT, API_KEY, MERCHANT_ID, PUBLIC_IP);
+ Merchant merchant = api.merchant().get();
+ assertEquals(MERCHANT_ID, merchant.getId());
+ }
+
}
diff --git a/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java b/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java
index 8465cfd..e93311a 100644
--- a/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java
@@ -47,8 +47,8 @@ public class CustomerBankPayoutsTest extends BaseTest {
@Before
public void setUp() throws Exception {
this.customer = this.api.customers().create(new Customer()
- .name("Jorge Perez").email("juan.perez@example.com")
- .phoneNumber("44200000000")
+ .name("Jorge Perez").email("juan.perez@correo.com")
+ .phoneNumber("44212033000")
.requiresAccount(true));
this.api.charges().create(this.customer.getId(), new CreateCardChargeParams()
.amount(new BigDecimal("5"))
@@ -166,7 +166,8 @@ public void testCreateCustomerBankPayout_WithBankAccount() throws ServiceUnavail
.holderName("Cuenta"))
.amount(amount)
.description(desc)
- .orderId(orderId));
+ .orderId(orderId)
+ .currency("MXN"));
Assert.assertNotNull(transaction);
Assert.assertNotNull(transaction.getCreationDate());
Assert.assertThat(transaction.getAmount(), comparesEqualTo(amount));
diff --git a/src/test/integration/mx/openpay/core/client/full/CustomerCardChargesTest.java b/src/test/integration/mx/openpay/core/client/full/CustomerCardChargesTest.java
index 8ac97bd..d98f7fa 100644
--- a/src/test/integration/mx/openpay/core/client/full/CustomerCardChargesTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/CustomerCardChargesTest.java
@@ -27,6 +27,7 @@
import java.math.BigDecimal;
+import java.util.Calendar;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -35,6 +36,7 @@
import mx.openpay.client.Card;
import mx.openpay.client.Charge;
import mx.openpay.client.Customer;
+import mx.openpay.client.core.OpenpayAPI;
import mx.openpay.client.core.requests.transactions.CancelParams;
import mx.openpay.client.core.requests.transactions.ConfirmCaptureParams;
import mx.openpay.client.core.requests.transactions.CreateCardChargeParams;
@@ -348,6 +350,60 @@ public void testCreate_Customer_WithCard_currencyUSD() throws Exception {
assertNotNull(charge.getMetadata());
}
+ @Test
+ public void testCreate_Customer_WithCard_currencyEUR() throws Exception {
+ BigDecimal amount = new BigDecimal("300.00");
+ String desc = "Pago de taxi";
+ Map metadata = new LinkedHashMap();
+ metadata.put("origin", "Madrid");
+ metadata.put("destination", "Paris");
+ metadata.put("seats", "3");
+
+ OpenpayAPI api = new OpenpayAPI(
+ "https://dev-api.openpay.com.es/",
+ "sk_3c4897405bc34dce9b29609fd793b43c",
+ "mwlcpd7myrasxzrz7j61"
+ );
+
+ Customer customer = api.customers().create(
+ new Customer()
+ .name("Carlos")
+ .lastName("Chavez")
+ .email("carlos.chavez@openpay.mx")
+ .phoneNumber("4491053632")
+ );
+
+ Calendar exp = Calendar.getInstance();
+ exp.add(Calendar.YEAR, 2);
+
+ Card card = api.cards().create(
+ customer.getId(),
+ new Card()
+ .cardNumber("4111111111111111")
+ .holderName("Juanito Pérez Nuñez")
+ .cvv2("111")
+ .expirationMonth(exp.get(Calendar.MONTH))
+ .expirationYear(exp.get(Calendar.YEAR) % 100)
+ );
+
+ Charge charge = api.charges().create(
+ customer.getId(),
+ new CreateCardChargeParams()
+ .cardId(card.getId())
+ .amount(amount)
+ .description(desc)
+ .currency(Currency.EUR)
+ .metadata(metadata)
+ .deviceSessionId("Tu2yXO0sJpT6KUVi1g4IWDOEmIHP69XI")
+ );
+
+ assertNotNull(charge);
+ assertNotNull(charge.getCard());
+ assertNull(charge.getCard().getCvv2());
+ assertNotNull(charge.getCard().getId());
+ assertNotNull(charge.getMetadata());
+ }
+
@Test
public void testCreate_Customer_NoCardOrId() throws Exception {
BigDecimal amount = new BigDecimal("10000.00");
diff --git a/src/test/integration/mx/openpay/core/client/full/FeesTest.java b/src/test/integration/mx/openpay/core/client/full/FeesTest.java
index 10f15a4..e3292e1 100644
--- a/src/test/integration/mx/openpay/core/client/full/FeesTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/FeesTest.java
@@ -45,8 +45,8 @@ public class FeesTest extends BaseTest {
@Before
public void setUp() throws Exception {
this.customer = this.api.customers().create(new Customer()
- .name("Juan Nuñez").email("juan.perez@example.com")
- .phoneNumber("44200000000")
+ .name("Juan Nuñez").email("juan.perez@correo.com")
+ .phoneNumber("44212033000")
.requiresAccount(true));
this.api.charges().create(this.customer.getId(), new CreateCardChargeParams()
.amount(new BigDecimal("5"))
diff --git a/src/test/integration/mx/openpay/core/client/full/MerchantBankAccountsTest.java b/src/test/integration/mx/openpay/core/client/full/MerchantBankAccountsTest.java
index 1d57df9..a24875f 100644
--- a/src/test/integration/mx/openpay/core/client/full/MerchantBankAccountsTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/MerchantBankAccountsTest.java
@@ -61,7 +61,7 @@ public void testList_MerchantDoesNotExist() throws ServiceUnavailableException,
public void testGet() throws Exception {
BankAccount bankAccount = this.api.bankAccounts().list(null).get(0);
bankAccount = this.api.bankAccounts().get(bankAccount.getId());
- assertEquals("012XXXXXXXXXX24616", bankAccount.getClabe());
+ assertEquals("012XXXXXXXXXX60639", bankAccount.getClabe());
}
@Test
diff --git a/src/test/integration/mx/openpay/core/client/full/MerchantBankPayoutsTest.java b/src/test/integration/mx/openpay/core/client/full/MerchantBankPayoutsTest.java
index a836825..08088ac 100644
--- a/src/test/integration/mx/openpay/core/client/full/MerchantBankPayoutsTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/MerchantBankPayoutsTest.java
@@ -156,6 +156,7 @@ public void testCreateMerchantBankPayout_WithBankAccount() throws ServiceUnavail
}
@Test
+ @Ignore
public void testCreateMerchantBankPayout_WithBankAccount_Breakdown() throws ServiceUnavailableException,
OpenpayServiceException {
BigDecimal amount = BigDecimal.ONE;
diff --git a/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java b/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java
index bf27a63..23762ba 100644
--- a/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java
@@ -36,18 +36,12 @@
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
-import mx.openpay.client.Address;
-import mx.openpay.client.Card;
-import mx.openpay.client.Charge;
-import mx.openpay.client.Customer;
-import mx.openpay.client.GatewayParams;
-import mx.openpay.client.HttpContext;
-import mx.openpay.client.ShipTo;
-import mx.openpay.client.SimpleRefund;
+import mx.openpay.client.*;
import mx.openpay.client.core.requests.transactions.ConfirmCaptureParams;
import mx.openpay.client.core.requests.transactions.CreateCardChargeParams;
import mx.openpay.client.core.requests.transactions.RefundParams;
import mx.openpay.client.enums.Currency;
+import mx.openpay.client.enums.PaymentType;
import mx.openpay.client.enums.UseCardPointsType;
import mx.openpay.client.exceptions.OpenpayServiceException;
import mx.openpay.client.exceptions.ServiceUnavailableException;
@@ -76,7 +70,7 @@ public void setUp() throws Exception {
.holderName("Juanito Pérez Nuñez")
.cvv2("111")
.expirationMonth(9)
- .expirationYear(20)
+ .expirationYear(25)
.address(TestUtils.prepareAddress()));
}
@@ -106,6 +100,54 @@ public void testCreate_Customer_WithId() throws ServiceUnavailableException, Ope
Assert.assertNotNull(transaction.getFee());
}
+ @Test
+ public void testCreate_Charge_WithoutInterest() throws ServiceUnavailableException, OpenpayServiceException {
+ BigDecimal amount = new BigDecimal("1500.00");
+ String desc = "Pago con bandera paymentsType con valor WITHOUT_INTEREST";
+ String orderId = String.valueOf(System.currentTimeMillis());
+ DeferralPayments deferralPayments = new DeferralPayments(3, PaymentType.WITHOUT_INTEREST);
+ Charge transaction = this.api.charges().create(new CreateCardChargeParams()
+ .cardId(this.registeredCard.getId())
+ .amount(amount)
+ .description(desc)
+ .capture(true)
+ .orderId(orderId).cvv2("235")
+ .deferralPayments(deferralPayments)
+ .gateway(new GatewayParams()
+ .addData("amex", "keyName", "data")
+ .addData("amex", "otherKey", "value")));
+
+ assertNotNull(transaction);
+ assertEquals(amount, transaction.getAmount());
+ assertEquals(desc, transaction.getDescription());
+ assertThat(transaction.getCardPoints(), is(nullValue()));
+ Assert.assertNotNull(transaction.getFee());
+ }
+
+ @Test
+ public void testCreate_Charge_WithInterest() throws ServiceUnavailableException, OpenpayServiceException {
+ BigDecimal amount = new BigDecimal("1500.00");
+ String desc = "Pago con bandera paymentsType con valor WITH_INTEREST";
+ String orderId = String.valueOf(System.currentTimeMillis());
+ DeferralPayments deferralPayments = new DeferralPayments(3, PaymentType.WITH_INTEREST);
+ Charge transaction = this.api.charges().create(new CreateCardChargeParams()
+ .cardId(this.registeredCard.getId())
+ .amount(amount)
+ .description(desc)
+ .capture(true)
+ .orderId(orderId).cvv2("235")
+ .deferralPayments(deferralPayments)
+ .gateway(new GatewayParams()
+ .addData("amex", "keyName", "data")
+ .addData("amex", "otherKey", "value")));
+
+ assertNotNull(transaction);
+ assertEquals(amount, transaction.getAmount());
+ assertEquals(desc, transaction.getDescription());
+ assertThat(transaction.getCardPoints(), is(nullValue()));
+ Assert.assertNotNull(transaction.getFee());
+ }
+
@Test
public void testSearchOrderId() throws ServiceUnavailableException, OpenpayServiceException {
BigDecimal amount = new BigDecimal("10.00");
diff --git a/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java
new file mode 100644
index 0000000..5a0ed18
--- /dev/null
+++ b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java
@@ -0,0 +1,105 @@
+package mx.openpay.core.client.full;
+
+
+import mx.openpay.client.OpenCheckoutConfigurationResponse;
+import mx.openpay.client.OpenCheckoutConfigurationResponseLight;
+import mx.openpay.client.core.requests.transactions.CreateOpenCheckoutParams;
+import mx.openpay.client.exceptions.OpenpayServiceException;
+import mx.openpay.client.exceptions.ServiceUnavailableException;
+import mx.openpay.client.utils.SearchOpenCheckoutParams;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+
+public class OpenCheckoutTest extends BaseTest{
+
+ @Test
+ public void testgetById() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ String idOpencheckout = "occen6olmiybj77ixuq6";
+ OpenCheckoutConfigurationResponse response = this.api.openCheckout().getConfigurationsById("movcg01xcf9kggrron0e",idOpencheckout);
+ assertNotNull(response);
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+
+
+ @Test
+ public void testAddOpenCheckout() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ CreateOpenCheckoutParams openCheckout = new CreateOpenCheckoutParams()
+ .with("name", "prueba")
+ .with("amount", 200)
+ .with("description", "aaaa")
+ .with("redirect_url", "prueba.com")
+ .with("currency","MXN")
+ .with("iva", 2)
+ .with("expiration_date", null)
+ .with("open_amount", true);
+ OpenCheckoutConfigurationResponse response = this.api.openCheckout().createOpenCheckout(openCheckout);
+ System.out.println(response);
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+
+
+ @Test
+ public void testUpdatepenCheckout() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ CreateOpenCheckoutParams openCheckout = new CreateOpenCheckoutParams()
+ .with("name", "prueba")
+ .with("id", "occen6olmiybj77ixuq6")
+ .with("amount", 200)
+ .with("description", "aaaa")
+ .with("redirect_url", "prueba.com")
+ .with("currency","MXN")
+ .with("iva", 2)
+ .with("expiration_date", null)
+ .with("open_amount", true);
+ OpenCheckoutConfigurationResponse response = this.api.openCheckout().updateOpenCheckout(openCheckout);
+ System.out.println(response);
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+
+
+ @Test
+ public void testDeleteById() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ String idOpencheckout = "occen6olmiybj77ixuq6";
+ this.api.openCheckout().deleteOpencheckout("movcg01xcf9kggrron0e",idOpencheckout);
+
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+
+
+ @Test
+ public void testgetBylight() throws ServiceUnavailableException, OpenpayServiceException {
+ try {
+ List response = this.api.openCheckout().getConfigurationsLight("myjsc2gdtfccbzgxdqza");
+ assertNotNull(response);
+ } catch (OpenpayServiceException e) {
+ e.printStackTrace();
+ //assertEquals(404, e.getHttpCode().intValue());
+ assertNotNull(e.getErrorCode());
+ }
+ }
+
+}
diff --git a/src/test/integration/mx/openpay/core/client/full/TransfersTest.java b/src/test/integration/mx/openpay/core/client/full/TransfersTest.java
index c39e183..970477a 100644
--- a/src/test/integration/mx/openpay/core/client/full/TransfersTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/TransfersTest.java
@@ -48,8 +48,8 @@ public class TransfersTest extends BaseTest {
@Before
public void setUp() throws Exception {
this.customerFrom = this.api.customers().create(new Customer()
- .name("Jorge Perez").email("juan.perez@example.com")
- .phoneNumber("44200000000").requiresAccount(true));
+ .name("Jorge Perez").email("juan.perez@correo.com")
+ .phoneNumber("44212033000").requiresAccount(true));
this.api.charges().create(this.customerFrom.getId(), new CreateCardChargeParams()
.amount(new BigDecimal("100"))
.description("Some funds")
diff --git a/src/test/integration/mx/openpay/core/client/full/groups/GroupCustomerCardChargesTest.java b/src/test/integration/mx/openpay/core/client/full/groups/GroupCustomerCardChargesTest.java
index df4c2a3..29067f0 100644
--- a/src/test/integration/mx/openpay/core/client/full/groups/GroupCustomerCardChargesTest.java
+++ b/src/test/integration/mx/openpay/core/client/full/groups/GroupCustomerCardChargesTest.java
@@ -47,8 +47,8 @@ public class GroupCustomerCardChargesTest extends GroupBaseTest {
@Before
public void setUp() throws Exception {
this.customer = this.groupApi.groupCustomers().create(new Customer()
- .name("Jorge Perez").email("juan.perez@example.com")
- .phoneNumber("44200000000").requiresAccount(false));
+ .name("Jorge Perez").email("juan.perez@correo.com")
+ .phoneNumber("44212033000").requiresAccount(false));
this.customerRegisteredCard = this.groupApi.groupCards().create(this.customer.getId(), new Card()
.cardNumber("4242424242424242")
.holderName("Juanito Pérez Nuñez")