# Generate orders

# Interface call request specification

The connection is suitable for useChecksum for ticket paymentScenarios where you don't need to pull up the checkout (request order payment), seeDevelopment guideSection 3.3

Note: The interface is reentrant iforder_idorout_order_idExisting, updates entire order data directly

A successful request will create an order with status = 10 (see status enumeration below)

Each ticket can only be consumed once, creating the order interface can be adjusted several times, but whether to generate a new ticket depends on the situation Scenario A: The first generation of ticketA, ticket A pulled up the cashier consumption ticket after the ticket is invalid A new ticket B is generated on the second replay.

Scenario B: The first time you generate ticket A, if you don't transfer the ticket at the checkout counter, then the ticket will still be generated within 24 hours and the new ticket will be generated after 24 hours.

Currently, only those who enter after successful order payment will sync the order to the order center.

Http request method: POST
https://api.weixin.qq.com/shop/order/add?access_Token = xxxxxxxxx

# Example of a request parameter(General Payment Scenario)

{
    "create_time": "2020-03-25 13:05:25",
    "out_order_id": 'xxxxx';                  // Required, external order ID under normal scenarioThe main external order ID in the case of single payment (multiple orders paid together once)
    "openid": "oTVP50O53a7jgmawAmxKukNlq3XI",
    "path": "/pages/order.html?out_order_id=xxxxx",     // Here is the best path to have a parameter value that can match out_order_The value of id matches
    "scene": 1177,                          // The scene value of the Mini Program at the time of ordering can be obtained through the[getLaunchOptionsSync](https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html)or[onLaunch/onShow](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onLaunch-Object-object)Get it
    "out_user_id": "323232323",
    "order_detail " :
    {
        "product_Infos ":
        [
            {
                "out_product_id": "12345",
                "out_sku_id":"23456",
                "product_cnt": 10,
                "sale_price": 100,   //The selling price of the item at the time of generating this order can not match the price of uploading the item interface.
                "real_price": 100,  // The apportioned price of a single sku (unit: points) after deducting the discount, if there is no discount, the price will be charged to the sale_Price consistency
                "path": "pages/productDetail/productDetail?productId=2176180",
                "title" : "Detergent,"
                "head_img": " http://img10.360buyimg.com/n1/s450x450_jfs/t1/85865/39/13611/488083/5e590a40E4bdf69c0/55c9bf645ea2b727.jpg",
            },
            ...
        ],
        "pay_info": {
            "pay_method_type": 0,       // 0: WeChat Pay, 1: Cash on delivery, 2: Merchant membership card (default 0)
            "prepay_id": "42526234625", // pay_method_type = Required at 0
            "prepay_time": "2020-03-25 14:04:25"
        },
        "price_info": {         // Note that the unit price in the price field is cents, not dollars
            "order_price": 1600,
            "freight": 500,
            "discounted_price": 100,
            "additional_price": 200,
            "additional_remarks": "Taxes and fees"
        }
    },
    "delivery_detail " : {
        "delivery_type": 1,     // 1: Normal express delivery, 2: There is no need for express delivery, 3: Offline distribution, 4: User Input
    },
    "address_info": {
        "receiver_name": "Zhang San,"
        "detailed_address": "Detailed shipping address information,"
        "tel_number": "Phone number of consignee,"
        "country": "Country, Optional,"
        "province": "Provinces, optional,"
        "city": "City, Optional,"
        "town": "Township, Optional"
    }
}

# Return Package Example

{
    "errcode": 0,
    "errmsg":"ok",
    "data":
    {
        "order_id":32434234,
        "out_order_id": 'xxxxx';
        "ticket": 'xxxxxxx';
        "ticket_expire_time": "2020-12-01 00:00:00",
        "final_price": 10500        //final_price=product_price+freight-discounted_price+additional_price
    }
}

# Request Parameter Dxplaination

