Hi all,
I am trying to find out why this is happen to me.
I am using webhook dispute.created and dispute.state.updated
so I run a payment the call out “dispute.created” webhook.
when it is call it auto send auto “accept” using curl with php.
the trouble I get is the “dispute.state.updated” gets call two times
the first time tell me it was ACCEPTED. then the next one tells me that it need EVIDENCE_REQUIRED.
each webhook is on it only web page
here is the code
if($decode[‘type’] == ‘dispute.created’){
$disputeID = $decode[‘data’][‘id’];
$amount = $decode[‘data’][‘object’][‘dispute’][‘amount_money’][‘amount’];
$paymentID = $decode[‘data’][‘object’][‘dispute’][‘disputed_payment’][‘payment_id’];
$status = $decode[‘data’][‘object’][‘dispute’][‘state’];
$reason = $decode[‘data’][‘object’][‘dispute’][‘reason’];
$data = json_encode($decode[‘data’]);
$sql1 = “INSERT INTO squaredispute (disputeID, amount, paymentID, stuts, reason, dataraw, date)
VALUES (’$disputeID’, ‘$amount’, ‘$paymentID’, ‘$status’, ‘$reason’, ‘$data’, ‘$d’)”;
$last_id = sql($sql1, “last_id”, 0);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://connect.squareupsandbox.com/v2/disputes/$disputeID/accept” );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_HTTPHEADER, array(“Square-Version: 2021-06-16”, “Authorization: Bearer EAAAEPjpOMsuF1GwrGPUfn7rxvJKbuVpMngD4CWuCW4QGp8Mci9ST4x5eP1UMjMC”, “Content-Type: application/json”));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
echo curl_exec($ch);
curl_close($ch);
}
the payload from created is
{
"merchant_id": "MLMJ2HJ1AXYRS",
"location_id": "LTJ5W7X266TXZ",
"type": "dispute.created",
"event_id": "37df2db5-dddf-4685-a027-f9edf593563b",
"created_at": "2021-07-16T00:00:24.867Z",
"data": {
"type": "dispute",
"id": "59cM46wXoAjDT1thRBWhOD",
"object": {
"dispute": {
"amount_money": {
"amount": 8802,
"currency": "USD"
},
"brand_dispute_id": "2hqBDNFlTDWYybapjJOQhA",
"card_brand": "VISA",
"created_at": "2021-07-16T00:00:24.867Z",
"disputed_payment": {
"payment_id": "zZcMVrLKqvEMhm8sJ8YkxJuKh0ZZY"
},
"due_at": "2021-07-30T00:00:00.000Z",
"id": "59cM46wXoAjDT1thRBWhOD",
"location_id": "LTJ5W7X266TXZ",
"reason": "CANCELLED",
"reported_at": "2021-07-16T00:00:00.000Z",
"state": "EVIDENCE_REQUIRED",
"updated_at": "2021-07-16T00:00:24.867Z"
}
}
}
}
the payload from the update
{
"merchant_id": "MLMJ2HJ1AXYRS",
"location_id": "LTJ5W7X266TXZ",
"type": "dispute.state.updated",
"event_id": "4c534bd6-5db4-4ebd-bc08-3929d949bbaa",
"created_at": "2021-07-16T00:00:25.659Z",
"data": {
"type": "dispute",
"id": "59cM46wXoAjDT1thRBWhOD",
"object": {
"dispute": {
"amount_money": {
"amount": 8802,
"currency": "USD"
},
"brand_dispute_id": "2hqBDNFlTDWYybapjJOQhA",
"card_brand": "VISA",
"created_at": "2021-07-16T00:00:24.867Z",
"disputed_payment": {
"payment_id": "zZcMVrLKqvEMhm8sJ8YkxJuKh0ZZY"
},
"due_at": "2021-07-30T00:00:00.000Z",
"id": "59cM46wXoAjDT1thRBWhOD",
"location_id": "LTJ5W7X266TXZ",
"reason": "CANCELLED",
"reported_at": "2021-07-16T00:00:00.000Z",
"state": "ACCEPTED",
"updated_at": "2021-07-16T00:00:25.659Z",
"version": 2
}
}
}
}
the next one
{
"merchant_id": "MLMJ2HJ1AXYRS",
"location_id": "LTJ5W7X266TXZ",
"type": "dispute.state.updated",
"event_id": "53499d86-275f-4d71-be8a-4414cb4be5ce",
"created_at": "2021-07-16T00:00:40.109Z",
"data": {
"type": "dispute",
"id": "59cM46wXoAjDT1thRBWhOD",
"object": {
"dispute": {
"amount_money": {
"amount": 8802,
"currency": "USD"
},
"brand_dispute_id": "vH66D3icTAaK8FpPRY9MCQ",
"card_brand": "VISA",
"created_at": "2021-07-16T00:00:24.867Z",
"disputed_payment": {
"payment_id": "zZcMVrLKqvEMhm8sJ8YkxJuKh0ZZY"
},
"due_at": "2021-07-30T00:00:00.000Z",
"id": "59cM46wXoAjDT1thRBWhOD",
"location_id": "LTJ5W7X266TXZ",
"reason": "CANCELLED",
"reported_at": "2021-07-16T00:00:00.000Z",
"state": "EVIDENCE_REQUIRED",
"updated_at": "2021-07-16T00:00:40.109Z",
"version": 3
}
}
}
}
my Application ID
sandbox-sq0idb-u6O-mkhDoe0kGetuT9iruA
Thank you for your help