API Explanation (V2.5)

Source file: Vending Machine Program Integration with Third-Party Software V2.5 new.pdf

Output type: English HTML extract. Non-English content was translated or replaced with the English equivalent already present in the document.

1. Introduction

1.1 Purpose of Writing

This section explains the design considerations of the program system, including the basic processing flow of the program, the organizational structure of the system, module division, function allocation, interface design, and data structure design.

Note: Different users can implement their respective interfaces based on their different needs. If an interface is not relevant, it does not need to be implemented. QR code scanning requires additional hardware installation.

1.2 Terms and Abbreviations

TermExplanationRemark
Stocking (Delivery) The identifier used by the stocking/delivery personnel to open the machine for restocking. It can be entered on the touchscreen or by scanning a QR code. An 8-digit Arabic numeral.
Pick Up Code The password used by the user to collect goods. It can be entered on the touchscreen or by scanning a QR code. An 8-digit Arabic numeral.

2. Summary Design

All interfaces use HTTP POST to send requests to the third-party server, and the returned results are in JSON format. The request address for the VMC is configurable. See the last page for how to enter the server address.

2.1 Interface Design

2.1.1 Restock: Vending machine reports each slot's data to the third party

2.1.1.1 Request

Field NameTypeExplanation
FunCodeStringInterface No: 1000
MachineIDStringMachine ID
TradeNoStringSerial number; return as-is
SlotNoStringSlot number
KeyNumIntKey number, for machines with corresponding buttons
StatusIntSlot status: 0 = normal, other = malfunction
QuantityIntRestocking / delivery quantity
StockIntCurrent stock after restocking / delivery
CapacityIntCapacity
ProductIDStringCommodity / product ID
PriceStringUnit price, e.g. 1.5
TypeStringProduct type
IntroductionStringProduct introduction
NameStringProduct name

Any changes to product data on the machine trigger this interface to report to the third-party server.

2.1.1.2 Response

{"Status":"0","SlotNo":"22","TradeNo":"20170802193446876","Err":"success","ImageUrl":"http://xxx.com/201708029502889.png","ImageDetailUrl":"http://xxx.com/20170801124323318.png"}
Field NameExplanation
Status0 = restocking successful; 1 = re-upload; other = failure. Required.
SlotNoSlot number. Required.
TradeNoUploaded serial number, returned as-is.
ImageUrlProduct image URL.
ImageDetailUrlProduct details image URL.
ErrError description.
Note: Interface 1000 is used to synchronize machine data with the backend. The server must respond in the required format, otherwise the machine will keep reporting.

2.1.2 Verify pick-up code

2.1.2.1 Request

Field NameTypeExplanation
FunCodeStringInterface No: 2000
TradeNoStringOrder number / serial number; return as-is
SessionCodeStringPick-up code entered by the client on the touch screen
MachineIDStringMachine ID
SlotNoStringSlot number
PriceStringUnit price, e.g. 1.5
AccountStringCard number. Usually not used together with SessionCode; choose one.
PWDStringPassword

2.1.2.2 Response

{ "Status": "0","SlotNo":"23","ProductID":"1002356","TradeNo":"20170609123523569","Err":"success"}
Field NameExplanation
Status0 indicates success; others indicate failure. Required.
SlotNoSlot numbers to dispense from. Multiple slots are separated by |. Example: 23|28. Required.
ProductIDProduct ID to dispense. If SlotNo > 0, dispensing prioritizes SlotNo. To dispense by ProductID, set SlotNo to a number less than 1.
TradeNoOrder number, returned as-is. Required.
ErrError description.

2.1.3 Poll interface

2.1.3.1 Request

Field NameTypeExplanation
FunCodeStringInterface No: 4000
MachineIDStringMachine ID

2.1.3.2 Response

Case 1: MsgType = 0. Server controls the VMC to dispense the product.

