Plasma

Pedidos

Gerencie pedidos, atualize status e acompanhe fulfillment.

Visão Geral

A API de Pedidos permite consultar e gerenciar todos os pedidos da sua loja. Você pode listar, buscar detalhes, criar e atualizar o status dos pedidos.

Endpoints

MétodoEndpointDescrição
GET/api/sdk/ordersListar pedidos
POST/api/sdk/ordersCriar pedido
GET/api/sdk/orders/:idBuscar pedido
PATCH/api/sdk/orders/:idAtualizar pedido

Listar Pedidos

GET /api/sdk/orders

Parâmetros de Query

ParâmetroTipoDescrição
limitnumberMáximo de itens (1-100, padrão: 50)
cursorstringCursor para paginação
statusstringpending, processing, completed, cancelled
paymentStatusstringpending, paid, failed, refunded
fulfillmentStatusstringunfulfilled, partial, fulfilled
customerEmailstringFiltrar por email do cliente
orderNumberstringBuscar por número do pedido
searchstringBusca por número, email ou nome
dateFromstringData inicial (ISO 8601)
dateTostringData final (ISO 8601)
sortBystringOrdenar por: createdAt, updatedAt, total, orderNumber
sortOrderstringasc ou desc (padrão: desc)

Exemplo

curl -X GET "https://api.plasmacheckout.com/api/sdk/orders?status=pending&limit=10" \
  -H "X-PLASMA-Public-Key: pk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "X-PLASMA-Secret-Key: sk_live_xxxxxxxxxxxxxxxxxxxx"
const response = await fetch(
  'https://api.plasmacheckout.com/api/sdk/orders?status=pending&limit=10',
  {
    headers: {
      'X-PLASMA-Public-Key': 'pk_live_xxxxxxxxxxxxxxxxxxxx',
      'X-PLASMA-Secret-Key': 'sk_live_xxxxxxxxxxxxxxxxxxxx'
    }
  }
);

const result = await response.json();
console.log(result.data);        // array de pedidos
console.log(result.pagination);  // { hasMore, nextCursor, count, total }
import requests

response = requests.get(
    'https://api.plasmacheckout.com/api/sdk/orders',
    headers={
        'X-PLASMA-Public-Key': 'pk_live_xxxxxxxxxxxxxxxxxxxx',
        'X-PLASMA-Secret-Key': 'sk_live_xxxxxxxxxxxxxxxxxxxx'
    },
    params={'status': 'pending', 'limit': 10}
)

data = response.json()
print(data['data'])
print(data['pagination'])

Resposta

{
  "data": [
    {
      "id": "cm5order123abc456def",
      "orderNumber": "PLS-2025-A1B2C3",
      "status": "processing",
      "paymentStatus": "paid",
      "fulfillmentStatus": "unfulfilled",
      "customerEmail": "cliente@email.com",
      "customerName": "João Silva",
      "customerPhone": "+5511999999999",
      "shippingAddress": {
        "street": "Rua das Flores, 123",
        "city": "São Paulo",
        "state": "SP",
        "zipCode": "01234-567",
        "country": "BR"
      },
      "billingAddress": null,
      "items": [
        {
          "productId": "cm5abc123def456ghi789",
          "title": "Camiseta Premium",
          "quantity": 2,
          "price": 7990,
          "sku": "CAM-001"
        }
      ],
      "subtotal": 15980,
      "shipping": 1500,
      "discount": 0,
      "tax": 0,
      "total": 17480,
      "currency": "BRL",
      "paymentMethod": "pix",
      "notes": "",
      "metadata": null,
      "createdAt": "2025-01-15T10:00:00Z",
      "updatedAt": "2025-01-15T10:30:00Z"
    }
  ],
  "pagination": {
    "hasMore": true,
    "nextCursor": "cm5order123abc456deg",
    "count": 10,
    "total": 250
  },
  "filters": {
    "status": "pending",
    "paymentStatus": null,
    "fulfillmentStatus": null,
    "customerEmail": null,
    "dateFrom": null,
    "dateTo": null
  }
}

Criar Pedido

POST /api/sdk/orders

Body

CampoTipoObrigatórioDescrição
customerobjectDados do cliente
customer.emailstringEmail do cliente (formato válido)
customer.namestringNome completo
customer.phonestringTelefone
itemsarrayItens do pedido (min 1)
items[].productIdstringID do produto (opcional)
items[].titlestringTítulo do item
items[].quantitynumberQuantidade (min 1)
items[].pricenumberPreço unitário em centavos
items[].skustringSKU do item
shippingAddressobjectEndereço de entrega
billingAddressobjectEndereço de cobrança (padrão: shipping)
shippingnumberValor do frete em centavos
discountnumberValor do desconto em centavos
taxnumberValor do imposto em centavos
currencystringMoeda (padrão: BRL)
paymentMethodstringpix, credit_card, boleto, external
notesstringObservações (max 1000 chars)
metadataobjectDados extras

O campo items[].productId é opcional. Você pode criar pedidos com itens customizados fornecendo title e price diretamente.

Exemplo

