0

I have the following error in my backend php code for a paypal transaction:

<br />
<b>Parse error</b>: syntax error, unexpected '[' in <b>E:\web\chartmyg\TESTPAYPAL\backend.php</b> on line <b>95</b><br />

This is the particular section of the code ($data = [ is the line it complains about):

$json = file_get_contents('php://input');
$input = json_decode($json, false);
$price = $input->cost;
$description = $input->description;

$this->generateAccessToken();

// THIS NEXT LINE IS THE ERROR
$data = [
    "intent" => "CAPTURE",
    "purchase_units" => [[
        "description" => $description,
        "amount" => [
            "currency_code" => "GBP",
            "value" => $price,
        ],
    ]]
];
$json = json_encode($data);

$curl = curl_init();

Could the be an access issue with Paypal?

When I load the page before clicking the Paypal button it gives me an error:

Failed to load resource: net::ERR_NAME_NOT_RESOLVED

This is the problem here:

<script data-namespace="paypalbutton4" src="https://www.paypal.com/sdk/js?debug=true&intent=capture&currency=GBP&client-id=AeXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXX"></script>
Rewind
  • 2,554
  • 3
  • 30
  • 56
  • That is not paypal problem. One of the variables contains invalid characters. – Markus Zeller Jul 23 '23 at 18:37
  • `Could the be an access issue with Paypal?`...of course not. Its a syntax error, your code is not even executing. – ADyson Jul 23 '23 at 21:41
  • I think the person who said the question has been answered is correct. I have to define my array old-style; `$data = array(...)`. However, the `ERR_NAME_NOT_RESOLVED` is still occuring at page load. – Rewind Jul 23 '23 at 22:20
  • That error means your browser was not able to resolve the host name of the resource you are trying to load there. Either you got some extension blocking this, or something went wrong with the DNS resolve, in the latter case check https://www.hostinger.com/tutorials/err_name_not_resolved for options how to solve. – CBroe Jul 24 '23 at 06:50

0 Answers0