Skip to content

Expected value to be of type 'Optional<Nullable<string>>' but found 'boolean'.\n #14

Description

@brennomeneses

Quando tentei usar split de pagamento ele até dá sucesso no corpo de requisição, porém ele logo em seguida dá um throw em um erro.

...rest
message: "Expected value to be of type 'Optional<Nullable<string>>' but found 'boolean'.\n" +
        '\n' +
        'Given value: true\n' +
        "Type: 'boolean'\n" +
        "Expected type: 'Optional<Nullable<string>>'\n" +
        'Path: charges › 0 › last_transaction › split › 0 › options › charge_remainder_fee'
    }

O codigo referente ao script:

...rest,
split: [{
                type: "percentage",
                amount: 100,
                recipientId: "re_clhkul8zt0gq7019t7ep4rdd1",
                options: {
                    liable: true,
                    chargeRemainderFee: true,
                    chargeProcessingFee: true
                }
            }]

Ao usar o cURL ele funciona certo sem erros:

curl --request POST \
     --url https://api.pagar.me/core/v5/orders \
     --header 'accept: application/json' \
     --header 'authorization: Basic c2tfdGVzdF9WT0tYUkxaQ2FRVHgwTG9EOg==' \
     --header 'content-type: application/json' \
     --data '
{
  "items": [
    {
      "amount": 100,
      "description": "Chaveiro do Tesseract",
      "quantity": 1,
      "code": "12345"
    }
  ],
  "customer": {
    "name": "Tony Stark",
    "email": "Tony@Avangers.com"
  },
  "payments": [
    {
      "credit_card": {
        "card": {
          "billing_address": {
            "line_1": "10880, Malibu Point, Malibu Central",
            "zip_code": "90265",
            "city": "Malibu",
            "state": "CA",
            "country": "US"
          },
          "number": "342793631858229",
          "holder_name": "Tony Stark",
          "exp_month": 1,
          "exp_year": 30,
          "cvv": "3531"
        },
        "installments": 1,
        "statement_descriptor": "AVENGERS"
      },
      "split": [
        {
          "options": {
            "charge_processing_fee": true,
            "charge_remainder_fee": true,
            "liable": true
          },
          "amount": 100,
          "recipient_id": "TEST",
          "type": "percentage"
        }
      ],
      "payment_method": "credit_card"
    }
  ]
}
'

Acredito que seja algo relacionado a alguma conversão de valor, uma vez que ele dá sucesso pelo cURL

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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