Квадратные заказы, созданные в api, не отображаются на панели инструментов в реальном времени - PullRequest
0 голосов
/ 03 августа 2020

Я использовал руководство #square для создания порядка в квадратном API, но порядок отображается только на бэкэнде с помощью вызова search_orders, но не на живой панели инструментов. Вот что я сделал

##Step 1 create order
order={}
order['location_id']=location_id
#not sure how best to have this
order['reference_id']= "011"
line_items=[]

quantity="1"
measurement_unit={}
measurement_unit['generic_unit']="UNIT"
quantity_unit={}
quantity_unit['measurement_unit']=measurement_unit
quantity_unit['precision']=1
note="TEST ORDER BY PETER"
base_price_money={}
# base_price_money['amount']= catalogue_price
base_price_money['amount']= 0
base_price_money['currency']=catalogue_currency

line_item={}
line_item['catalog_object_id']=catalogue_id
# line_item['name']= catalogue_name
line_item['quantity']= quantity
# line_item['quantity_unit']=quantity_unit
line_item['note']=note
line_item['base_price_money']=base_price_money

line_items.append(line_item)

order['line_items']=line_items

fulfillment={}
pickup_details={}
pickup_details['note']='TEST Order forwarded from Feedr'
pickup_details['pickup_at']=datetime.datetime.now(datetime.timezone.utc).isoformat()
recipient={}
address={}
address['address_line_1']=""
address['administrative_district_level_1']=""
address['first_name']="PETER"
address['first_name']="TEST"
recipient['address']=address
recipient['display_name']= "Peter Test  Forward"
recipient['schedule_type']= "SCHEDULED"
pickup_details['recipient']=recipient
fulfillment["pickup_details"]=pickup_details
fulfillment["state"]="PROPOSED"
fulfillment["type"]= "PICKUP"
fulfillment["uid"]= "6"

order['fulfillments']=[fulfillment]

body={}
body['order']=order
body['idempotency_key']=str(uuid.uuid1())


result = client.orders.create_order(location_id=location_id, body=body)


if result.is_success():
  print('done')
elif result.is_error():
  print(result.errors)

# Шаг 2 оплатить созданный заказ с нуля, так как заказ оплачен из другой системы

result = client.orders.pay_order(
  order_id = result.body.get("order").get("id"),
  body = {
    "idempotency_key": body['idempotency_key'],
    "payment_ids": []
  }
)
if result.is_success():

  print('done')
elif result.is_error():
  print(result.errors)
Когда я ищу заказы с помощью вызова ниже, я вижу созданные мной заказы, но их нет на панели управления
orders_api = client.orders

body = {}
body['location_ids']=locations
body['return_entries']= False
result = orders_api.search_orders(body)

Не уверен, что отсутствует

...