Dear All,
I’m getting following error no matter i have set the correct values. I was trying almost 4 days by now and still no result.
{ “errors”: [ { “category”: “AUTHENTICATION_ERROR”, “code”: “UNAUTHORIZED”, “detail”: “This request could not be authorized.” } ] }
My function is a follows and i’m 100% sure about the credintials as same request working from Postman Json post.
Since this is a Laravel Program. I’m testing in my localhost:8000. is that the issue ?
public function get_squre_checkout_url($data){
$headers['Square-Version'] = '2024-01-18';
$headers['Authorization'] = $data['auth'];
$headers['Content-Type'] = 'application/json';
$my_data = [
"idempotency_key" => $data['idempotency_key'],
"quick_pay" => [
"name" => $data['name'],
"price_money" => [
"amount" => $data['amount'],
"currency" => $data['currency']
],
"location_id" => $data['location_id']
],
"checkout_options" => [
"allow_tipping" => false,
"ask_for_shipping_address" => false,
"enable_coupon" => false,
"enable_loyalty" => false,
"merchant_support_email" => $data['merchant_support_email'],
"redirect_url" => $data['redirect_url'],
"accepted_payment_methods" => [
"afterpay_clearpay" => true,
"apple_pay" => true,
"cash_app_pay" => false,
"google_pay" => true
]
],
"description" => $data['description']
];
$my_request = http_build_query($my_data);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://connect.squareupsandbox.com/v2/online-checkout/payment-links');
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $my_request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
curl_close($curl);
return $result;
}
Please help me to get this sorted. i’m very new to Square Development and this is my 5th day with square yet.
looking forward to hearing from you.