-
Notifications
You must be signed in to change notification settings - Fork 0
Clientes
zodiacfireworks edited this page Mar 7, 2021
·
1 revision
Consulta la documentación de Culqi en https://apidocs.culqi.com/#/clientes
def get_customer_data():
customer_data = deepcopy(Data.CUSTOMER)
customer_data["email"] = "richard{0}@piedpiper.com".format(uuid4().hex[:4])
return customer_datacustomer_list = culqi.customer.list(
data={
"limit": 1,
},
headers={
"Accept-Encoding": "identity",
},
)
display(customer_list){
"status": 200,
"data": {
"paging": {
"previous": "https://api.culqi.com/v2/customers?limit=1&before=cus_test_f4l7UKPuYrORPvyP",
"next": "https://api.culqi.com/v2/customers?limit=1&after=cus_test_f4l7UKPuYrORPvyP",
"cursors": {
"before": "cus_test_f4l7UKPuYrORPvyP",
"after": "cus_test_f4l7UKPuYrORPvyP"
},
"remaining_items": null
},
"items": [
{
"object": "customer",
"id": "cus_test_f4l7UKPuYrORPvyP",
"creation_date": 1615131609000,
"email": "richard50be@piedpiper.com",
"antifraud_details": {
"first_name": "Richard",
"last_name": "Piedpiper",
"address": "Avenida Lima 123213",
"address_city": "LIMA",
"country_code": "PE",
"phone": "+51998989789",
"object": "client"
},
"cards": [
{
"object": "card",
"id": "crd_test_yAPm5rwlF3aTGVHa",
"active": true,
"creation_date": 1615131614000,
"customer_id": "cus_test_f4l7UKPuYrORPvyP",
"source": {
"object": "token",
"id": "tkn_test_mw7AQicjlOII6Y5u",
"type": "card",
"creation_date": 1615131608000,
"email": "richard50be@piedpiper.com",
"card_number": "511111******1118",
"last_four": "1118",
"active": true,
"iin": {
"object": "iin",
"bin": "511111",
"card_brand": "MasterCard",
"card_type": "debito",
"card_category": "Clásica",
"issuer": {
"name": "INTERBANK",
"country": "PERU",
"country_code": "PE",
"website": null,
"phone_number": null
},
"installments_allowed": [
24,
2,
3,
4,
5,
6,
7,
8,
9,
12,
48
]
},
"client": {
"ip": "191.98.182.73",
"ip_country": "Peru",
"ip_country_code": "PE",
"browser": "UNKNOWN",
"device_fingerprint": null,
"device_type": "Escritorio"
},
"metadata": {}
},
"metadata": {}
}
],
"metadata": {}
}
]
}
}
customer_data = get_customer_data()
customer = culqi.customer.create(data=customer_data)
display(customer){
"status": 201,
"data": {
"object": "customer",
"id": "cus_test_xHxfvWLS9lInzdqE",
"creation_date": 1615131616908,
"email": "richard8f52@piedpiper.com",
"antifraud_details": {
"first_name": "Richard",
"last_name": "Piedpiper",
"address": "Avenida Lima 123213",
"address_city": "LIMA",
"country_code": "PE",
"phone": "+51998989789",
"object": "client"
},
"metadata": {}
}
}
customer_id = customer["data"]["id"]
customer = culqi.customer.read(id_=customer_id)
display(customer){
"status": 200,
"data": {
"object": "customer",
"id": "cus_test_xHxfvWLS9lInzdqE",
"creation_date": 1615131616000,
"email": "richard8f52@piedpiper.com",
"antifraud_details": {
"first_name": "Richard",
"last_name": "Piedpiper",
"address": "Avenida Lima 123213",
"address_city": "LIMA",
"country_code": "PE",
"phone": "+51998989789",
"object": "client"
},
"cards": [],
"metadata": {}
}
}
customer_id = customer["data"]["id"]
customer_metadata = {
"metadata": {
"orderId": 1234567890
}
}
customer = culqi.customer.update(
id_=customer_id, data=customer_metadata
)
display(customer){
"status": 200,
"data": {
"object": "customer",
"id": "cus_test_xHxfvWLS9lInzdqE",
"creation_date": 1615131616000,
"email": "richard8f52@piedpiper.com",
"antifraud_details": {
"first_name": "Richard",
"last_name": "Piedpiper",
"address": "Avenida Lima 123213",
"address_city": "LIMA",
"country_code": "PE",
"phone": "+51998989789",
"object": "client"
},
"metadata": {
"orderId": "1234567890"
}
}
}
customer_id = customer["data"]["id"]
deleted_customer = culqi.customer.delete(id_=customer_id)
display(deleted_customer){
"status": 200,
"data": {
"id": "cus_test_xHxfvWLS9lInzdqE",
"deleted": true,
"merchant_message": "Se eliminó el cliente con ID cus_test_xHxfvWLS9lInzdqE exitosamente."
}
}
SoftButterfly Development Team