From ce8545ba41c7913e25babaa177c06b84da10cd08 Mon Sep 17 00:00:00 2001 From: Eli Lopez Date: Tue, 21 Sep 2021 13:31:41 -0500 Subject: [PATCH 01/27] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eb0979d..0dc48cd 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.7.0 + 1.8.0-SNAPSHOT jar openpay-api-client Java client for Openpay Services From f1d33cd53c327aec2c7d57dac91d6b959b5e1b75 Mon Sep 17 00:00:00 2001 From: Eli Lopez Date: Tue, 21 Sep 2021 13:50:07 -0500 Subject: [PATCH 02/27] =?UTF-8?q?Preparado=20README.md=20de=20siguiente=20?= =?UTF-8?q?versi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ``` From 773c0e0ad287316fc6c956609d14e9ca295f31a9 Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Mon, 14 Mar 2022 14:17:23 -0600 Subject: [PATCH 03/27] se agregar nueva funcionalidad para crear link de cobro masivo desde la libreria - JORDY MENDOZA --- pom.xml | 3 +- .../OpenCheckoutConfigurationResponse.java | 35 ++++++++ ...enCheckoutConfigurationSearchResponse.java | 22 +++++ .../java/mx/openpay/client/SearchDetails.java | 17 ++++ .../mx/openpay/client/core/OpenpayAPI.java | 5 ++ .../operations/OpenCheckoutOperations.java | 87 ++++++++++++++++++ .../CreateOpenCheckoutParams.java | 89 +++++++++++++++++++ .../utils/SearchOpenCheckoutParams.java | 56 ++++++++++++ .../client/full/CustomerBankPayoutsTest.java | 3 +- .../core/client/full/OpenCheckoutTest.java | 51 +++++++++++ 10 files changed, 366 insertions(+), 2 deletions(-) create mode 100644 src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponse.java create mode 100644 src/main/java/mx/openpay/client/OpenCheckoutConfigurationSearchResponse.java create mode 100644 src/main/java/mx/openpay/client/SearchDetails.java create mode 100644 src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java create mode 100644 src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java create mode 100644 src/main/java/mx/openpay/client/utils/SearchOpenCheckoutParams.java create mode 100644 src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java diff --git a/pom.xml b/pom.xml index 0dc48cd..1b723ce 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.8.0-SNAPSHOT + 1.9.0-SNAPSHOT jar openpay-api-client Java client for Openpay Services @@ -134,6 +134,7 @@ 20020423 test + 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/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/core/OpenpayAPI.java b/src/main/java/mx/openpay/client/core/OpenpayAPI.java index 97652c4..00f7be0 100644 --- a/src/main/java/mx/openpay/client/core/OpenpayAPI.java +++ b/src/main/java/mx/openpay/client/core/OpenpayAPI.java @@ -64,6 +64,8 @@ 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)); } @@ -87,6 +89,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 +165,6 @@ public CheckoutsOperations checkouts() { return this.checkoutsOperations; } + public OpenCheckoutOperations openCheckout(){return this.openCheckoutOperations;} + } 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..5e5959d --- /dev/null +++ b/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java @@ -0,0 +1,87 @@ +package mx.openpay.client.core.operations; + +import mx.openpay.client.OpenCheckoutConfigurationResponse; +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.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_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); + } + + + + /** + * 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); + } + + + + + + + +} 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..d01162c --- /dev/null +++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java @@ -0,0 +1,89 @@ +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 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); + } + + +} 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/full/CustomerBankPayoutsTest.java b/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java index 8465cfd..22a5f19 100644 --- a/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java +++ b/src/test/integration/mx/openpay/core/client/full/CustomerBankPayoutsTest.java @@ -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/OpenCheckoutTest.java b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java new file mode 100644 index 0000000..440d49e --- /dev/null +++ b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java @@ -0,0 +1,51 @@ +package mx.openpay.core.client.full; + + +import mx.openpay.client.OpenCheckoutConfigurationResponse; +import mx.openpay.client.core.requests.transactions.CreateOpenCheckoutParams; +import mx.openpay.client.exceptions.OpenpayServiceException; +import mx.openpay.client.exceptions.ServiceUnavailableException; +import org.junit.Test; + +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("monto_abierto", 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()); + } + } +} From a7620881cc2e5487df6bad7f9e182d812760cca0 Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Fri, 25 Mar 2022 19:18:26 -0600 Subject: [PATCH 04/27] cambios de checkout abierto - Yovany --- pom.xml | 2 +- src/main/java/mx/openpay/client/Checkout.java | 3 + ...penCheckoutConfigurationResponseLight.java | 20 +++++++ .../java/mx/openpay/client/Subscription.java | 3 + .../openpay/client/core/impl/ListTypes.java | 16 +---- .../operations/OpenCheckoutOperations.java | 49 ++++++++++++++- .../transactions/CreateCheckoutParams.java | 7 +++ .../CreateOpenCheckoutParams.java | 9 ++- .../core/client/full/OpenCheckoutTest.java | 60 ++++++++++++++++++- 9 files changed, 150 insertions(+), 19 deletions(-) create mode 100644 src/main/java/mx/openpay/client/OpenCheckoutConfigurationResponseLight.java diff --git a/pom.xml b/pom.xml index 1b723ce..8c7b1c5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.0-SNAPSHOT + 1.9.1-SNAPSHOT jar openpay-api-client Java client for Openpay Services diff --git a/src/main/java/mx/openpay/client/Checkout.java b/src/main/java/mx/openpay/client/Checkout.java index 2edfa01..b8df5f0 100644 --- a/src/main/java/mx/openpay/client/Checkout.java +++ b/src/main/java/mx/openpay/client/Checkout.java @@ -34,6 +34,9 @@ public class Checkout { @SerializedName("expiration_date") private Date expirationDate; + @SerializedName("plan_id") + private Integer planId; + private Customer customer; private Transaction transaction; 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/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/core/impl/ListTypes.java b/src/main/java/mx/openpay/client/core/impl/ListTypes.java index 1122172..ea002c4 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,8 @@ public class ListTypes { }.getType()); map.put(Webhook.class, new TypeToken>() { }.getType()); + map.put(OpenCheckoutConfigurationResponseLight.class, new TypeToken>() { + }.getType()); TYPES_MAP = Collections.unmodifiableMap(map); } diff --git a/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java b/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java index 5e5959d..df7b512 100644 --- a/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java +++ b/src/main/java/mx/openpay/client/core/operations/OpenCheckoutOperations.java @@ -1,6 +1,7 @@ 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; @@ -9,6 +10,7 @@ import mx.openpay.client.utils.SearchOpenCheckoutParams; import java.util.Date; +import java.util.List; import java.util.Map; public class OpenCheckoutOperations extends ServiceOperations{ @@ -17,7 +19,9 @@ public class OpenCheckoutOperations extends ServiceOperations{ 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_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; @@ -43,6 +47,20 @@ public OpenCheckoutConfigurationResponse createOpenCheckout( final RequestBuilde } + /** + * 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). @@ -79,6 +97,35 @@ public OpenCheckoutConfigurationResponse getConfigurationsById(final String merc } + /** + * 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/CreateCheckoutParams.java b/src/main/java/mx/openpay/client/core/requests/transactions/CreateCheckoutParams.java index 15c8a18..4f51b8c 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 idPlan(final Integer idPlan) { + return this.with("plan_id", idPlan); + } + /** * 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 index d01162c..71f67e8 100644 --- a/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java +++ b/src/main/java/mx/openpay/client/core/requests/transactions/CreateOpenCheckoutParams.java @@ -8,6 +8,13 @@ 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. */ @@ -86,4 +93,4 @@ public CreateCheckoutParams openAmount(Boolean openAmount) { } -} +} \ No newline at end of file diff --git a/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java index 440d49e..a84007d 100644 --- a/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java +++ b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java @@ -2,11 +2,15 @@ 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; @@ -16,7 +20,7 @@ public class OpenCheckoutTest extends BaseTest{ @Test public void testgetById() throws ServiceUnavailableException, OpenpayServiceException { try { - String idOpencheckout = "occen6olmiybj77ixuq6"; + String idOpencheckout = "occen6olmiybj77ixuq6"; OpenCheckoutConfigurationResponse response = this.api.openCheckout().getConfigurationsById("movcg01xcf9kggrron0e",idOpencheckout); assertNotNull(response); } catch (OpenpayServiceException e) { @@ -27,7 +31,6 @@ public void testgetById() throws ServiceUnavailableException, OpenpayServiceExce } - @Test public void testAddOpenCheckout() throws ServiceUnavailableException, OpenpayServiceException { try { @@ -39,7 +42,7 @@ public void testAddOpenCheckout() throws ServiceUnavailableException, OpenpaySer .with("currency","MXN") .with("iva", 2) .with("expiration_date", null) - .with("monto_abierto", true); + .with("open_amount", true); OpenCheckoutConfigurationResponse response = this.api.openCheckout().createOpenCheckout(openCheckout); System.out.println(response); } catch (OpenpayServiceException e) { @@ -48,4 +51,55 @@ public void testAddOpenCheckout() throws ServiceUnavailableException, OpenpaySer 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()); + } + } + } From 4f759f24bb27769c6514af4d57b8167331ac6502 Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Fri, 1 Apr 2022 13:17:40 -0600 Subject: [PATCH 05/27] modificacion al tipo de dato en parametro planId del checkout --- .../core/requests/transactions/CreateCheckoutParams.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 4f51b8c..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 @@ -87,8 +87,8 @@ public CreateCheckoutParams redirectStorePayment(Boolean redirectStorePayment) { /** * Plan for store checkout */ - public CreateCheckoutParams idPlan(final Integer idPlan) { - return this.with("plan_id", idPlan); + public CreateCheckoutParams planIdPublic(final String planIdPublic) { + return this.with("plan_id_public", planIdPublic); } /** From db40ac4a170dba4764d3a837b83d4df303f7af8f Mon Sep 17 00:00:00 2001 From: Eli Lopez Date: Fri, 1 Apr 2022 14:34:59 -0600 Subject: [PATCH 06/27] Revert "modificacion al tipo de dato en parametro planId del checkout" This reverts commit 4f759f24bb27769c6514af4d57b8167331ac6502. --- .../core/requests/transactions/CreateCheckoutParams.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3047bfb..4f51b8c 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 @@ -87,8 +87,8 @@ public CreateCheckoutParams redirectStorePayment(Boolean redirectStorePayment) { /** * Plan for store checkout */ - public CreateCheckoutParams planIdPublic(final String planIdPublic) { - return this.with("plan_id_public", planIdPublic); + public CreateCheckoutParams idPlan(final Integer idPlan) { + return this.with("plan_id", idPlan); } /** From 80c07670618ddc28db47ea1eca6eca7c2346f653 Mon Sep 17 00:00:00 2001 From: Eli Lopez Date: Fri, 1 Apr 2022 14:38:03 -0600 Subject: [PATCH 07/27] modificacion al tipo de dato en parametro planId del checkout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Aumentada versión --- pom.xml | 2 +- .../core/requests/transactions/CreateCheckoutParams.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8c7b1c5..8466af8 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.1-SNAPSHOT + 1.9.2-SNAPSHOT jar openpay-api-client Java client for Openpay Services 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 4f51b8c..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 @@ -87,8 +87,8 @@ public CreateCheckoutParams redirectStorePayment(Boolean redirectStorePayment) { /** * Plan for store checkout */ - public CreateCheckoutParams idPlan(final Integer idPlan) { - return this.with("plan_id", idPlan); + public CreateCheckoutParams planIdPublic(final String planIdPublic) { + return this.with("plan_id_public", planIdPublic); } /** From 59607379abca2de2e187e588ba742030a37cfbc0 Mon Sep 17 00:00:00 2001 From: Yahir GH Date: Wed, 18 May 2022 20:15:39 -0500 Subject: [PATCH 08/27] Se ajusta SDK Java para aceptar cuotas sin intereses. --- .../mx/openpay/client/DeferralPayments.java | 5 ++ .../mx/openpay/client/enums/PaymentType.java | 10 ++++ .../client/full/MerchantCardChargesTest.java | 60 ++++++++++++++++--- 3 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 src/main/java/mx/openpay/client/enums/PaymentType.java diff --git a/src/main/java/mx/openpay/client/DeferralPayments.java b/src/main/java/mx/openpay/client/DeferralPayments.java index 7b53eb3..6043ff0 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,7 @@ public class DeferralPayments { /** The payments. */ private Integer payments; + @SerializedName("payments_type") + private PaymentType paymentsType; + } 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/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java b/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java index bf27a63..5f4b46b 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 WITHOUT_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"); From c35889f313e28a140ebfd629dd7a9eeeed9a3fe7 Mon Sep 17 00:00:00 2001 From: Yahir GH Date: Thu, 19 May 2022 10:38:41 -0500 Subject: [PATCH 09/27] Se agrega constructor en DeferralPayments con atributo payments para no afectar implementaciones actuales --- src/main/java/mx/openpay/client/DeferralPayments.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/mx/openpay/client/DeferralPayments.java b/src/main/java/mx/openpay/client/DeferralPayments.java index 6043ff0..fc2cb6a 100644 --- a/src/main/java/mx/openpay/client/DeferralPayments.java +++ b/src/main/java/mx/openpay/client/DeferralPayments.java @@ -18,4 +18,7 @@ public class DeferralPayments { @SerializedName("payments_type") private PaymentType paymentsType; + public DeferralPayments(Integer payments) { + this.payments = payments; + } } From a421bef4328e88c8a0a4a311da90730358c5ff52 Mon Sep 17 00:00:00 2001 From: Yahir GH Date: Thu, 19 May 2022 16:45:56 -0500 Subject: [PATCH 10/27] Se incrementa version. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8466af8..ea80cd4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.2-SNAPSHOT + 1.9.3-SNAPSHOT jar openpay-api-client Java client for Openpay Services From b70344865695cb7f2e2da9380fd5c65a841b1b6c Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Mon, 30 May 2022 10:32:23 -0500 Subject: [PATCH 11/27] se agrega moneda ARS para pesos argentinos --- pom.xml | 2 +- src/main/java/mx/openpay/client/enums/Currency.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index ea80cd4..8fb7e8f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.3-SNAPSHOT + 1.9.4-SNAPSHOT jar openpay-api-client Java client for Openpay Services diff --git a/src/main/java/mx/openpay/client/enums/Currency.java b/src/main/java/mx/openpay/client/enums/Currency.java index 875f1b4..78ce77d 100644 --- a/src/main/java/mx/openpay/client/enums/Currency.java +++ b/src/main/java/mx/openpay/client/enums/Currency.java @@ -26,5 +26,10 @@ public enum Currency { /** * Peru peso */ - PEN; + PEN, + /** + * Argentina peso + */ + ARS + ; } From 1d4f5eeca667d51c8a0d648adf3836d0208f5bc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEV-SERGIO-QUI=C3=91ONEZ?= Date: Fri, 3 Jun 2022 13:38:57 -0500 Subject: [PATCH 12/27] Se prepara componente para subir a Maven Central --- pom.xml | 45 ++++++++++++++----- .../core/client/full/OpenCheckoutTest.java | 2 +- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 8fb7e8f..b833dad 100644 --- a/pom.xml +++ b/pom.xml @@ -3,18 +3,19 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.4-SNAPSHOT + 1.7.1-SNAPSHOT jar + openpay-api-client Java client for Openpay Services http://github.com/open-pay/openpay-java - + @@ -24,12 +25,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,6 +40,23 @@ + + scm:git:git://github.com/open-pay/openpay-java.git + scm:git:ssh://github.com/open-pay/openpay-java.git + https://github.com/open-pay/openpay-java + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + com.google.code.gson @@ -193,6 +205,20 @@ + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins maven-source-plugin @@ -214,7 +240,6 @@ attach-javadoc - verify jar diff --git a/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java index a84007d..5a0ed18 100644 --- a/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java +++ b/src/test/integration/mx/openpay/core/client/full/OpenCheckoutTest.java @@ -97,7 +97,7 @@ public void testgetBylight() throws ServiceUnavailableException, OpenpayServiceE assertNotNull(response); } catch (OpenpayServiceException e) { e.printStackTrace(); - assertEquals(404, e.getHttpCode().intValue()); + //assertEquals(404, e.getHttpCode().intValue()); assertNotNull(e.getErrorCode()); } } From 455a99581828872095af69630a89f1469473358b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEV-SERGIO-QUI=C3=91ONEZ?= Date: Tue, 7 Jun 2022 17:16:00 -0500 Subject: [PATCH 13/27] Se adecua POM para subir a maven central --- pom.xml | 68 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/pom.xml b/pom.xml index b833dad..2548718 100644 --- a/pom.xml +++ b/pom.xml @@ -3,19 +3,12 @@ 4.0.0 mx.openpay openpay-api-client - 1.7.1-SNAPSHOT + 1.7.1 jar openpay-api-client Java client for Openpay Services http://github.com/open-pay/openpay-java - - @@ -43,19 +36,19 @@ scm:git:git://github.com/open-pay/openpay-java.git scm:git:ssh://github.com/open-pay/openpay-java.git - https://github.com/open-pay/openpay-java + https://github.com/open-pay/openpay-java/tree/develop - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + openpayra + https://oss.sonatype.org/content/repositories/snapshots + + + openpayra + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + @@ -207,22 +200,30 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.7 - true - - ossrh - https://oss.sonatype.org/ - true - - + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + openpayra + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + + org.apache.maven.plugins maven-source-plugin - 2.2.1 + 3.2.1 attach-sources @@ -236,10 +237,11 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.9.1 + 3.2.0 attach-javadoc + verify jar @@ -288,10 +290,10 @@ org.apache.maven.plugins maven-gpg-plugin - 1.4 + 1.6 ${gpg.keyname} - ${gpg.passphrase} + ${gpg.passphrase} @@ -311,4 +313,4 @@ Openpay - + \ No newline at end of file From 5f831feaf82d22893d389ee6cfa3349908bd1e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Marin=CC=83elarena?= Date: Tue, 26 Jul 2022 12:37:02 -0500 Subject: [PATCH 14/27] Se realizan correcciones de vulnerabilidades y se actualizan tests. --- pom.xml | 16 +++++++++++++--- .../client/full/CustomerBankPayoutsTest.java | 4 ++-- .../mx/openpay/core/client/full/FeesTest.java | 4 ++-- .../client/full/MerchantCardChargesTest.java | 2 +- .../openpay/core/client/full/TransfersTest.java | 4 ++-- .../groups/GroupCustomerCardChargesTest.java | 4 ++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 2548718..ffaa2b7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.7.1 + 1.9.5-SNAPSHOT jar openpay-api-client @@ -54,7 +54,7 @@ com.google.code.gson gson - 2.2.4 + 2.9.0 compile @@ -115,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 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 22a5f19..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")) 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/MerchantCardChargesTest.java b/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java index 5f4b46b..23762ba 100644 --- a/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java +++ b/src/test/integration/mx/openpay/core/client/full/MerchantCardChargesTest.java @@ -127,7 +127,7 @@ public void testCreate_Charge_WithoutInterest() throws ServiceUnavailableExcepti @Test public void testCreate_Charge_WithInterest() throws ServiceUnavailableException, OpenpayServiceException { BigDecimal amount = new BigDecimal("1500.00"); - String desc = "Pago con bandera paymentsType con valor WITHOUT_INTEREST"; + 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() 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") From 619f3076fcd515bdf5aefcae2a1059fad203fcab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEV-SERGIO-QUI=C3=91ONEZ?= Date: Fri, 29 Jul 2022 11:15:59 -0500 Subject: [PATCH 15/27] Adaptacion de POM para prueba en Bamboo --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ffaa2b7..bf6bde5 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ - + @@ -209,7 +209,7 @@ - + org.apache.maven.plugins From 62f592b889871625bcbb3e643355505a49b27f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEV-SERGIO-QUI=C3=91ONEZ?= Date: Fri, 12 Aug 2022 11:25:22 -0500 Subject: [PATCH 16/27] Revert "Adaptacion de POM para prueba en Bamboo" This reverts commit 619f3076fcd515bdf5aefcae2a1059fad203fcab. --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index bf6bde5..ffaa2b7 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ - + @@ -209,7 +209,7 @@ - + org.apache.maven.plugins From 5ea97b65a543df4f5041c68c4fbe0fdd9c8c942a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEV-SERGIO-QUI=C3=91ONEZ?= Date: Fri, 12 Aug 2022 11:33:52 -0500 Subject: [PATCH 17/27] Se prepara version para subir a MAVEN --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ffaa2b7..7e586ae 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.5-SNAPSHOT + 1.7.2-SNAPSHOT jar openpay-api-client From 157f27b4f8538b4b0c2ffb9631e5b99d7fcc3426 Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Wed, 12 Oct 2022 20:01:09 -0500 Subject: [PATCH 18/27] cambios para mostrat historico de links de cobro --- pom.xml | 2 +- .../mx/openpay/client/CheckoutResponse.java | 48 +++++++++++++++++ .../openpay/client/core/impl/ListTypes.java | 2 + .../core/operations/CheckoutsOperations.java | 19 +++++++ .../client/utils/SearchCheckoutParams.java | 51 +++++++++++++++++++ .../core/client/full/CheckoutTest.java | 36 +++++++++++++ 6 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/main/java/mx/openpay/client/CheckoutResponse.java create mode 100644 src/main/java/mx/openpay/client/utils/SearchCheckoutParams.java create mode 100644 src/test/integration/mx/openpay/core/client/full/CheckoutTest.java diff --git a/pom.xml b/pom.xml index 7e586ae..ad01e91 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.7.2-SNAPSHOT + 1.9.6-SNAPSHOT jar openpay-api-client 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/core/impl/ListTypes.java b/src/main/java/mx/openpay/client/core/impl/ListTypes.java index ea002c4..36893a1 100644 --- a/src/main/java/mx/openpay/client/core/impl/ListTypes.java +++ b/src/main/java/mx/openpay/client/core/impl/ListTypes.java @@ -62,6 +62,8 @@ public class ListTypes { }.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/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/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()); + } + } +} From 908cd5612e6d5be8552b72edfcdde3b35a0f5082 Mon Sep 17 00:00:00 2001 From: BrunoRiveraPina Date: Fri, 11 Nov 2022 17:01:44 -0600 Subject: [PATCH 19/27] Jose_Luis_Cruz_Santoyo-Se agrega el product-type para marcar transacciones desde Recaudo --- pom.xml | 2 +- .../core/requests/transactions/CreateBankChargeParams.java | 6 +++++- .../core/requests/transactions/CreateCardChargeParams.java | 5 +++++ .../core/requests/transactions/CreateStoreChargeParams.java | 6 +++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index ad01e91..cc771b5 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.6-SNAPSHOT + 1.9.7-SNAPSHOT jar openpay-api-client 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..ac32e6c 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 @@ -246,4 +246,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/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); } } From c9fc4f297117e74b3111b8f004974c47ee160abe Mon Sep 17 00:00:00 2001 From: DEV-JOSE-ROMERO Date: Tue, 6 Jun 2023 11:58:34 -0600 Subject: [PATCH 20/27] Ajustes para soporta IP Public al obtener la instancia OpenpayAPI --- pom.xml | 2 +- .../openpay/client/core/HttpServiceClient.java | 2 ++ .../openpay/client/core/JsonServiceClient.java | 16 ++++++++++++++-- .../java/mx/openpay/client/core/OpenpayAPI.java | 4 ++++ .../core/impl/DefaultHttpServiceClient.java | 6 ++++++ .../mx/openpay/core/client/TestConstans.java | 2 ++ .../core/client/full/ConfigurationTest.java | 10 ++++++++++ .../client/full/MerchantBankAccountsTest.java | 2 +- .../client/full/MerchantBankPayoutsTest.java | 1 + 9 files changed, 41 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index cc771b5..4f39ed7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.7-SNAPSHOT + 1.9.8-SNAPSHOT jar openpay-api-client 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 00f7be0..a41ba50 100644 --- a/src/main/java/mx/openpay/client/core/OpenpayAPI.java +++ b/src/main/java/mx/openpay/client/core/OpenpayAPI.java @@ -70,6 +70,10 @@ public OpenpayAPI(final String location, final String apiKey, final String merch 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); 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/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/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/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; From 7520180226d6204a24957f5956f806369280f4dc Mon Sep 17 00:00:00 2001 From: DEV-JOSE-ROMERO Date: Tue, 6 Jun 2023 16:03:09 -0600 Subject: [PATCH 21/27] =?UTF-8?q?Adaptaci=C3=B3n=20de=20POM=20para=20prueb?= =?UTF-8?q?a=20en=20Bamboo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4f39ed7..377a7f8 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ - + @@ -209,7 +209,7 @@ - + org.apache.maven.plugins From ae05b1b99a7741076f17f3510eb6dc3f59a454a0 Mon Sep 17 00:00:00 2001 From: Carlos Galvan Date: Fri, 23 Feb 2024 12:24:19 -0600 Subject: [PATCH 22/27] =?UTF-8?q?Se=20agrega=20campo=20de=20origin=20chann?= =?UTF-8?q?el=20para=20informar=20en=20el=20registro=20de=20transacci?= =?UTF-8?q?=C3=B3n=20el=20plugin=20que=20genero=20la=20transacci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/mx/openpay/client/Checkout.java | 3 +++ src/main/java/mx/openpay/client/Transaction.java | 2 ++ .../core/requests/transactions/CreateCardChargeParams.java | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/src/main/java/mx/openpay/client/Checkout.java b/src/main/java/mx/openpay/client/Checkout.java index b8df5f0..0294a4e 100644 --- a/src/main/java/mx/openpay/client/Checkout.java +++ b/src/main/java/mx/openpay/client/Checkout.java @@ -40,4 +40,7 @@ public class Checkout { private Customer customer; private Transaction transaction; + + @SerializedName("origin") + private String originChannel = "SDK_JAVA"; } diff --git a/src/main/java/mx/openpay/client/Transaction.java b/src/main/java/mx/openpay/client/Transaction.java index 40e15cb..b2296d0 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 = "SDK_JAVA"; } 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 ac32e6c..9922b56 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 == null ? "SDK_JAVA" : originChannel); + } + /** * The amount to charge to the card. Required. */ From 7b91eeca2cd5f3a387f6924dfb31d2757b10e72f Mon Sep 17 00:00:00 2001 From: Carlos Galvan Date: Mon, 26 Feb 2024 14:11:55 -0600 Subject: [PATCH 23/27] =?UTF-8?q?Se=20agrega=20validaci=C3=B3n=20de=20si?= =?UTF-8?q?=20origin=20channel=20viene=20nulo=20poner=20SDK=5FJAVA=20por?= =?UTF-8?q?=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/requests/transactions/CreateCardChargeParams.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 9922b56..67815e0 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 @@ -42,6 +42,7 @@ public class CreateCardChargeParams extends RequestBuilder { public CreateCardChargeParams() { this.with("method", ChargeMethods.CARD.name().toLowerCase()); + originChannel(""); } /** @@ -59,7 +60,7 @@ public CreateCardChargeParams cardId(final String cardId) { } public CreateCardChargeParams originChannel(final String originChannel) { - return this.with("origin_channel", originChannel == null ? "SDK_JAVA" : originChannel); + return this.with("origin_channel", originChannel.isEmpty() ? "SDK_JAVA" : originChannel); } /** From 790d196f111b5290ea6475e85d7bee7bfef4a045 Mon Sep 17 00:00:00 2001 From: Carlos Galvan Date: Tue, 27 Feb 2024 13:40:10 -0600 Subject: [PATCH 24/27] Se modifica el constructor de la clase CreateCardChargeParams para enviar el valor de SDK_JAVA por default --- .../core/requests/transactions/CreateCardChargeParams.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 67815e0..adc781f 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 @@ -42,7 +42,7 @@ public class CreateCardChargeParams extends RequestBuilder { public CreateCardChargeParams() { this.with("method", ChargeMethods.CARD.name().toLowerCase()); - originChannel(""); + originChannel("SDK_JAVA"); } /** @@ -60,7 +60,7 @@ public CreateCardChargeParams cardId(final String cardId) { } public CreateCardChargeParams originChannel(final String originChannel) { - return this.with("origin_channel", originChannel.isEmpty() ? "SDK_JAVA" : originChannel); + return this.with("origin_channel", originChannel); } /** From 92bc615429c75bae5df55de29d48ac3b28a33bb2 Mon Sep 17 00:00:00 2001 From: Carlos Galvan Date: Mon, 4 Mar 2024 10:32:35 -0600 Subject: [PATCH 25/27] Se elimina el valor por default del origin Channel --- src/main/java/mx/openpay/client/Checkout.java | 2 +- src/main/java/mx/openpay/client/Transaction.java | 2 +- .../core/requests/transactions/CreateCardChargeParams.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/mx/openpay/client/Checkout.java b/src/main/java/mx/openpay/client/Checkout.java index 0294a4e..da67540 100644 --- a/src/main/java/mx/openpay/client/Checkout.java +++ b/src/main/java/mx/openpay/client/Checkout.java @@ -42,5 +42,5 @@ public class Checkout { private Transaction transaction; @SerializedName("origin") - private String originChannel = "SDK_JAVA"; + private String originChannel; } diff --git a/src/main/java/mx/openpay/client/Transaction.java b/src/main/java/mx/openpay/client/Transaction.java index b2296d0..ee41c20 100644 --- a/src/main/java/mx/openpay/client/Transaction.java +++ b/src/main/java/mx/openpay/client/Transaction.java @@ -91,5 +91,5 @@ public class Transaction { private GatewayResponse gateway; @SerializedName("origin_channel") - private String originChannel = "SDK_JAVA"; + private String originChannel; } 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 adc781f..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 @@ -42,7 +42,6 @@ public class CreateCardChargeParams extends RequestBuilder { public CreateCardChargeParams() { this.with("method", ChargeMethods.CARD.name().toLowerCase()); - originChannel("SDK_JAVA"); } /** From 4fceb248df726f4c4e5684f28332dea446ff44a1 Mon Sep 17 00:00:00 2001 From: "carlos.chavez" Date: Thu, 7 Mar 2024 13:56:11 -0600 Subject: [PATCH 26/27] Ajuste para ambiente DEV-ESP --- src/main/java/mx/openpay/client/enums/Currency.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/mx/openpay/client/enums/Currency.java b/src/main/java/mx/openpay/client/enums/Currency.java index 78ce77d..9f02661 100644 --- a/src/main/java/mx/openpay/client/enums/Currency.java +++ b/src/main/java/mx/openpay/client/enums/Currency.java @@ -30,6 +30,10 @@ public enum Currency { /** * Argentina peso */ - ARS - ; + ARS, + + /** + * Euros + */ + EUR } From 6fec126d2fcb957bd98d9d8effa972573d251b62 Mon Sep 17 00:00:00 2001 From: "carlos.chavez" Date: Mon, 11 Mar 2024 10:45:55 -0600 Subject: [PATCH 27/27] Ajuste para ambiente DEV-ESP --- pom.xml | 2 +- .../client/full/CustomerCardChargesTest.java | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 377a7f8..7d46169 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 mx.openpay openpay-api-client - 1.9.8-SNAPSHOT + 1.9.9-SNAPSHOT jar openpay-api-client 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");