parameter type Required Required Introductions
create_time string yes Creation time, yyyy-MM-dd HH: mm: SS
out_order_id string yes Merchant Custom Order ID
openid string yes User's openid
path string yes The page path of the order, for the micro-channel side order center jump
scene number yes The scene value of the Mini Program when placing an order, can be passed throughgetLaunchOptionsSyncoronLaunch/onShowGet it
order_detail.product_infos[].out_product_id string yes Custom Product ID
order_detail.product_infos[].out_sku_id string yes Merchant custom product skuID, fill-in string if the product_No sku under id.
order_detail.product_infos[].product_cnt number yes Number of purchases
order_detail.product_infos[].sale_price number yes The selling price (unit: points) of the item at the time of order creation, can not match the price of the uploaded item interface
order_detail.product_infos[].real_price number yes Average price per unit sku (unit: cents) after deduction of discount, if no discount, with sale_Price consistency
order_detail.product_infos[].head_img string yes Header Map of Goods at Order Generation
order_detail.product_infos[].title string yes Title of the item when the order is generated
order_detail.product_infos[].path string yes Bound Mini Program product path
order_detail.pay_info.pay_method_type number yes Payment, 0, WeChat Pay, 1: Cash on delivery, 2: merchant membership card (default 0)
order_detail.pay_info.prepay_id string no Pre-payment ID, payment method is "WeChat Pay" required
order_detail.pay_info.prepay_time string no Prepayment Time (get prepay)_Id time), Payment method is required for "WeChat Pay," yyyy-MM-dd HH: mm: SS
order_detail.price_info.order_price number yes The final amount of the order paid (in cents)_price = Total price of goods + freight + additional_price - discounted_price
order_detail.price_info.freight number yes Freight (in cents)
order_detail.price_info.discounted_price number no Preferential amount (unit: points)
order_detail.price_info.additional_price number no Additional amount (in cents)
order_detail.price_info.additional_remarks string no Additional Amount Remarks
delivery_detail.delivery_type number yes 1: Normal express delivery, 2: There is no need for express delivery, 3: Offline distribution, 4: User Input (Default 1)
address_info object no Address information, delivery_type = 2 No setting is required, delivery_type = 4 Fill in the address of the store
address_info.receiver_name string yes Name of recipient
address_info.detailed_address string yes Detailed shipping address information
address_info.Tel_number string yes Recipient's mobile phone number
address_info.country string no country
address_info.province string no province
address_info.city string no city
address_info.town string no Township
order_detail.shop_id string no Store ID
order_detail.dg_id string no Guide ID
order_detail.remark_info.buyer_message string no Buyer Message
order_detail.remark_info.trade_memo string no Seller Notes
order_detail.buyer_info.delivery_name string no Buyer InformationName of consignee
order_detail.buyer_info.delivery_mobile string no Buyer InformationMobile phone number
order_detail.buyer_info.delivery_address string no Buyer InformationDelivery Address(street)
order_detail.buyer_info.province string no Buyer Informationprovince
order_detail.buyer_info.city string no Buyer Informationcity
order_detail.buyer_info.area string no Buyer Informationarea
order_detail.buyer_info.zip_code string no Buyer InformationPostcode
order_detail.buyer_info.lastedchange_time string no Buyer InformationLast updated time
order_detail.price_detail.total_amount number no Original price
order_detail.price_detail.benefit_type number no Preferential way 0 nothing 1 Amount of relief 2 discounts
order_detail.price_detail.discount_type string no Type of offer vipcouponintegral
order_detail.price_detail.benefit_name string no Coupon Name
order_detail.price_detail.benefit_info string no Coupon Description
order_detail.price_detail.benefit_condition number no Eligible amount
order_detail.price_detail.benefit_value number no Full reduction
order_detail.price_detail.benefit_discount number no Actual amount of relief
order_detail.price_detail.coupon_id number no Coupon id
order_detail.service_orders[].out_product_id string no Service Suborder ListMerchant Custom Product ID (Order Line Product)
order_detail.service_orders[].sub_order_price number no Service Suborder ListTotal Suborder Price
order_detail.service_orders[].sub_order_amount number no Service Suborder ListNumber of Suborders
order_detail.service_orders[].sub_order_id string no Service Suborder List Suborder id

# Return parameter specification

parameter type Introductions
Errcode number Error code
errmsg string Error message
data.order_id number(uint64) Trading Component Platform Order ID
data.out_order_id string Trading Component Platform Order ID
data.ticket string Pull up the ticket at the checkout
data.ticket_expire_time string Valid Ticket Deadline
data.final_price number Final Order Price (Unit: Cents)

# Enumerate - status

Enumeration value describe
10 Outstanding
11 Checkout payment completed (automatic flow, the same treatment as 10 for merchants)
20 Pending shipment (paid for)/Balance paid by user)
30 Pending receipt
100 complete
200 After the sale of all goods, the order is cancelled
250 User active cancellation/Outstanding Time Out Cancellation/Business cancellation