Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmarshalling invalido en la respuesta de la creacion de una suscripcion #78

Closed
tltorress opened this issue Dec 10, 2024 · 1 comment
Closed

Comments

@tltorress
Copy link

Hola! Al momento de usar el metodo preapproval.Create falla al hacer el unmarshalling de la respuesta por que el struct preapproval.Response espera el CardID como Int, sin embargo, el API de mercadopago lo retorna como String. Ocasionando un error como el siguiente:

json: cannot unmarshal string into Go struct field Response.card_id of type int

Además dejo un fragmento del codigo donde se termina generando el error.

func (c client) CreateSuscription(ctx context.Context, req preapproval.Request) (*preapproval.Response, error) {
    res, err := c.pa.Create(ctx, req)
    if err != nil {
        return nil, err
    }
    return res, nil
}

Un fix sugerido podria ser simplemente cambiar el type del CardID a String

type Response struct {
    AutoRecurring   AutoRecurringResponse json:"auto_recurring"
    Summarized      SummarizedResponse    json:"summarized"
    DateCreated     time.Time             json:"date_created"
    LastModified    time.Time             json:"last_modified"
    NextPaymentDate time.Time             json:"next_payment_date"

    ID                 string json:"id"
    PayerEmail         string json:"payer_email"
    Status             string json:"status"
    Reason             string json:"reason"
    ExternalReference  string json:"external_reference"
    InitPoint          string json:"init_point"
    SandboxInitPoint   string json:"sandbox_init_point"
    PaymentMethodID    string json:"payment_method_id"
    FirstInvoiceOffset string json:"first_invoice_offset"
    BackURL            string json:"back_url"
    PreapprovalPlanID  string json:"preapproval_plan_id"
    PayerFirstName     string json:"payer_first_name"
    PayerLastName      string json:"payer_last_name"
    CardID             string json:"card_id" // <-- Este es el cambio sugerido
    Version            int    json:"version"
    PayerID            int    json:"payer_id"
    CollectorID        int    json:"collector_id"
    ApplicationID      int    json:"application_id"
}
@VickieAranha
Copy link
Contributor

Hola, @tltorress, buenas tardes,

Se implementó la solución sugerida para la versión 1.0.7 del SDK 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants