Skip to content

Commit cf976f1

Browse files
authored
Merge pull request #100 from mercadopago/feat/ordersq3
[Feat] Adding orders fields
2 parents 9cc15d0 + 645274a commit cf976f1

File tree

6 files changed

+85
-69
lines changed

6 files changed

+85
-69
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## VERSION 1.7.0
2+
3+
Added Orders fields
4+
5+
## VERSION 1.6.0
6+
7+
Added CBP fields
18

29
## VERSION 1.5.0
310

@@ -11,7 +18,6 @@ Fix `store_id` in `DeviceResponse` to accept string values.
1118

1219
Include `network-transaction-id`
1320

14-
1521
## VERSION 1.3.0
1622

1723
Include Order Industry Data Fields and Example

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func main() {
5252
Type: "online",
5353
TotalAmount: "1000.00",
5454
ExternalReference: "ext_ref_1234",
55+
Currency: "BRL",
5556
Transactions: &order.TransactionRequest{
5657
Payments: []order.PaymentRequest{
5758
{

examples/apis/order/create/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func main() {
2121
Type: "online",
2222
TotalAmount: "1000.00",
2323
ExternalReference: "ext_ref_1234",
24+
Currency: "BRL",
2425
Transactions: &order.TransactionRequest{
2526
Payments: []order.PaymentRequest{
2627
{

examples/apis/order/createwithindustryfields/main.go

Lines changed: 72 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package main
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/mercadopago/sdk-go/pkg/config"
78
"github.com/mercadopago/sdk-go/pkg/order"
89
)
910

1011
func main() {
11-
accessToken := "<ACCESS_TOKEN>"
12+
accessToken := "{{ACCESS_TOKEN}}"
1213
c, err := config.New(accessToken)
1314
if err != nil {
1415
fmt.Println(err)
@@ -18,29 +19,14 @@ func main() {
1819
client := order.NewClient(c)
1920
request := order.Request{
2021
Type: "online",
21-
TotalAmount: "1000.00",
2222
ProcessingMode: "automatic",
23-
Marketplace: "NONE",
23+
TotalAmount: "1000.00",
2424
ExternalReference: "ext_ref_1234",
25-
CaptureMode: "automatic_async",
26-
Transactions: &order.TransactionRequest{
27-
Payments: []order.PaymentRequest{
28-
{
29-
Amount: "1000.00",
30-
PaymentMethod: &order.PaymentMethodRequest{
31-
ID: "master",
32-
Token: "<CARD_TOKEN>",
33-
Type: "credit_card",
34-
Installments: 1,
35-
},
36-
},
37-
},
38-
},
39-
25+
Currency: "BRL",
4026
Payer: &order.PayerRequest{
4127
Email: "<PAYER_EMAIL>",
42-
FirstName: "João",
43-
LastName: "Silva",
28+
FirstName: "John",
29+
LastName: "Doe",
4430
Identification: &order.IdentificationRequest{
4531
Type: "CPF",
4632
Number: "<NUMBER>",
@@ -50,63 +36,81 @@ func main() {
5036
Number: "<NUMBER>",
5137
},
5238
Address: &order.PayerAddressRequest{
53-
StreetName: "Rua Flores",
54-
StreetNumber: "130",
55-
Neighborhood: "Bosque",
56-
City: "Sao Paulo",
39+
StreetName: "R. Ângelo Piva",
40+
StreetNumber: "144",
41+
ZipCode: "06210110",
42+
Neighborhood: "Presidente Altino",
43+
City: "Osasco",
5744
State: "SP",
5845
Complement: "303",
5946
},
6047
},
48+
Transactions: &order.TransactionRequest{
49+
Payments: []order.PaymentRequest{
50+
{
51+
Amount: "1000.00",
52+
PaymentMethod: &order.PaymentMethodRequest{
53+
ID: "elo",
54+
Type: "credit_card",
55+
Token: "{{CARD_TOKEN}}",
56+
Installments: 1,
57+
},
58+
},
59+
},
60+
},
6161
Items: []order.ItemsRequest{
6262
{
63-
ExternalCode: "ext_ref_1234",
63+
ExternalCode: "1",
6464
Title: "Passagem Para SP",
65-
Description: "Test",
66-
PictureURL: "http://picture.testuser.com",
67-
CategoryID: "test",
65+
Description: "Passagem Para SP",
66+
PictureURL: "https://example_url.com/",
67+
CategoryID: "travel",
6868
Quantity: 1,
6969
Type: "travel",
70-
UnitPrice: "1000.00",
70+
UnitPrice: "10.00",
7171
Warranty: true,
72-
EventDate: "2023-10-10T00:00:00Z",
72+
EventDate: "2014-06-28T16:53:03.176-04:00",
7373
},
7474
},
75-
7675
AdditionalInfo: &order.AdditionalInfoRequest{
77-
PayerAuthenticationType: "MOBILE",
78-
PayerRegistrationDate: "2020-08-06T09:25:04.000-03:00",
79-
PayerIsPrimeUser: true,
80-
PayerIsFirstPurchaseOnLine: false,
81-
PayerLastPurchase: "2020-08-06T09:25:04.000-03:00",
82-
ShipmentExpress: true,
83-
ShipmentLocalPickup: true,
84-
PlatFormShipmentDeliveryPromise: "2024-12-31T23:59:59Z",
85-
PlatFormShipmentDropShipping: "string",
86-
PlatformShipmentSafety: "string",
87-
PlatformShipmentTrackingCode: "1234",
88-
PlatformShipmentTrackingStatus: "Em rota",
89-
PlatformShipmentWithdrawn: true,
90-
PlatformSellerID: "123456",
91-
PlatformSellerName: "Gui",
92-
PlatformSellerEmail: "<SELLER_EMAIL>",
93-
PlatformSellerStatus: "Active",
94-
PlatformSellerReferralURL: "https://www.testuser.com/seller/123456",
95-
PlatformSellerRegistrationDate: "2020-01-01T00:00:00.000-03:00",
96-
PlatformSellerHiredPlan: "Premium",
97-
PlatformSellerBusinessType: "E-commerce",
98-
PlatformSellerAddressZipCode: "123456",
99-
PlatformSellerAddressStreetName: "NAME",
100-
PlatformSellerAddressStreetNumber: "125",
101-
PlatformSellerAddressCity: "São Paulo",
102-
PlatformSellerAddressState: "SP",
103-
PlatformSellerAddressComplement: "101",
104-
PlatformSellerAddressCountry: "Brasil",
105-
PlatformSellerIdentificationType: "CNPJ",
106-
PlatformSellerIdentificationNumber: "00000000000",
107-
PlatformSellerPhoneNumber: "00000000000",
108-
PlatformSellerPhoneAreaCode: "11",
109-
PlatformAuthentication: "string",
76+
PayerAuthenticationType: "MOBILE",
77+
PayerRegistrationDate: "2024-01-01T00:00:00",
78+
PayerIsPrimeUser: true,
79+
PayerIsFirstPurchaseOnLine: true,
80+
PayerLastPurchase: "2024-01-01T00:00:00",
81+
ShipmentExpress: true,
82+
ShipmentLocalPickup: true,
83+
PlatFormShipmentDeliveryPromise: "2024-12-31T23:59:59Z",
84+
PlatformSellerID: "123456",
85+
PlatformSellerName: "Example Seller",
86+
PlatformSellerEmail: "seller@example.com",
87+
PlatformAuthentication: "string",
88+
TravelPassengers: &[]order.TravelPassengerRequest{
89+
{
90+
FirstName: "jose da silva",
91+
LastName: "ferreira",
92+
Identification: &order.IdentificationRequest{
93+
Type: "CPF",
94+
Number: "<NUMBER>",
95+
},
96+
},
97+
},
98+
TravelRoutes: &[]order.TravelRouterRequest{
99+
{
100+
Departure: "GRU",
101+
Destination: "CWB",
102+
DepartureDateTime: "2020-01-01T00:00:00.000-03:00",
103+
ArrivalDateTime: "2020-01-01T00:00:00.000-03:00",
104+
Company: "gol",
105+
},
106+
{
107+
Departure: "GRU",
108+
Destination: "CWB",
109+
DepartureDateTime: "2020-01-01T00:00:00.000-03:00",
110+
ArrivalDateTime: "2020-01-01T00:00:00.000-03:00",
111+
Company: "azul",
112+
},
113+
},
110114
},
111115
}
112116

@@ -115,5 +119,8 @@ func main() {
115119
fmt.Println(err)
116120
return
117121
}
118-
fmt.Println(resource)
122+
fmt.Println("Order created successfully:")
123+
fmt.Printf("ID: %s\n", resource.ID)
124+
fmt.Printf("Status: %s\n", resource.Status)
125+
fmt.Printf("Total Amount: %s %s\n", resource.TotalAmount, request.Currency)
119126
}

pkg/internal/httpclient/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
currentSDKVersion string = "1.6.1"
19+
currentSDKVersion string = "1.7.0"
2020
productID string = "CNITR48HSRV0CRPT3NI0"
2121
)
2222

pkg/order/request.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Request struct {
1111
MarketPlaceFee string `json:"marketplace_fee,omitempty"`
1212
ExpirationTime string `json:"expiration_time,omitempty"`
1313
CheckoutAvailableAt string `json:"checkout_available_at,omitempty"`
14+
Currency string `json:"currency,omitempty"`
1415
Transactions *TransactionRequest `json:"transactions,omitempty"`
1516
Payer *PayerRequest `json:"payer,omitempty"`
1617
Items []ItemsRequest `json:"items,omitempty"`
@@ -36,7 +37,7 @@ type AdditionalInfoRequest struct {
3637
PayerAuthenticationType string `json:"payer.authentication_type,omitempty"`
3738
PayerRegistrationDate string `json:"payer.registration_date,omitempty"`
3839
PayerIsPrimeUser bool `json:"payer.is_prime_user,omitempty"`
39-
PayerIsFirstPurchaseOnLine bool `json:"payer.is_first_purchase_onLine,omitempty"`
40+
PayerIsFirstPurchaseOnLine bool `json:"payer.is_first_purchase_online,omitempty"`
4041
PayerLastPurchase string `json:"payer.last_purchase,omitempty"`
4142
ShipmentExpress bool `json:"shipment.express,omitempty"`
4243
ShipmentLocalPickup bool `json:"shipment.local_pickup,omitempty"`
@@ -78,7 +79,7 @@ type TravelRouterRequest struct {
7879
Company string `json:"company,omitempty"`
7980
}
8081
type PayerAddressRequest struct {
81-
Zipcode string `json:"zipcode,omitempty"`
82+
ZipCode string `json:"zip_code,omitempty"`
8283
StreetName string `json:"street_name,omitempty"`
8384
StreetNumber string `json:"street_number,omitempty"`
8485
Neighborhood string `json:"neighborhood,omitempty"`

0 commit comments

Comments
 (0)