{ "Status": "0","MsgType":"0","TradeNo":"20170609123523569","SlotNo":"25","ProductID":"1005678692","Err":"success"}
Field NameExplanation
Status0 = success; others = failure.
MsgTypeMessage type.
TradeNoOrder number / serial number.
SlotNoSlot number to dispense from.
ProductIDProduct ID to dispense. If SlotNo > 0, dispensing prioritizes SlotNo. To dispense by ProductID, set SlotNo to a number less than 1.
ErrError description.

Note: This feature is generally used for app or e-commerce one-click pickup. The VMC should call this interface periodically. Recommended interval: 3 seconds.

Case 2: MsgType = 1. E-commerce platform or app notifies the VMC of restocking.

{ "Status": "0","MsgType":"1","SlotNo":"25","TradeNo":"111111","Capacity":"1","Quantity":"1","ProductID":"111111","Name":"dsff","Price":"2.0","Type":"yinl","Introduction":"ssfsf","ImageUrl":"http://xxx.com/201708029502889.png","ImageDetailUrl":"http://xxx.com/201708029502889.png","GoodsAdUrl":"ssfsf","Err":"success"}
Field NameExplanation
Status0 = restocking needed; others = not needed.
MsgTypeMessage type = 1.
SlotNoSlot number.
ErrError description.
CapacityCapacity.
QuantityRestock quantity.
ProductIDProduct ID.
NameProduct name.
PricePrice.
TypeProduct type.
IntroductionProduct description.
ImageUrlProduct image URL.
ImageDetailUrlProduct details image URL.

Note: After successful restocking, call the restocking result feedback interface. Since polling happens every 3 seconds, the machine needs time to update product information after receiving the message. The server can wait a while before checking for success or failure feedback. During this wait, the response can still return the content for server-controlled dispensing.

Note: After downloading, call the download result feedback interface. Because polling happens every 3 seconds, the machine needs time to download the advertisement after publication. The server can wait before checking for success/failure feedback. During this wait, it can still return content for server-controlled dispensing. When returning ad content, return all published ads, including ones already downloaded successfully, because the local machine compares against the returned ad list and deletes ads that are no longer present.

2.1.4 Result feedback

2.1.4.1 Product delivery feedback

Field NameTypeExplanation
FunCodeStringInterface No: 5000
MachineIDStringMachine ID
PayTypeIntPayment type
TradeNoStringOrder number / serial number
SlotNoStringSlot number
StatusInt0 = dispensing successful; 1 = dispensing failed; 2 = dispensing successful but order number missing or invalid; 3 = dispensing failed but order number missing or invalid; 4 = dispensing result unknown
TimeStringDelivery time
AmountStringAmount
ProductIDStringProduct ID
NameStringProduct name
TypeStringProduct type

2.1.4.2 Response

{ "Status": "0","TradeNo":"20170609123523569","SlotNo":"25","Err":"success"}
Field NameExplanation
Status0 = confirmation successful; others = failure.
TradeNoOrder number / serial number.
SlotNoSlot number.
ErrError description.
Note: Interface 5000 is used to report dispensing results. The server must respond in the required format, otherwise the machine will keep reporting this result.

2.1.4.3 APP restocking result feedback request

Field NameTypeExplanation
FunCodeStringInterface No: 5001
MachineIDStringMachine ID
SlotNoStringSlot number
StatusInt0 = success; others = failure

2.1.4.4 Response

{ "Status": "0","SlotNo":"25","TradeNo":"20170609123523569","Err":"success"}
Field NameExplanation
Status0 = confirmation successful; others = failure.
SlotNoSlot number.
TradeNoOrder number, returned as-is.
ErrError description.

Polling traffic note: The polling interface (Funcode 4000) polls every 3 seconds by default, which can consume a lot of data.

  1. Increase the polling interval on the machine if remote control dispensing is not used.
  2. If the server has no useful information to send when it receives a polling request, it can delay the response by 60–90 seconds. If the interface is unused, it can also choose not to respond.

3. Android Application Server Address Configuration

3.1 Connect the machine to the network

3.2 Enter settings in the Android program

Go to the machine administration settings page, open E-Commerce pickup, and enter your server address there to receive data.

Note: The original PDF appears to include configuration screenshots on the last pages. Text extraction did not capture the image content.