From 480e5dec42ae0ccbd101e9e6170118f41cca1341 Mon Sep 17 00:00:00 2001 From: edmarSoaress Date: Fri, 2 Feb 2024 10:16:52 -0300 Subject: [PATCH] remover pointer from response --- examples/apis/payment/capture/main.go | 4 +- examples/apis/payment/capture_amount/main.go | 4 +- pkg/payment/payment.go | 78 ++-- pkg/payment/payment_test.go | 4 +- pkg/payment/response.go | 370 +++++++++---------- resources/mocks/payment/search_response.json | 4 +- 6 files changed, 245 insertions(+), 219 deletions(-) diff --git a/examples/apis/payment/capture/main.go b/examples/apis/payment/capture/main.go index c617ccd9..c5f763d2 100644 --- a/examples/apis/payment/capture/main.go +++ b/examples/apis/payment/capture/main.go @@ -37,11 +37,11 @@ func main() { } // Capture. - result, err := client.Capture(context.Background(), pay.ID) + pay, err = client.Capture(context.Background(), pay.ID) if err != nil { fmt.Println(err) return } - fmt.Println(result) + fmt.Println(pay) } diff --git a/examples/apis/payment/capture_amount/main.go b/examples/apis/payment/capture_amount/main.go index 972f82ac..bd293760 100644 --- a/examples/apis/payment/capture_amount/main.go +++ b/examples/apis/payment/capture_amount/main.go @@ -37,11 +37,11 @@ func main() { } // Capture amount. - result, err := client.CaptureAmount(context.Background(), pay.ID, 100.1) + pay, err = client.CaptureAmount(context.Background(), pay.ID, 100.1) if err != nil { fmt.Println(err) return } - fmt.Println(result) + fmt.Println(pay) } diff --git a/pkg/payment/payment.go b/pkg/payment/payment.go index f1baafa5..283fca44 100644 --- a/pkg/payment/payment.go +++ b/pkg/payment/payment.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" "strconv" "strings" @@ -13,27 +14,28 @@ import ( ) const ( - postURL = "https://api.mercadopago.com/v1/payments" - searchURL = "https://api.mercadopago.com/v1/payments/search" - getURL = "https://api.mercadopago.com/v1/payments/{id}" - putURL = "https://api.mercadopago.com/v1/payments/{id}" + baseURL = "https://api.mercadopago.com/v1/" + postURL = baseURL + "payments" + searchURL = baseURL + "payments/search" + getURL = baseURL + "payments/{id}" + putURL = baseURL + "payments/{id}" ) // Client contains the methods to interact with the Payments API. type Client interface { // Create creates a new payment. // It is a post request to the endpoint: https://api.mercadopago.com/v1/payments - // Reference: https://www.mercadopago.com.br/developers/pt/reference/payments/_payments/post/ + // Reference: https://www.mercadopago.com/developers/en/reference/payments/_payments/post/ Create(ctx context.Context, request Request) (*Response, error) // Search searches for payments. // It is a get request to the endpoint: https://api.mercadopago.com/v1/payments/search - // Reference: https://www.mercadopago.com.br/developers/pt/reference/payments/_payments_search/get/ + // Reference: https://www.mercadopago.com/developers/en/reference/payments/_payments_search/get/ Search(ctx context.Context, request SearchRequest) (*SearchResponse, error) // Get gets a payment by its ID. // It is a get request to the endpoint: https://api.mercadopago.com/v1/payments/{id} - // Reference: https://www.mercadopago.com.br/developers/pt/reference/payments/_payments_id/get/ + // Reference: https://www.mercadopago.com/developers/en/reference/payments/_payments_id/get/ Get(ctx context.Context, id int64) (*Response, error) // Cancel cancels a payment by its ID. @@ -77,17 +79,25 @@ func (c *client) Create(ctx context.Context, request Request) (*Response, error) return nil, err } - formatted := &Response{} - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *Response + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil } func (c *client) Search(ctx context.Context, dto SearchRequest) (*SearchResponse, error) { params := dto.Parameters() - req, err := http.NewRequestWithContext(ctx, http.MethodGet, searchURL+"?"+params, nil) + + url, err := url.Parse(searchURL) + if err != nil { + return nil, fmt.Errorf("error parsing url: %w", err) + } + url.RawQuery = params + + req, err := http.NewRequestWithContext(ctx, http.MethodGet, url.String(), nil) + if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } @@ -97,12 +107,12 @@ func (c *client) Search(ctx context.Context, dto SearchRequest) (*SearchResponse return nil, err } - var formatted *SearchResponse - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *SearchResponse + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil } func (c *client) Get(ctx context.Context, id int64) (*Response, error) { @@ -118,12 +128,12 @@ func (c *client) Get(ctx context.Context, id int64) (*Response, error) { return nil, err } - formatted := &Response{} - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *Response + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil } func (c *client) Cancel(ctx context.Context, id int64) (*Response, error) { @@ -144,12 +154,12 @@ func (c *client) Cancel(ctx context.Context, id int64) (*Response, error) { return nil, err } - formatted := &Response{} - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *Response + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil } func (c *client) Capture(ctx context.Context, id int64) (*Response, error) { @@ -170,12 +180,12 @@ func (c *client) Capture(ctx context.Context, id int64) (*Response, error) { return nil, err } - formatted := &Response{} - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *Response + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil } func (c *client) CaptureAmount(ctx context.Context, id int64, amount float64) (*Response, error) { @@ -196,10 +206,26 @@ func (c *client) CaptureAmount(ctx context.Context, id int64, amount float64) (* return nil, err } - formatted := &Response{} - if err := json.Unmarshal(res, &formatted); err != nil { + var payment *Response + if err := json.Unmarshal(res, &payment); err != nil { return nil, fmt.Errorf("error unmarshaling response: %w", err) } - return formatted, nil + return payment, nil +} + +func buildUrl(params url.Values) (string, error) { + url, err := url.Parse(searchURL) + if err != nil { + return "", fmt.Errorf("error parsing url: %w", err) + } + + for key, value := range params { + for _, v := range value { + q := url.Query() + q.Add(key, v) + url.RawQuery = q.Encode() + } + } + return url.String(), nil } diff --git a/pkg/payment/payment_test.go b/pkg/payment/payment_test.go index 434f0f1f..4488cd0f 100644 --- a/pkg/payment/payment_test.go +++ b/pkg/payment/payment_test.go @@ -251,12 +251,12 @@ func TestSearch(t *testing.T) { }, Results: []Response{ { - ID: 123, + ID: 57592046572, Status: "approved", StatusDetail: "accredited", }, { - ID: 456, + ID: 57592038796, Status: "pending", StatusDetail: "pending_waiting_transfer", }, diff --git a/pkg/payment/response.go b/pkg/payment/response.go index 61c1dfdd..fff8eb57 100644 --- a/pkg/payment/response.go +++ b/pkg/payment/response.go @@ -6,328 +6,328 @@ import ( // Response is the response from the Payments API. type Response struct { - DifferentialPricingID string `json:"differential_pricing_id,omitempty"` - MoneyReleaseSchema string `json:"money_release_schema,omitempty"` - OperationType string `json:"operation_type,omitempty"` - IssuerID string `json:"issuer_id,omitempty"` - PaymentMethodID string `json:"payment_method_id,omitempty"` - PaymentTypeID string `json:"payment_type_id,omitempty"` - Status string `json:"status,omitempty"` - StatusDetail string `json:"status_detail,omitempty"` - CurrencyID string `json:"currency_id,omitempty"` - Description string `json:"description,omitempty"` - AuthorizationCode string `json:"authorization_code,omitempty"` - IntegratorID string `json:"integrator_id,omitempty"` - PlatformID string `json:"platform_id,omitempty"` - CorporationID string `json:"corporation_id,omitempty"` - NotificationURL string `json:"notification_url,omitempty"` - CallbackURL string `json:"callback_url,omitempty"` - ProcessingMode string `json:"processing_mode,omitempty"` - MerchantAccountID string `json:"merchant_account_id,omitempty"` - MerchantNumber string `json:"merchant_number,omitempty"` - CouponCode string `json:"coupon_code,omitempty"` - ExternalReference string `json:"external_reference,omitempty"` - PaymentMethodOptionID string `json:"payment_method_option_id,omitempty"` - PosID string `json:"pos_id,omitempty"` - StoreID string `json:"store_id,omitempty"` - DeductionSchema string `json:"deduction_schema,omitempty"` - CounterCurrency string `json:"counter_currency,omitempty"` - CallForAuthorizeID string `json:"call_for_authorize_id,omitempty"` - StatementDescriptor string `json:"statement_descriptor,omitempty"` - MoneyReleaseStatus string `json:"money_release_status,omitempty"` - Installments int `json:"installments,omitempty"` - ID int64 `json:"id,omitempty"` - SponsorID int64 `json:"sponsor_id,omitempty"` - CollectorID int64 `json:"collector_id,omitempty"` - TransactionAmount float64 `json:"transaction_amount,omitempty"` - TransactionAmountRefunded float64 `json:"transaction_amount_refunded,omitempty"` - CouponAmount float64 `json:"coupon_amount,omitempty"` - TaxesAmount float64 `json:"taxes_amount,omitempty"` - ShippingAmount float64 `json:"shipping_amount,omitempty"` - NetAmount float64 `json:"net_amount,omitempty"` - LiveMode bool `json:"live_mode,omitempty"` - Captured bool `json:"captured,omitempty"` - BinaryMode bool `json:"binary_mode,omitempty"` - Metadata map[string]any `json:"metadata,omitempty"` - InternalMetadata map[string]any `json:"internal_metadata,omitempty"` - - DateCreated *time.Time `json:"date_created,omitempty"` - DateApproved *time.Time `json:"date_approved,omitempty"` - DateLastUpdated *time.Time `json:"date_last_updated,omitempty"` - DateOfExpiration *time.Time `json:"date_of_expiration,omitempty"` - MoneyReleaseDate *time.Time `json:"money_release_date,omitempty"` - Payer *PayerResponse `json:"payer,omitempty"` - AdditionalInfo *AdditionalInfoResponse `json:"additional_info,omitempty"` - Order *OrderResponse `json:"order,omitempty"` - TransactionDetails *TransactionDetailsResponse `json:"transaction_details,omitempty"` - Card *CardResponse `json:"card,omitempty"` - PointOfInteraction *PointOfInteractionResponse `json:"point_of_interaction,omitempty"` - PaymentMethod *PaymentMethodResponse `json:"payment_method,omitempty"` - ThreeDSInfo *ThreeDSInfoResponse `json:"three_ds_info,omitempty"` - FeeDetails []FeeDetailResponse `json:"fee_details,omitempty"` - Taxes []TaxResponse `json:"taxes,omitempty"` - Refunds []RefundResponse `json:"refunds,omitempty"` + DifferentialPricingID string `json:"differential_pricing_id"` + MoneyReleaseSchema string `json:"money_release_schema"` + OperationType string `json:"operation_type"` + IssuerID string `json:"issuer_id"` + PaymentMethodID string `json:"payment_method_id"` + PaymentTypeID string `json:"payment_type_id"` + Status string `json:"status"` + StatusDetail string `json:"status_detail"` + CurrencyID string `json:"currency_id"` + Description string `json:"description"` + AuthorizationCode string `json:"authorization_code"` + IntegratorID string `json:"integrator_id"` + PlatformID string `json:"platform_id"` + CorporationID string `json:"corporation_id"` + NotificationURL string `json:"notification_url"` + CallbackURL string `json:"callback_url"` + ProcessingMode string `json:"processing_mode"` + MerchantAccountID string `json:"merchant_account_id"` + MerchantNumber string `json:"merchant_number"` + CouponCode string `json:"coupon_code"` + ExternalReference string `json:"external_reference"` + PaymentMethodOptionID string `json:"payment_method_option_id"` + PosID string `json:"pos_id"` + StoreID string `json:"store_id"` + DeductionSchema string `json:"deduction_schema"` + CounterCurrency string `json:"counter_currency"` + CallForAuthorizeID string `json:"call_for_authorize_id"` + StatementDescriptor string `json:"statement_descriptor"` + MoneyReleaseStatus string `json:"money_release_status"` + Installments int `json:"installments"` + ID int64 `json:"id"` + SponsorID int64 `json:"sponsor_id"` + CollectorID int64 `json:"collector_id"` + TransactionAmount float64 `json:"transaction_amount"` + TransactionAmountRefunded float64 `json:"transaction_amount_refunded"` + CouponAmount float64 `json:"coupon_amount"` + TaxesAmount float64 `json:"taxes_amount"` + ShippingAmount float64 `json:"shipping_amount"` + NetAmount float64 `json:"net_amount"` + LiveMode bool `json:"live_mode"` + Captured bool `json:"captured"` + BinaryMode bool `json:"binary_mode"` + Metadata map[string]any `json:"metadata"` + InternalMetadata map[string]any `json:"internal_metadata"` + + DateCreated time.Time `json:"date_created"` + DateApproved time.Time `json:"date_approved"` + DateLastUpdated time.Time `json:"date_last_updated"` + DateOfExpiration time.Time `json:"date_of_expiration"` + MoneyReleaseDate time.Time `json:"money_release_date"` + Payer PayerResponse `json:"payer"` + AdditionalInfo AdditionalInfoResponse `json:"additional_info"` + Order OrderResponse `json:"order"` + TransactionDetails TransactionDetailsResponse `json:"transaction_details"` + Card CardResponse `json:"card"` + PointOfInteraction PointOfInteractionResponse `json:"point_of_interaction"` + PaymentMethod PaymentMethodResponse `json:"payment_method"` + ThreeDSInfo ThreeDSInfoResponse `json:"three_ds_info"` + FeeDetails []FeeDetailResponse `json:"fee_details"` + Taxes []TaxResponse `json:"taxes"` + Refunds []RefundResponse `json:"refunds"` } // PayerResponse represents the payer of the payment. type PayerResponse struct { - Type string `json:"type,omitempty"` - ID string `json:"id,omitempty"` - Email string `json:"email,omitempty"` - FirstName string `json:"first_name,omitempty"` - LastName string `json:"last_name,omitempty"` - EntityType string `json:"entity_type,omitempty"` + Type string `json:"type"` + ID string `json:"id"` + Email string `json:"email"` + FirstName string `json:"first_name"` + LastName string `json:"last_name"` + EntityType string `json:"entity_type"` - Identification *IdentificationResponse `json:"identification,omitempty"` + Identification IdentificationResponse `json:"identification"` } // IdentificationResponse represents payer's personal identification. type IdentificationResponse struct { - Type string `json:"type,omitempty"` - Number string `json:"number,omitempty"` + Type string `json:"type"` + Number string `json:"number"` } // AdditionalInfoResponse represents additional information about a payment. type AdditionalInfoResponse struct { - IPAddress string `json:"ip_address,omitempty"` + IPAddress string `json:"ip_address"` - Payer *AdditionalInfoPayerResponse `json:"payer,omitempty"` - Shipments *ShipmentsResponse `json:"shipments,omitempty"` - Items []ItemResponse `json:"items,omitempty"` + Payer AdditionalInfoPayerResponse `json:"payer"` + Shipments ShipmentsResponse `json:"shipments"` + Items []ItemResponse `json:"items"` } // ItemResponse represents an item. type ItemResponse struct { - ID string `json:"id,omitempty"` - Title string `json:"title,omitempty"` - Description string `json:"description,omitempty"` - PictureURL string `json:"picture_url,omitempty"` - CategoryID string `json:"category_id,omitempty"` - Quantity int `json:"quantity,omitempty"` - UnitPrice float64 `json:"unit_price,omitempty"` + ID string `json:"id"` + Title string `json:"title"` + Description string `json:"description"` + PictureURL string `json:"picture_url"` + CategoryID string `json:"category_id"` + Quantity int `json:"quantity"` + UnitPrice float64 `json:"unit_price"` } // AdditionalInfoPayerResponse represents payer's additional information. type AdditionalInfoPayerResponse struct { - FirstName string `json:"first_name,omitempty"` - LastName string `json:"last_name,omitempty"` + FirstName string `json:"first_name"` + LastName string `json:"last_name"` - RegistrationDate *time.Time `json:"registration_date,omitempty"` - Phone *PhoneResponse `json:"phone,omitempty"` - Address *AddressResponse `json:"address,omitempty"` + RegistrationDate time.Time `json:"registration_date"` + Phone PhoneResponse `json:"phone"` + Address AddressResponse `json:"address"` } // PhoneResponse represents phone information. type PhoneResponse struct { - AreaCode string `json:"area_code,omitempty"` - Number string `json:"number,omitempty"` + AreaCode string `json:"area_code"` + Number string `json:"number"` } // AddressResponse represents address information. type AddressResponse struct { - ZipCode string `json:"zip_code,omitempty"` - StreetName string `json:"street_name,omitempty"` - StreetNumber string `json:"street_number,omitempty"` + ZipCode string `json:"zip_code"` + StreetName string `json:"street_name"` + StreetNumber string `json:"street_number"` } // ShipmentsResponse represents shipment information. type ShipmentsResponse struct { - ReceiverAddress *ReceiverAddressResponse `json:"receiver_address,omitempty"` + ReceiverAddress ReceiverAddressResponse `json:"receiver_address"` } // ReceiverAddressResponse represents the receiver's address within ShipmentsResponse. type ReceiverAddressResponse struct { - StateName string `json:"state_name,omitempty"` - CityName string `json:"city_name,omitempty"` - Floor string `json:"floor,omitempty"` - Apartment string `json:"apartment,omitempty"` + StateName string `json:"state_name"` + CityName string `json:"city_name"` + Floor string `json:"floor"` + Apartment string `json:"apartment"` - Address *AddressResponse `json:"address,omitempty"` + Address AddressResponse `json:"address"` } // OrderResponse represents order information. type OrderResponse struct { - ID int `json:"id,omitempty"` - Type string `json:"type,omitempty"` + ID int `json:"id"` + Type string `json:"type"` } // TransactionDetailsResponse represents transaction details. type TransactionDetailsResponse struct { - FinancialInstitution string `json:"financial_institution,omitempty"` - ExternalResourceURL string `json:"external_resource_url,omitempty"` - PaymentMethodReferenceID string `json:"payment_method_reference_id,omitempty"` - AcquirerReference string `json:"acquirer_reference,omitempty"` - TransactionID string `json:"transaction_id,omitempty"` - NetReceivedAmount float64 `json:"net_received_amount,omitempty"` - TotalPaidAmount float64 `json:"total_paid_amount,omitempty"` - InstallmentAmount float64 `json:"installment_amount,omitempty"` - OverpaidAmount float64 `json:"overpaid_amount,omitempty"` + FinancialInstitution string `json:"financial_institution"` + ExternalResourceURL string `json:"external_resource_url"` + PaymentMethodReferenceID string `json:"payment_method_reference_id"` + AcquirerReference string `json:"acquirer_reference"` + TransactionID string `json:"transaction_id"` + NetReceivedAmount float64 `json:"net_received_amount"` + TotalPaidAmount float64 `json:"total_paid_amount"` + InstallmentAmount float64 `json:"installment_amount"` + OverpaidAmount float64 `json:"overpaid_amount"` } // CardResponse represents card information. type CardResponse struct { - ID string `json:"id,omitempty"` - LastFourDigits string `json:"last_four_digits,omitempty"` - FirstSixDigits string `json:"first_six_digits,omitempty"` - ExpirationYear int `json:"expiration_year,omitempty"` - ExpirationMonth int `json:"expiration_month,omitempty"` + ID string `json:"id"` + LastFourDigits string `json:"last_four_digits"` + FirstSixDigits string `json:"first_six_digits"` + ExpirationYear int `json:"expiration_year"` + ExpirationMonth int `json:"expiration_month"` - DateCreated *time.Time `json:"date_created,omitempty"` - DateLastUpdated *time.Time `json:"date_last_updated,omitempty"` - Cardholder *CardholderResponse `json:"cardholder,omitempty"` + DateCreated time.Time `json:"date_created"` + DateLastUpdated time.Time `json:"date_last_updated"` + Cardholder CardholderResponse `json:"cardholder"` } // CardholderResponse represents cardholder information. type CardholderResponse struct { - Name string `json:"name,omitempty"` + Name string `json:"name"` - Identification *IdentificationResponse `json:"identification,omitempty"` + Identification IdentificationResponse `json:"identification"` } // PointOfInteractionResponse represents point of interaction information. type PointOfInteractionResponse struct { - Type string `json:"type,omitempty"` - SubType string `json:"sub_type,omitempty"` - LinkedTo string `json:"linked_to,omitempty"` + Type string `json:"type"` + SubType string `json:"sub_type"` + LinkedTo string `json:"linked_to"` - ApplicationData *ApplicationDataResponse `json:"application_data,omitempty"` - TransactionData *TransactionDataResponse `json:"transaction_data,omitempty"` + ApplicationData ApplicationDataResponse `json:"application_data"` + TransactionData TransactionDataResponse `json:"transaction_data"` } // ApplicationDataResponse represents application data within PointOfInteractionResponse. type ApplicationDataResponse struct { - Name string `json:"name,omitempty"` - Version string `json:"version,omitempty"` + Name string `json:"name"` + Version string `json:"version"` } // TransactionDataResponse represents transaction data within PointOfInteractionResponse. type TransactionDataResponse struct { - QRCode string `json:"qr_code,omitempty"` - QRCodeBase64 string `json:"qr_code_base64,omitempty"` - TransactionID string `json:"transaction_id,omitempty"` - TicketURL string `json:"ticket_url,omitempty"` - SubscriptionID string `json:"subscription_id,omitempty"` - BillingDate string `json:"billing_date,omitempty"` - BankTransferID int64 `json:"bank_transfer_id,omitempty"` - FinancialInstitution int64 `json:"financial_institution,omitempty"` - FirstTimeUse bool `json:"first_time_use,omitempty"` - - BankInfo *BankInfoResponse `json:"bank_info,omitempty"` - SubscriptionSequence *SubscriptionSequenceResponse `json:"subscription_sequence,omitempty"` - InvoicePeriod *InvoicePeriodResponse `json:"invoice_period,omitempty"` - PaymentReference *PaymentReferenceResponse `json:"payment_reference,omitempty"` + QRCode string `json:"qr_code"` + QRCodeBase64 string `json:"qr_code_base64"` + TransactionID string `json:"transaction_id"` + TicketURL string `json:"ticket_url"` + SubscriptionID string `json:"subscription_id"` + BillingDate string `json:"billing_date"` + BankTransferID int64 `json:"bank_transfer_id"` + FinancialInstitution int64 `json:"financial_institution"` + FirstTimeUse bool `json:"first_time_use"` + + BankInfo BankInfoResponse `json:"bank_info"` + SubscriptionSequence SubscriptionSequenceResponse `json:"subscription_sequence"` + InvoicePeriod InvoicePeriodResponse `json:"invoice_period"` + PaymentReference PaymentReferenceResponse `json:"payment_reference"` } // BankInfoResponse represents bank information. type BankInfoResponse struct { - IsSameBankAccountOwner string `json:"is_same_bank_account_owner,omitempty"` + IsSameBankAccountOwner string `json:"is_same_bank_account_owner"` - Payer *BankInfoPayerResponse `json:"payer,omitempty"` - Collector *BankInfoCollectorResponse `json:"collector,omitempty"` + Payer BankInfoPayerResponse `json:"payer"` + Collector BankInfoCollectorResponse `json:"collector"` } // SubscriptionSequenceResponse represents subscription sequence. type SubscriptionSequenceResponse struct { - Number int64 `json:"number,omitempty"` - Total int64 `json:"total,omitempty"` + Number int64 `json:"number"` + Total int64 `json:"total"` } // InvoicePeriodResponse represents invoice period. type InvoicePeriodResponse struct { - Type string `json:"type,omitempty"` - Period int64 `json:"period,omitempty"` + Type string `json:"type"` + Period int64 `json:"period"` } // PaymentReferenceResponse represents payment reference. type PaymentReferenceResponse struct { - ID string `json:"id,omitempty"` + ID string `json:"id"` } // BankInfoPayerResponse represents payer information within BankInfoResponse. type BankInfoPayerResponse struct { - Email string `json:"email,omitempty"` - LongName string `json:"long_name,omitempty"` - AccountID int64 `json:"account_id,omitempty"` + Email string `json:"email"` + LongName string `json:"long_name"` + AccountID int64 `json:"account_id"` } // BankInfoCollectorResponse represents collector information within BankInfoResponse. type BankInfoCollectorResponse struct { - LongName string `json:"long_name,omitempty"` - AccountID int64 `json:"account_id,omitempty"` + LongName string `json:"long_name"` + AccountID int64 `json:"account_id"` } // PaymentMethodResponse represents payment method information. type PaymentMethodResponse struct { - ID string `json:"id,omitempty"` - Type string `json:"type,omitempty"` - IssuerID string `json:"issuer_id,omitempty"` + ID string `json:"id"` + Type string `json:"type"` + IssuerID string `json:"issuer_id"` - Data *DataResponse `json:"data,omitempty"` + Data DataResponse `json:"data"` } // DataResponse represents data within PaymentMethodResponse. type DataResponse struct { - Rules *RulesResponse `json:"rules,omitempty"` + Rules RulesResponse `json:"rules"` } // RulesResponse represents payment rules. type RulesResponse struct { - Fine *FeeResponse `json:"fine,omitempty"` - Interest *FeeResponse `json:"interest,omitempty"` - Discounts []DiscountResponse `json:"discounts,omitempty"` + Fine FeeResponse `json:"fine"` + Interest FeeResponse `json:"interest"` + Discounts []DiscountResponse `json:"discounts"` } // DiscountResponse represents payment discount information. type DiscountResponse struct { - Type string `json:"type,omitempty"` - Value float64 `json:"value,omitempty"` + Type string `json:"type"` + Value float64 `json:"value"` - LimitDate *time.Time `json:"limit_date,omitempty"` + LimitDate time.Time `json:"limit_date"` } // FeeResponse represents payment fee information. type FeeResponse struct { - Type string `json:"type,omitempty"` - Value float64 `json:"value,omitempty"` + Type string `json:"type"` + Value float64 `json:"value"` } // ThreeDSInfoResponse represents 3DS (Three-Domain Secure) information. type ThreeDSInfoResponse struct { - ExternalResourceURL string `json:"external_resource_url,omitempty"` - Creq string `json:"creq,omitempty"` + ExternalResourceURL string `json:"external_resource_url"` + Creq string `json:"creq"` } // FeeDetailResponse represents payment fee detail information. type FeeDetailResponse struct { - Type string `json:"type,omitempty"` - FeePayer string `json:"fee_payer,omitempty"` - Amount float64 `json:"amount,omitempty"` + Type string `json:"type"` + FeePayer string `json:"fee_payer"` + Amount float64 `json:"amount"` } // TaxResponse represents tax information. type TaxResponse struct { - Type string `json:"type,omitempty"` - Value float64 `json:"value,omitempty"` + Type string `json:"type"` + Value float64 `json:"value"` } // RefundResponse represents refund information. type RefundResponse struct { - Status string `json:"status,omitempty"` - RefundMode string `json:"refund_mode,omitempty"` - Reason string `json:"reason,omitempty"` - UniqueSequenceNumber string `json:"unique_sequence_number,omitempty"` - ID int64 `json:"id,omitempty"` - PaymentID int64 `json:"payment_id,omitempty"` - Amount float64 `json:"amount,omitempty"` - AdjustmentAmount float64 `json:"adjustment_amount,omitempty"` + Status string `json:"status"` + RefundMode string `json:"refund_mode"` + Reason string `json:"reason"` + UniqueSequenceNumber string `json:"unique_sequence_number"` + ID int64 `json:"id"` + PaymentID int64 `json:"payment_id"` + Amount float64 `json:"amount"` + AdjustmentAmount float64 `json:"adjustment_amount"` - DateCreated *time.Time `json:"date_created,omitempty"` - Source *SourceResponse `json:"source,omitempty"` + DateCreated time.Time `json:"date_created"` + Source SourceResponse `json:"source"` } // SourceResponse represents source information. type SourceResponse struct { - ID string `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Type string `json:"type,omitempty"` + ID string `json:"id"` + Name string `json:"name"` + Type string `json:"type"` } diff --git a/resources/mocks/payment/search_response.json b/resources/mocks/payment/search_response.json index 5b9f31fd..6f8d8ef2 100644 --- a/resources/mocks/payment/search_response.json +++ b/resources/mocks/payment/search_response.json @@ -6,12 +6,12 @@ }, "results": [ { - "id": 123, + "id": 57592046572, "status": "approved", "status_detail": "accredited" }, { - "id": 456, + "id": 57592038796, "status": "pending", "status_detail": "pending_waiting_transfer" }