我在square中创建了一个客户,结果如下。我需要的是获得客户的身份证
我的代码:
from square.client import Client
client = Client(
access_token=settings.SQUARE_ACCESS_TOKEN,
environment=settings.SQUARE_ENVIRONMENT,
)
api_customers = client.customers
request_body = {'idempotency_key': idempotency_key, 'given_name': name, 'company_name': company,'phone_number':phone}
result = api_customers.create_customer(request_body)
这是输出:
<ApiResponse [{"customer":
{"id": "F8M9KDHWPMYGK2108RMQVQ6FHC",
"created_at": "2020-10-22T09:14:50.159Z",
"updated_at": "2020-10-22T09:14:50Z",
"given_name": "mkv5",
"phone_number": "900000066666",
"company_name": "codesvera",
"preferences": {"email_unsubscribed": false},
"creation_source": "THIRD_PARTY"}
}
]>
你在用这个图书馆吗? https://github.com/square/square-python-sdk/blob/master/square/http/api_response.py
如果是,结果是数组和APiResponse对象
所以首先你应该这样做:
result = result.body
然后获取ID:result['customer']['id']
Ps:您在github文档中有一个示例: https://github.com/square/square-python-sdk
相关问题 更多 >
编程相关推荐