I am implementing Card Payments in php and javascript, it really works now, I receive a response in the sandbox log correctly, and the payment made with the card is presented correctly, but in my javascript screen on the client side it says Payment Failed, and in the browser console I get
Unexpected token ‘<’, "
<div style"... is not valid JSONCan someone enlighten me what I’m doing wrong?
I already have 3 days without sleeping all due to the loss of the old sqpayments -.-
i think i am not getting a json on the javascript side in the await fetch ? this is the end of my php code
try {
$apiResponse = $client->getPaymentsApi()->createPayment($body);
if ($apiResponse->isSuccess()) {
return json_encode($ApiResponse->getResult());
// Your business logic here
} else {
return json_encode(array('errors' => $ApiResponse->getErrors()));
// Your error-handling code here
}
} catch (ApiException $e) {
echo json_encode(array('errors' => $e));
}
Am I returning correctly?
new code view the difference
try {
$apiResponse = $client->getPaymentsApi()->createPayment($body);
if ($apiResponse->isSuccess()) {
return json_encode($apiResponse->getResult());
// Your business logic here
} else {
return json_encode(array('errors' => $apiResponse->getErrors()));
// Your error-handling code here
}
} catch (ApiException $e) {
echo json_encode(array('errors' => $e));
}