I'm having an issue in the sandbox with our work flow creating an additional customer record after using the ecommerce v1/order/<order id>/pay endpoint AND then swapping all items to the new customer record (yes i know this sounds odd).
We are using the following flow:
1. I'm creating a token with the token endpiont and the following object "v1/tokens", returning a source token to assign to a customer and use for payment later.
- brand (i.e DISCOVER)
- number
- cvv
- exp_month
- exp_year
2. I'm creating a customer record with the ecommerce endpoint "V1/customers"
- ecomind = "ecom",
- firstName
- lastName
- name = firstName + lastName,
- source (from step 1)
- phone
this is what the customer record looks like
{
"href": "https://sandbox.dev.clover.com/v3/merchants/9QPTP66T7X9BE/customers/ATKQP7YRZCP86",
"id": "ATKQP7YRZCP86", <-- customer id
"firstName": "Harrison,",
"lastName": "Chris",
"marketingAllowed": false,
"customerSince": 1607195931000,
"cards": {
"elements": [
{
"id": "BHGPQP7Q006NP",
"first6": "601136",
"last4": "6668",
"cardType": "DISCOVER",
"token": "clv_1TSTSzjCMwRejX2zS2915z8v", < --- token I'm using
"tokenType": "CTOKEN",
"modifiedTime": 1607195931000,
"customer": {
"id": "ATKQP7YRZCP86"
}
.....
3. I'm creating the order with the ecommerce endpoint with the following object "v1/orders"
- items[]
- currency = "usd",
- customer = customer id (from step 2)
- email
this is what the response order object looks like
{
"id": "SG9PKV9CYKNBE",
"object": "order",
"amount": 425,
"currency": "USD",
"customer": "ATKQP7YRZCP86", <---- customer id from step 2
"items": [
{
"quantity": 1,
"amount": 100,
"description": "BarGuard Application Hold"
},
{
"parent": "0DCE3GPZT46E4",
"amount": 5,
"description": "Pizza",
"tax_rates": [
{
"name": "Ohio 6.5 % Sales Tax",
"rate": 650000
}
]
},
.....
4. At this point the merchant adds the line items (our app is not handling line item additions)
5. I've trying paying with both customer and source token "/v1/orders/<order id from step 3>/pay" and the following object:
- ecomind": "ecom",
- source: <source from step 1>
- tip_amount
AND
- ecomind: "ecom",
- customer: <customer id from step 2>,
- tip_amount
Paying this way i end up with an additonional customer object like below (../v3/merchants/{ {merchant_id}}/customers?expand=cards):
{
"elements": [
{
"href": "https://sandbox.dev.clover.com/v3/merchants/9QPTP66T7X9BE/customers/6K4CS0TRG75QW",
"id": "6K4CS0TRG75QW", <-- New customer created
"marketingAllowed": false,
"customerSince": 1607197044000,
"cards": {
"elements": [
{
"id": "9ZPQDHPZ3RARP",
"token": "7297162975886668",
"tokenType": "MULTIPAY",
"modifiedTime": 1607197043000,
"customer": {
"id": "6K4CS0TRG75QW"
}
}
]
}
},
{
"href": "https://sandbox.dev.clover.com/v3/merchants/9QPTP66T7X9BE/customers/ATKQP7YRZCP86",
"id": "ATKQP7YRZCP86", < ----- Old customer never charged
"firstName": "Harrison,",
"lastName": "Chris",
"marketingAllowed": false,
"customerSince": 1607195931000,
"cards": {
"elements": [
{
"id": "BHGPQP7Q006NP",
"first6": "601136",
"last4": "6668",
"cardType": "DISCOVER",
"token": "clv_1TSTSzjCMwRejX2zS2915z8v",
"tokenType": "CTOKEN",
"modifiedTime": 1607195931000,
"customer": {
"id": "ATKQP7YRZCP86"
}
}
]
}
}
],
"href": "http://apisandbox.dev.clover.com/v3/merchants/9QPTP66T7X9BE/customers?limit=100"
}