Skip to content

Commit 2c385cd

Browse files
Merge pull request #309 from mercadopago/release/2.4.0
Release/2.4.0
2 parents 6a421db + 7b4ce67 commit 2c385cd

File tree

14 files changed

+283
-45
lines changed

14 files changed

+283
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ already.
2020
<dependency>
2121
<groupId>com.mercadopago</groupId>
2222
<artifactId>sdk-java</artifactId>
23-
<version>2.3.0</version>
23+
<version>2.4.0</version>
2424
</dependency>
2525
```
2626

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.mercadopago</groupId>
66
<artifactId>sdk-java</artifactId>
7-
<version>2.3.0</version>
7+
<version>2.4.0</version>
88
<packaging>jar</packaging>
99

1010
<name>Mercadopago SDK</name>

src/main/java/com/mercadopago/MercadoPagoConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/** Mercado Pago configuration class. */
1616
public class MercadoPagoConfig {
1717

18-
public static final String CURRENT_VERSION = "2.3.0";
18+
public static final String CURRENT_VERSION = "2.4.0";
1919

2020
public static final String PRODUCT_ID = "BC32A7VTRPP001U8NHJ0";
2121

src/main/java/com/mercadopago/client/order/OrderCreateRequest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
import lombok.Getter;
66

77
import java.util.List;
8+
import java.util.Map;
89

9-
// API version: 1ff4822a-2dfd-4393-800e-a562edb3fe32
10+
// API version: acd67b14-97c4-4a4a-840d-0a018c09654f
1011

1112
/** Order class. */
1213
@Builder
@@ -53,4 +54,7 @@ public class OrderCreateRequest extends MPResource {
5354

5455
/** Expiration time of the order. */
5556
private String expirationTime;
57+
58+
/** Additional info for the order. */
59+
private Map<String, Object> additionalInfo;
5660
}

src/main/java/com/mercadopago/client/order/OrderItemRequest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import lombok.Getter;
44

5-
// API version: 1ff4822a-2dfd-4393-800e-a562edb3fe32
5+
// API version: acd67b14-97c4-4a4a-840d-0a018c09654f
66

77
/** OrderItemRequest class. */
88
@Getter
@@ -23,10 +23,18 @@ public class OrderItemRequest {
2323
/** Category ID of the item. */
2424
private String categoryId;
2525

26+
/** Type of the item. */
27+
private String type;
28+
2629
/** Description of the item. */
2730
private String description;
2831

2932
/** Picture URL of the item. */
3033
private String pictureUrl;
3134

35+
/** Warranty of the item. */
36+
private Boolean warranty;
37+
38+
/** Event date of the item. */
39+
private String eventDate;
3240
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.mercadopago.client.order;
2+
3+
import lombok.Builder;
4+
import lombok.Getter;
5+
6+
// API version: acd67b14-97c4-4a4a-840d-0a018c09654f
7+
8+
/** OrderPayerAddressRequest class. */
9+
@Getter
10+
@Builder
11+
public class OrderPayerAddressRequest {
12+
/** Street name. */
13+
private String streetName;
14+
15+
/** Street number. */
16+
private String streetNumber;
17+
18+
/** Zip code. */
19+
private String zipCode;
20+
21+
/** Neighborhood. */
22+
private String neighborhood;
23+
24+
/** City. */
25+
private String city;
26+
27+
/** State. */
28+
private String state;
29+
}

src/main/java/com/mercadopago/client/order/OrderPayerRequest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
package com.mercadopago.client.order;
22

3-
import com.mercadopago.resources.common.Address;
43
import com.mercadopago.resources.common.Identification;
54
import com.mercadopago.resources.common.Phone;
65
import lombok.Builder;
76
import lombok.Getter;
87

9-
// API version: 1ff4822a-2dfd-4393-800e-a562edb3fe32
8+
// API version: acd67b14-97c4-4a4a-840d-0a018c09654f
109

1110
/** OrderPayerRequest class. */
1211
@Getter
1312
@Builder
1413
public class OrderPayerRequest {
14+
/** Payer's entity type. */
15+
private String entityType;
16+
1517
/** Payer's email. */
1618
private String email;
1719

@@ -31,6 +33,6 @@ public class OrderPayerRequest {
3133
private Phone phone;
3234

3335
/** Address information. */
34-
private Address address;
36+
private OrderPayerAddressRequest address;
3537

3638
}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package com.mercadopago.example.apis.order;
2+
3+
import com.mercadopago.MercadoPagoConfig;
4+
import com.mercadopago.client.order.*;
5+
import com.mercadopago.core.MPRequestOptions;
6+
import com.mercadopago.exceptions.MPApiException;
7+
import com.mercadopago.resources.order.Order;
8+
9+
import java.util.ArrayList;
10+
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
13+
14+
/**
15+
* Mercado Pago Create Order with industry fields.
16+
*
17+
* @see <a href=
18+
* "https://mercadopago.com/developers/en/reference/orders/online-payments/create/post">Documentation</a>.
19+
*/
20+
public class CreateOrderWithIndustryFields {
21+
public static void main(String[] args) {
22+
MercadoPagoConfig.setAccessToken("{{ACCESS_TOKEN}}");
23+
24+
System.out.println("Initializing OrderClient...");
25+
OrderClient client = new OrderClient();
26+
27+
System.out.println("Creating OrderPaymentRequest...");
28+
OrderPaymentRequest payment = OrderPaymentRequest.builder()
29+
.amount("100.00")
30+
.paymentMethod(OrderPaymentMethodRequest.builder()
31+
.id("master")
32+
.type("credit_card")
33+
.token("{{CARD_TOKEN}}")
34+
.installments(1)
35+
.statementDescriptor("statement")
36+
.build())
37+
.build();
38+
39+
System.out.println("Adding payment details:");
40+
System.out.println("Payment Amount: " + payment.getAmount());
41+
System.out.println("Payment Method ID: " + payment.getPaymentMethod().getId());
42+
43+
List<OrderPaymentRequest> payments = new ArrayList<>();
44+
payments.add(payment);
45+
46+
System.out.println("Creating OrderCreateRequest...");
47+
48+
// Build additionalInfo map
49+
Map<String, Object> additionalInfo = new HashMap<>();
50+
51+
// Payer info
52+
additionalInfo.put("payer.authentication_type", "MOBILE");
53+
additionalInfo.put("payer.registration_date", "2022-01-01T00:00:00Z");
54+
additionalInfo.put("payer.is_prime_user", true);
55+
additionalInfo.put("payer.is_first_purchase_online", false);
56+
additionalInfo.put("payer.last_purchase", "2024-12-01T12:00:00Z");
57+
58+
// Shipment info
59+
additionalInfo.put("shipment.express", true);
60+
additionalInfo.put("shipment.local_pickup", false);
61+
62+
// Platform shipment
63+
additionalInfo.put("platform.shipment.delivery_promise", "delivery_promise");
64+
additionalInfo.put("platform.shipment.drop_shipping", "drop_shipping");
65+
additionalInfo.put("platform.shipment.safety", "safety");
66+
additionalInfo.put("platform.shipment.tracking.code", "TRACK123");
67+
additionalInfo.put("platform.shipment.tracking.status", "status");
68+
additionalInfo.put("platform.shipment.withdrawn", false);
69+
70+
// Platform seller
71+
additionalInfo.put("platform.seller.id", "123456");
72+
additionalInfo.put("platform.seller.name", "Seller name");
73+
additionalInfo.put("platform.seller.email", "[email protected]");
74+
additionalInfo.put("platform.seller.status", "active");
75+
additionalInfo.put("platform.seller.referral_url", "https://example.com");
76+
additionalInfo.put("platform.seller.registration_date", "2020-05-01T00:00:00Z");
77+
additionalInfo.put("platform.seller.hired_plan", "Premium");
78+
additionalInfo.put("platform.seller.business_type", "E-commerce");
79+
additionalInfo.put("platform.seller.address.zip_code", "01310000");
80+
additionalInfo.put("platform.seller.address.street_name", "Av. Paulista");
81+
additionalInfo.put("platform.seller.address.street_number", "100");
82+
additionalInfo.put("platform.seller.address.city", "São Paulo");
83+
additionalInfo.put("platform.seller.address.state", "SP");
84+
additionalInfo.put("platform.seller.address.complement", "101");
85+
additionalInfo.put("platform.seller.address.country", "Brasil");
86+
additionalInfo.put("platform.seller.identification.type", "CNPJ");
87+
additionalInfo.put("platform.seller.identification.number", "12.345.678/0001-99");
88+
additionalInfo.put("platform.seller.phone.area_code", "11");
89+
additionalInfo.put("platform.seller.phone.number", "999999999");
90+
91+
// Platform authentication
92+
additionalInfo.put("platform.authentication", "2FA");
93+
94+
// Travel info
95+
Map<String, String> identification = new HashMap<>();
96+
identification.put("type", "CPF");
97+
identification.put("number", "12345678900");
98+
99+
Map<String, Object> passenger = new HashMap<>();
100+
passenger.put("first_name", "John");
101+
passenger.put("last_name", "Doe");
102+
passenger.put("identification", identification);
103+
104+
additionalInfo.put("travel.passengers", new Object[] { passenger });
105+
106+
Map<String, Object> route = new HashMap<>();
107+
route.put("departure", "GRU");
108+
route.put("destination", "CWB");
109+
route.put("departure_date_time", "2024-12-01T12:00:00Z");
110+
route.put("arrival_date_time", "2024-12-01T14:00:00Z");
111+
route.put("company", "LATAM");
112+
113+
additionalInfo.put("travel.routes", new Object[] { route });
114+
115+
OrderCreateRequest request = OrderCreateRequest.builder()
116+
.type("online")
117+
.processingMode("automatic")
118+
.totalAmount("100.00")
119+
.externalReference("ref_12345")
120+
.payer(OrderPayerRequest.builder().email("{{PAYER_EMAIL}}").build())
121+
.transactions(OrderTransactionRequest.builder()
122+
.payments(payments)
123+
.build())
124+
.additionalInfo(additionalInfo)
125+
.build();
126+
127+
System.out.println("Total amount: " + request.getTotalAmount());
128+
System.out.println("External reference: " + request.getExternalReference());
129+
130+
Map<String, String> headers = new HashMap<>();
131+
headers.put("X-Idempotency-Key", "{{IDEMPOTENCY_KEY}}");
132+
133+
MPRequestOptions requestOptions = MPRequestOptions.builder()
134+
.customHeaders(headers)
135+
.build();
136+
137+
try {
138+
System.out.println("Attempting to create order...");
139+
Order order = client.create(request, requestOptions);
140+
System.out.println("Order created: " + order.getId());
141+
System.out.println("Order status: " + order.getStatus());
142+
} catch (MPApiException mpApiException) {
143+
System.out.println("Error creating order: " + mpApiException.getMessage());
144+
System.out.println("Status Code: " + mpApiException.getStatusCode());
145+
System.out.println("Error Code: " + mpApiException.getApiResponse());
146+
System.out.println("Error Details: " + mpApiException.getCause());
147+
} catch (Exception e) {
148+
e.printStackTrace();
149+
System.out.println("Error creating order: " + e.getMessage());
150+
}
151+
}
152+
}

src/main/java/com/mercadopago/resources/order/Order.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import lombok.Getter;
55

66
import java.util.List;
7+
import java.util.Map;
78

8-
/* API version: 1ff4822a-2dfd-4393-800e-a562edb3fe32 */
9+
/* API version: acd67b14-97c4-4a4a-840d-0a018c09654f */
910

1011
/** Order class. */
1112
@Getter
@@ -26,10 +27,16 @@ public class Order extends MPResource {
2627
/** Total Paid amount of the order. */
2728
private String totalPaidAmount;
2829

29-
/** Identifier of the site (country) to which the Mercado Pago application that created the Order belongs. */
30+
/**
31+
* Identifier of the site (country) to which the Mercado Pago application that
32+
* created the Order belongs.
33+
*/
3034
private String countryCode;
3135

32-
/** Identifier of the user to which the Mercado Pago application that created the Order belongs. It is the person that will receive the payment. */
36+
/**
37+
* Identifier of the user to which the Mercado Pago application that created the
38+
* Order belongs. It is the person that will receive the payment.
39+
*/
3340
private String userId;
3441

3542
/** Status of Order. */
@@ -47,7 +54,10 @@ public class Order extends MPResource {
4754
/** Last modified date. */
4855
private String lastUpdatedDate;
4956

50-
/** Additional information that can be used to integrate with other systems, such as the identifier of the Order in the integrator's system. */
57+
/**
58+
* Additional information that can be used to integrate with other systems, such
59+
* as the identifier of the Order in the integrator's system.
60+
*/
5161
private OrderIntegrationData integrationData;
5262

5363
/** Configures which processing modes to use. */
@@ -71,7 +81,10 @@ public class Order extends MPResource {
7181
/** Date of expiration. */
7282
private String expirationTime;
7383

74-
/** Unique token that identifies your integration. You can get it in Your credentials. */
84+
/**
85+
* Unique token that identifies your integration. You can get it in Your
86+
* credentials.
87+
*/
7588
private String clientToken;
7689

7790
/** Items information. */
@@ -82,4 +95,7 @@ public class Order extends MPResource {
8295

8396
/** Payer information. */
8497
private OrderPayer payer;
98+
99+
/** Additional info for the order. */
100+
private Map<String, Object> additionalInfo;
85101
}

src/main/java/com/mercadopago/resources/order/OrderItem.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import lombok.Getter;
44

5-
// API version: d0494f1c-8d81-4c76-ae1d-0c65bb8ef6de
5+
// API version: acd67b14-97c4-4a4a-840d-0a018c09654f
66

77
/** OrderItem class. */
88
@Getter
@@ -23,6 +23,9 @@ public class OrderItem {
2323
/** Category ID of the item. */
2424
private String categoryId;
2525

26+
/** Type of the item. */
27+
private String type;
28+
2629
/** Description of the item. */
2730
private String description;
2831

@@ -32,4 +35,9 @@ public class OrderItem {
3235
/** External Code of the item. */
3336
private String externalCode;
3437

38+
/** Warranty of the item. */
39+
private Boolean warranty;
40+
41+
/** Event date of the item. */
42+
private String eventDate;
3543
}

src/test/java/com/mercadopago/client/merchantorder/MerchantOrderClientIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ private PreferenceRequest buildPreferenceRequest() {
273273
.autoReturn("all")
274274
.backUrls(
275275
PreferenceBackUrlsRequest.builder()
276-
.success("http://test.com/success")
277-
.failure("http://test.com/failure")
278-
.pending("http://test.com/pending")
276+
.success("https://test.com/success")
277+
.failure("https://test.com/failure")
278+
.pending("https://test.com/pending")
279279
.build())
280280
.binaryMode(true)
281281
.expires(false)

0 commit comments

Comments
 (0)