今日头条小程序 ,订单同步问题
391 浏览2023年08月08日作者:mario5203

响应:{'err_code': 40012, 'err_msg': 'open_id错误, 请确认是否是在抖音/抖音lite/火山 app内生成', 'body': ''}


    def push_out_order(self, order: Order, appid):
        url = "https://developer.toutiao.com/api/apps/order/v2/push"

        order_detail = {
            "order_id": order.out_order_no,
            "create_time": int(order.created_at.timestamp() * 1000),
            "status": "待支付" if order.status == 0 else "已支付",
            "amount": 1,
            "total_price": order.total_amount,
            "detail_url": "",
            "item_list": [
                {
                    "item_code": "lock",
                    "img": "",
                    "title": "查看结果",
                    "sub_title": "",
                    "amount": 1,
                    "price": order.total_amount
                }
            ]
        }

        payload = json.dumps({
            "access_token": self.get_access_token(platform.build_env_info(appid)),
            "app_name": "douyin",
            "open_id": order.user_id,
            "order_type": 0,
            "update_time": int(order.updated_at.timestamp() * 1000),
            "order_detail": json.dumps(order_detail, ensure_ascii=False)
        })
        headers = {
            'Content-Type': 'application/json'
        }

        response = requests.request("POST", url, headers=headers, data=payload)
        logging.info(f'order:{order},openid:{appid},response:{response.json()}')
        return response.json()

请问是哪里有问题

最后一次编辑于 2023 年 08 月 08 日
3 条评论

相关问答

专题推荐

热门文章

热门问答