I tried plenty of ways to resolve my issue nothing worked.
at last, I figured out that I am supposed to use the merchant access_token stored while connecting the account, and the location id is supposed to be the developer’s account used as a mediator in the applications side.
after changes this is how my code looks,
$client = new SquareClient([
'accessToken' => $merchant_square_access, //Merchants access token
'environment' => Environment::SANDBOX,
]);
$order = new \Square\Models\Order(env('LOCATION_ID')); //Developer's account location id
$price_money = new \Square\Models\Money();
$price_money->setAmount(15000);
$price_money->setCurrency('USD');
$quick_pay = new \Square\Models\QuickPay(
'Testing Quick Pay',
$price_money,
env('LOCATION_ID') //Developer's account location id
);
$body = new \Square\Models\CreatePaymentLinkRequest();
$body->setIdempotencyKey('bae2e9c0-479a-4fba-b835-9792e56f2cb0');
$body->setQuickPay($quick_pay);
$body->setSource('');
$api_response = $client->getCheckoutApi()->createPaymentLink($body);
if ($api_response->isSuccess()) {
$result = $api_response->getResult();
} else {
$errors = $api_response->getErrors();
}
Thanks for response, do check my code and please let me know If I’m following the correct way