Skip to content

Commit

Permalink
include submerchant
Browse files Browse the repository at this point in the history
  • Loading branch information
danielen-meli committed Jun 25, 2024
1 parent c4833ca commit 629a8d3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
21 changes: 19 additions & 2 deletions examples/apis/preference/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func main() {
cfg, err := config.New("{{ACCESS_TOKEN}}")
cfg, err := config.New("APP_USR-3031066189562927-042217-7204e46c8ca7b09cee4327a6e38f8c0d-831921084")
if err != nil {
fmt.Println(err)
return
Expand All @@ -20,11 +20,28 @@ func main() {
{
ID: "123",
Title: "Title",
UnitPrice: 100,
UnitPrice: 75,
Quantity: 1,
Description: "Description",
},
},
PaymentMethods: &preference.PaymentMethodsRequest{
DefaultPaymentMethodID: "visa",
},
Payer: &preference.PayerRequest{
Name: "tyuio",
Surname: "gfhjkl",
Email: "[email protected]",
Identification: &preference.IdentificationRequest{
Type: "CPF",
Number: "19119119100",
},
Address: &preference.AddressRequest{
ZipCode: "88054000",
StreetName: "Rua PREFERENCE",
StreetNumber: "12345",
},
},
}

client := preference.NewClient(cfg)
Expand Down
24 changes: 24 additions & 0 deletions pkg/payment/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Request struct {
MerchantServices *MerchantServicesRequest `json:"merchant_services,omitempty"`
Order *OrderRequest `json:"order,omitempty"`
Payer *PayerRequest `json:"payer,omitempty"`
ForwardData *ForwardDataRequest `json:"forward_data,omitempty"`
TransactionDetails *TransactionDetailsRequest `json:"transaction_details,omitempty"`
PointOfInteraction *PointOfInteractionRequest `json:"point_of_interaction,omitempty"`
PaymentMethod *PaymentMethodRequest `json:"payment_method,omitempty"`
Expand Down Expand Up @@ -177,6 +178,29 @@ type PayerRequest struct {
EntityType string `json:"entity_type,omitempty"`
}

// ForwardData represents data used in special conditions for the payment.
type ForwardDataRequest struct {
SubMerchant *SubMerchantRequest `json:"sub_merchant,omitempty"`
}

// SubMerchantRequest represents sub merchant request within ForwardDataRequest.
type SubMerchantRequest struct {
SubMerchantId string `json:"sub_merchant_id,omitempty"`
MCC string `json:"mcc,omitempty"`
Country string `json:"country,omitempty"`
AddressDoorNumber string `json:"address_door_number,omitempty"`
ZIP string `json:"zip,omitempty"`
DocumentNumber string `json:"document_number,omitempty"`
City string `json:"city,omitempty"`
AddressStreet string `json:"address_street,omitempty"`
LegalName string `json:"legal_name,omitempty"`
RegionCodeIso string `json:"region_code_iso,omitempty"`
RegionCode string `json:"region_code,omitempty"`
DocumentType string `json:"document_type,omitempty"`
Phone string `json:"phone,omitempty"`
URL string `json:"url,omitempty"`
}

// AddressRequest represents payer address request within PayerRequest.
type AddressRequest struct {
Neighborhood string `json:"neighborhood,omitempty"`
Expand Down
22 changes: 22 additions & 0 deletions pkg/payment/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
// Response is the response from the Payments API.
type Response struct {
Payer PayerResponse `json:"payer"`
ForwardData ForwardDataResponse `json:"forward_data,omitempty"`
AdditionalInfo AdditionalInfoResponse `json:"additional_info"`
Order OrderResponse `json:"order"`
TransactionDetails TransactionDetailsResponse `json:"transaction_details"`
Expand Down Expand Up @@ -81,6 +82,27 @@ type PayerResponse struct {
EntityType string `json:"entity_type"`
}

type ForwardDataResponse struct {
SubMerchant SubMerchantResponse `json:"sub_merchant,omitempty"`
}

type SubMerchantResponse struct {
SubMerchantId string `json:"sub_merchant_id,omitempty"`
MCC string `json:"mcc,omitempty"`
Country string `json:"country,omitempty"`
AddressDoorNumber string `json:"address_door_number,omitempty"`
ZIP string `json:"zip,omitempty"`
DocumentNumber string `json:"document_number,omitempty"`
City string `json:"city,omitempty"`
AddressStreet string `json:"address_street,omitempty"`
LegalName string `json:"legal_name,omitempty"`
RegionCodeIso string `json:"region_code_iso,omitempty"`
RegionCode string `json:"region_code,omitempty"`
DocumentType string `json:"document_type,omitempty"`
Phone string `json:"phone,omitempty"`
URL string `json:"url,omitempty"`
}

// IdentificationResponse represents payer's personal identification.
type IdentificationResponse struct {
Type string `json:"type"`
Expand Down

0 comments on commit 629a8d3

Please sign in to comment.