curl -X POST "https://api.plasmacheckout.com/api/sdk/orders" \
  -H "X-PLASMA-Public-Key: pk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "X-PLASMA-Secret-Key: sk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "customer": {
      "email": "cliente@email.com",
      "name": "João Silva",
      "phone": "+5511999999999"
    },
    "items": [
      {
        "productId": "cm5abc123def456ghi789",
        "title": "Camiseta Premium",
        "quantity": 2,
        "price": 7990
      },
      {
        "title": "Embalagem Presente",
        "quantity": 1,
        "price": 500
      }
    ],
    "shippingAddress": {
      "street": "Rua das Flores, 123",
      "city": "São Paulo",
      "state": "SP",
      "zipCode": "01234-567",
      "country": "BR"
    },
    "shipping": 1500,
    "tax": 0,
    "paymentMethod": "pix"
  }'
const response = await fetch('https://api.plasmacheckout.com/api/sdk/orders', {
  method: 'POST',
  headers: {
    'X-PLASMA-Public-Key': 'pk_live_xxxxxxxxxxxxxxxxxxxx',
    'X-PLASMA-Secret-Key': 'sk_live_xxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    customer: {
      email: 'cliente@email.com',
      name: 'João Silva',
      phone: '+5511999999999'
    },
    items: [
      { productId: 'cm5abc123def456ghi789', title: 'Camiseta Premium', quantity: 2, price: 7990 },
      { title: 'Embalagem Presente', quantity: 1, price: 500 }
    ],
    shippingAddress: {
      street: 'Rua das Flores, 123',
      city: 'São Paulo',
      state: 'SP',
      zipCode: '01234-567',
      country: 'BR'
    },
    shipping: 1500,
    paymentMethod: 'pix'
  })
});

const { data, message } = await response.json();

Resposta (201 Created)

{
  "data": {
    "id": "cm5order123abc456def",
    "orderNumber": "PLS-2025-A1B2C3",
    "status": "pending",
    "paymentStatus": "pending",
    "fulfillmentStatus": "unfulfilled",
    "subtotal": 16480,
    "shipping": 1500,
    "discount": 0,
    "tax": 0,
    "total": 17980,
    "currency": "BRL",
    "paymentMethod": "pix",
    "createdAt": "2025-01-15T10:00:00Z"
  },
  "message": "Order created successfully"
}

O total é calculado automaticamente: subtotal + shipping - discount + tax. O total não pode ser negativo.

Ao criar um pedido, o webhook order.created é disparado automaticamente.


Buscar Pedido

GET /api/sdk/orders/:id

Retorna o pedido com todos os itens e detalhes.

curl -X GET "https://api.plasmacheckout.com/api/sdk/orders/cm5order123abc456def" \
  -H "X-PLASMA-Public-Key: pk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "X-PLASMA-Secret-Key: sk_live_xxxxxxxxxxxxxxxxxxxx"
const response = await fetch(
  'https://api.plasmacheckout.com/api/sdk/orders/cm5order123abc456def',
  {
    headers: {
      'X-PLASMA-Public-Key': 'pk_live_xxxxxxxxxxxxxxxxxxxx',
      'X-PLASMA-Secret-Key': 'sk_live_xxxxxxxxxxxxxxxxxxxx'
    }
  }
);

const { data } = await response.json();

Atualizar Pedido

PATCH /api/sdk/orders/:id

Campos Atualizáveis

CampoTipoDescrição
statusstringpending, processing, completed, cancelled
paymentStatusstringpending, paid, failed, refunded
fulfillmentStatusstringunfulfilled, partial, fulfilled
trackingNumberstringCódigo de rastreio
trackingUrlstringURL de rastreamento
notesstringObservações internas
metadataobjectMetadados extras

Exemplo — Marcar como Pago

curl -X PATCH "https://api.plasmacheckout.com/api/sdk/orders/cm5order123abc456def" \
  -H "X-PLASMA-Public-Key: pk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "X-PLASMA-Secret-Key: sk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "paymentStatus": "paid"
  }'

Exemplo — Adicionar Rastreio

curl -X PATCH "https://api.plasmacheckout.com/api/sdk/orders/cm5order123abc456def" \
  -H "X-PLASMA-Public-Key: pk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "X-PLASMA-Secret-Key: sk_live_xxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "fulfillmentStatus": "fulfilled",
    "trackingNumber": "BR123456789BR",
    "trackingUrl": "https://rastreamento.correios.com.br/BR123456789BR"
  }'

Resposta

{
  "data": {
    "id": "cm5order123abc456def",
    "orderNumber": "PLS-2025-A1B2C3",
    "status": "processing",
    "paymentStatus": "paid",
    "fulfillmentStatus": "fulfilled",
    "trackingNumber": "BR123456789BR",
    "trackingUrl": "https://rastreamento.correios.com.br/BR123456789BR",
    "updatedAt": "2025-01-15T11:30:00Z"
  },
  "message": "Order updated successfully"
}

Status do Pedido

Status Geral

StatusDescrição
pendingAguardando processamento
processingEm processamento
completedConcluído
cancelledCancelado

Status de Pagamento

StatusDescrição
pendingAguardando pagamento
paidPago
failedFalhou
refundedReembolsado

Status de Fulfillment

StatusDescrição
unfulfilledNão enviado
partialParcialmente enviado
fulfilledEnviado completamente

Webhooks Relacionados

EventoQuando é disparado
order.createdPedido criado
order.paidpaymentStatus atualizado para paid
order.fulfilledfulfillmentStatus atualizado para fulfilled
order.cancelledstatus atualizado para cancelled
order.refundedpaymentStatus atualizado para refunded

Os webhooks são disparados automaticamente quando você atualiza o status via API.