Add/Update Orden de compra


The following endpoint can be used to add or update a orden de compra within the CoCard Pay Center application. When a orden de compra is added to CoCard Pay Center, a payment request will be automatically generated and the customer will be notified via text message, email or both based on the notification options set on the customer record.

If you choose to omit the customer info, a payment link will be provided in the API response. The payment link can be used on a self-checkout system or kiosk.

If the customer is viewing the orden de compra on their device and the orden de compra is updated, a message will display letting the customer know the orden de compra has been updated and the new version of the orden de compra will automatically be displayed on the customers device.


Punto Final

The following endpoint can be used to add or update a orden de compra. You must replace the {base_url} and {site_id} variable with the site id that was provided when the site was created.

POST
{base_url}/api/v4/site/{site_id}/invoice/addUpdate

Solicitud
Campo
Tipo
Descripción
externalId
String
The unique invoice id from the source system/database. If we detect a record with the same `external_id`, it will be updated, otherwise it will be added.
invoiceNumber
String
El número único asignado por el sistema fuente y mostrado al cliente en el orden de compra.
totals
The total amounts on the orden de compra. Validated against the sum of the line items found in `lines`.
customer
Una referencia al registro del cliente. Omita este campo para recibir un enlace al orden de compra.
invoiceTermName
String
The invoice term name for the orden de compra. Defaults to the customer invoice term if it exists, unless `null` is passed in.
lines
A list of line items on the orden de compra. Required if `description` is not passed in.
description
String
A short description of the products/services on the orden de compra. Required if `lines` are not passed in.
invoiceDate
Date
La fecha del orden de compra. Si se establece en el futuro, la solicitud no se enviará hasta esa fecha. El valor predeterminado es hoy si se deja en blanco. Format = YYYY-MM-DD
customerMemo
String
Una nota presentada al cliente en la parte inferior del orden de compra.
internalMemo
String
Un memo agregado en la parte inferior del orden de compra. Solo visible para el personal interno, nunca se muestra a los clientes.
payments
Una lista de pagos realizados en el orden de compra.
webhookUrl
String
La URL a la que se enviará la publicación cuando se realicen ciertas acciones en el orden de compra. Se enviarán notificaciones cuando un texto/correo electrónico falle, un cliente haga clic en un enlace o realice un pago.
options
Opciones para configurar en el orden de compra.
attachmentRefs
Una lista de adjuntos.
deleted
Boolean
Esta bandera representa si el registro ha sido eliminado y ya no está disponible para ser utilizado.
Sample Request (Simple)
			
{
  "external_id": "439772921",
  "invoice_number": "12345",
  "description": "Merchandise Bundle",
  "totals": {
    "total": 45.99
  },
  "customer": {
    "external_id": "39772634",
    "first_name": "John",
    "last_name": "Doe",
    "mobile_phone": "111-222-3333",
    "email": "johndoe@abc.com"
  },
  "options": {
    "tippingEnabled": false
  },
  "webhook_url": "https://yourcompany.com/webhook"
}


		
Sample Request (Advanced)
			
{
  "external_id": "439772921",
  "invoice_number": "12345",
  "description": "",
  "customer_memo": "Thank you for your business!",
  "internal_memo": "",
  "invoice_date": "2022-12-01",
  "invoice_term_name": null,
  "expire_at": "2023-01-01",
  "totals": {
    "taxes": 2.85,
    "total": 30
  },
  "customer": {
    "external_id": "39772634",
    "first_name": "John",
    "last_name": "Doe",
    "mobile_phone": "111-222-3333",
    "email": "johndoe@abc.com"
  },
  "lines": [
    {
      "description": "",
      "product": {
        "external_id": "62331255",
        "name": "Mens Large T-shirt",
        "unit_price": 15
      },
      "unit_price": 15,
      "qty": 2,
      "total": 30
    }
  ],
  "payments": [
    {
      "external_id": "72345322",
      "payment_type": "payment_card",
      "payment_sub_type": "amex",
      "display_name": "AMEX ****** 3422",
      "amount": 20,
      "gateway_transaction_id": 1234,
      "paid_on": "2021-03-15T16:32:11Z",
      "active": true
    }
  ],
  "options": {
    "tippingEnabled": false
  },
  "webhook_url": "https://yourcompany.com/webhook",
  "attachments": [
    "https://url.to.your/attachment"
  ]
}


		
Respuesta
Campo
Tipo
Descripción
success
Boolean
Whether the record was added or updated successfully.
action
String
Informs whether the record was added or updated. Will only be returned if `success` is `true`.
One of `added`, `updated`
_id
String
The auto generated id assigned to the record.
errors
String [ ]
A list of errors. Will only be returned if `success` is `false`.
link
String
The link to the orden de compra. Only returned if a `customer` is not passed in.
Sample Response (Successful)
			
{
  "success": true,
  "action": "added",
  "_id": "60f720d248f143332af022e0",
  "link": "https//site.url/KA39T1A45JL"
}


		
Sample Response (Failed)
			
{
  "success": false,
  "errors": [
    "invalid field2",
    "missing field_name"
  ]
}