Skip to main content

Create Order with Payment Reference

Creates an order in prepaid mode and generates an associated Yego Paycash payment reference. Stock for the requested products is reserved immediately and remains reserved until payment is confirmed or the reference expires.

Authentication​

This endpoint requires a Bearer token issued for your client account.

Authorization: Bearer <your_token>

Endpoint​

POST /v1/shipments/prepaid-orders/payment-reference

Request​

Headers​

HeaderValueRequired
AuthorizationBearer <token>Yes
Content-Typeapplication/jsonYes

Body​

FieldTypeRequiredMax lengthDescription
unique_order_numberstringYes50Unique order identifier, defined by the client.
total_pricedecimalYes5Total order amount.
warehouse_idintegerYes10Warehouse the order will be fulfilled from.
reference_expiry_daysintegerNo1Number of days the Yego Paycash payment reference will remain valid. Must be between 2 and 5 days. Defaults to 2 when omitted.
consigneeobjectYesβ€”Delivery information. See table below.
order_detailsarrayYesβ€”List of products. See table below.

reference_expiry_days is optional. If it is not provided, the payment reference will be generated with a validity period of 2 days.

When provided, the value must be an integer between 2 and 5, inclusive.

consignee​

FieldTypeRequiredMax lengthDescription
namestringYes35Recipient's full name.
countrystringYes20Country.
statestringYes35State.
municipalitystringYes35Municipality.
neighborhoodstringYes35Neighborhood.
streetstringYes24Street.
external_numberstringYes5External number.
internal_numberstringNo5Internal/apartment number.
zipcodestringYes55-digit postal code.
emailstringNo50A generic email is used if omitted.
phonestringYes1010-digit phone number.
commentsstringNo250Additional delivery instructions.

order_details[]​

FieldTypeRequiredMax lengthDescription
skustringYes35Product SKU.
quantityintegerYes10Quantity requested.

Request example​

curl -X POST https://api.eon.example.com/api/v1/payment_references \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"unique_order_number": "PAYCASH-EXAMPLE",
"total_price": 100.00,
"warehouse_id": 1,
"reference_expiry_days": 5,
"consignee": {
"name": "client name",
"country": "mexico",
"state": "san luis potosi",
"municipality": "san luis potosi",
"neighborhood": "XXXXXXXXXX",
"street": "XXXXXXXXXX",
"external_number": "000",
"internal_number": null,
"zipcode": "00000",
"email": null,
"phone": "4444444444",
"comments": null
},
"order_details": [
{ "sku": "SKU-EXAMPLE", "quantity": 1 }
]
}'

If reference_expiry_days is omitted, the reference will automatically be generated with a validity period of 2 days.

Response​

201 Created​

{
"code": 201,
"success": {
"arguments": {
"reference": "1698353800048",
"paycash_instructions_url": "https://sandboxpaycash.yego.mx/get-reference/MTY5ODM1MzgwMDA0ODoKICAgICAgICAgICAgICAgICAgICAkMTUwMC4wMDoKICAgICAgICAgICAgICAgICAgICAxMC8wOS8yMDI2CiAgICAgICAgICAgICAgICA="
},
"type": "order.created",
"message": "Order created successfully. "
}
}
FieldDescription
referenceYego Paycash payment reference for the buyer to pay in-store.
paycash_instructions_urlLink to payment instructions, including the barcode.

Errors​

StatusError codeCause
401unauthorizedMissing or invalid Bearer token.
404client_not_foundThe client associated with the token does not exist or has been deactivated.
409client_reference_already_existsAn order with that unique_order_number already exists for this client.
409order_already_processingA request with the same unique_order_number is already in progress (concurrent double submission).
422client_not_authorizedThe client does not have a fulfillment method enabled.
422invalid_addressOne or more consignee fields failed format validation.
422invalid_reference_expiry_daysreference_expiry_days must be an integer between 2 and 5, inclusive.
422no_shipping_service_coverageNo carrier has coverage for the given postal code.
422product_not_foundOne or more SKUs do not exist or do not belong to this client.
422insufficient_stockInsufficient stock for one or more products at the given warehouse.
503payment_reference_creation_failedTemporary failure generating the reference with Yego Paycash. Retry.

Error example​

{
"code": 422,
"fault": {
"arguments": [],
"type": "order.invalid_reference_expiry_days",
"message": "reference_expiry_days must be an integer between 2 and 5."
}
}