如何通过接口获取订单的发票信息

说明:

开发者对接订单接口,需要获取到买家下单时填写的发票信息,以便进行相应的业务处理,本文档将介绍说明有赞云开放接口 - 订单 API- 如何获取订单的发票信息

步骤:

店铺后台设置:

STEP1: 登陆商家的店铺后台–设置–订单设置–交易设置

image.png

STEP2: 买家下单时,填写需要开具的发票信息
image.png
image.png

接口获取:

接口名称:交易订单详情 4.0 接口
接口 API:youzan.trade.get.4.0.0
接口文档链接:https://doc.youzanyun.com/doc#/content/API/1-305/detail/api/0/120

JAVA 请求示例:

public class TradeTest {
    @Test
    public void test() throws ParseException {
        Token token = new Token("99f67e1c41ae9186c713fe0a97b1e76");
        DefaultYZClient yzClient = new DefaultYZClient();

        YouzanTradeGet youzanTradeGet = new YouzanTradeGet();
        //创建参数对象,并设置参数
        YouzanTradeGetParams youzanTradeGetParams = new YouzanTradeGetParams();
        String tid = new String("E20190921153115076000025");
        youzanTradeGetParams.setTid("E20190921153115076000025");
        youzanTradeGet.setAPIParams(youzanTradeGetParams);
        try {
            YouzanTradeGetResult result = yzClient.invoke(youzanTradeGet, token, YouzanTradeGetResult.class);
            System.out.println(JSON.toJSON(result));
        } catch (SDKException n) {
            n.printStackTrace();
        }

返回参数:

{"code":200,"data":{"delivery_order":[],"order_promotion":{"item":[],"adjust_fee":"0.00","order":[]},"refund_order":[],"full_order_info":{"child_info":{"child_orders":[]},"address_info":{"self_fetch_info":"","delivery_address":"哦啦啦啦啦","delivery_postal_code":"","delivery_province":"北京市","receiver_name":"妮子","delivery_city":"北京市","address_extra":"{\"areaCode\":\"110101\",\"lon\":116.38046810722916,\"lat\":39.91331018566404}","delivery_district":"东城区","receiver_tel":"18250677866"},"remark_info":{"buyer_message":""},"pay_info":{"outer_transactions":["191212101213000001"],"post_fee":"0.00","phase_payments":[],"total_fee":"0.01","payment":"0.01","transaction":["191212101212001110"]},"buyer_info":{"outer_user_id":"oHIuujmad4xCZ4Gk2KiIuqs8a5Sg","buyer_phone":"18250657666","fans_type":9,"buyer_id":679447102,"fans_id":1687397830,"fans_nickname":"Winnie"},"orders":[{"is_cross_border":"","outer_item_id":"","discount_price":"0.01","item_type":0,"num":1,"oid":"2708734725261099180","title":"妮子-普通商品-新疆阿克苏苹果","fenxiao_payment":"0.00","buyer_messages":"","cross_border_trade_mode":"","is_present":false,"order_item_extra":"[]","price":"0.01","sub_order_no":"","fenxiao_price":"0.00","total_fee":"0.01","alias":"35wsnx9xedv9s","payment":"0.01","is_pre_sale":"","outer_sku_id":"","sku_unique_code":"","goods_url":"https://h5.youzan.com/v2/showcase/goods?alias=35wsnx9xedv9s","customs_code":"","item_id":528982930,"pic_path":"https://img.yzcdn.cn/upload_files/2019/12/05/FrfyzfhcaACOYEDKw4zifj_73w5B.png","sku_id":0,"sku_properties_name":"[]","pre_sale_type":"","points_price":"0"}],"source_info":{"is_offline_order":false,"book_key":"1c0ed7b4-d732-4d24-88cb-b0c8a26e4b59","biz_source":"","source":{"platform":"wx","wx_entrance":"direct_buy"}},"order_info":{"order_extra":{"buyer_name":"Winnie","is_from_cart":"false","is_member":"true","is_points_order":"0"},"created":1576116732000,"expired_time":1576117932000,"status_str":"待发货","type":0,"tid":"E20191212101212057400005","pay_time":1576116733000,"is_retail_order":false,"pay_type_str":"PREPAIDCARD","update_time":1576116733000,"activity_type":1,"pay_type":35,"team_type":0,"refund_state":0,"close_type":0,"express_type":0,"order_tags":{"is_member":true,"is_payed":true,"is_secured_transactions":true},"status":"WAIT_SELLER_SEND_GOODS"}}},"success":true,"message":"successful"}

发票信息返回参数:

"invoice_info": {
                "user_name": "杭州市起码运动有限责任公司",
                "taxpayer_id": "asg778902222",
                "raise_type": "enterprise",
                "invoice_detail_type": "itemDetail",
                "email": "147459208786@qq.com"
            },