@@ -3,12 +3,13 @@ package main
33import (
44 "context"
55 "fmt"
6+
67 "github.com/mercadopago/sdk-go/pkg/config"
78 "github.com/mercadopago/sdk-go/pkg/order"
89)
910
1011func 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}
0 commit comments