Skip to content

"Failed to parse the response: Cannot convert null value to System.DateTime. Path 'due_at', line 1, position 222." ao gerar a cobrança #82

@profalves

Description

@profalves
public object SendCreditCardPayment(dynamic body, dynamic order)
        {
            try
            {
                string orderID = GetOrderID(order);

                string basicAuthUserName = "sk_test_algumcodigo"; // sua secret key 
                string basicAuthPassword = "";

                MundiAPIClient client = new MundiAPIClient(basicAuthUserName, basicAuthPassword);

                //string customerId = "cus_6l5dMWZ0hkHZ4XnE";

                //var query = client.Customers.GetCustomer(customerId);

                //if() ... tratar cliente

                var customer = new CreateCustomerRequest
                {
                    Name = "Consumidor",
                    Email = "email@email.com",
                };



                var request = new CreateChargeRequest()
                {
                    Amount = body.amount,
                    Code = orderID,
                    Customer = customer,
                    Payment = new CreatePaymentRequest()
                    {
                        PaymentMethod = body.paymentMethod,
                        CreditCard = new CreateCreditCardPaymentRequest()
                        {
                            Card = new CreateCardRequest
                            {
                                Number = "4000000000000010",
                                HolderName = body.card.holderName,
                                ExpMonth = body.card.expMonth,
                                ExpYear = body.card.expYear,
                                Cvv = body.card.cvv,
                            }
                        }
                    }
                };

                GetChargeResponse response = client.Charges.CreateCharge(request);

                var result = JObject.FromObject(response);

                return result;
            }
            catch (Exception ex)
            {

                throw ex;
            }

Quando vou obter a resposta dá erro de parse no campo due_at pois retorna nulo. Eu vejo que a cobrança é gerada mas não consegue associar na resposta. Já usei até var no lugar do tipo GetChargeResponse, mas o erro é o mesmo. Como pode ser resolvido essa situação?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions