Generate quick checkout link with metadata

How can i pass additional data like client_id,company_id data with my payment.update webhook after payment is completed so i can verify which user for which order has paid me

public function squareGateway($name = ‘something’, $amount = 69, $metaData = [‘companyId’ => 69])
{
try {
$price_money = new \Square\Models\Money();
$price_money->setAmount($amount * 100);
$price_money->setCurrency(‘USD’);

        // Create a new instance of SquareClient
        $client = new SquareClient([
            'accessToken' => 'ACCESS_TOKEN',
            'environment' => 'sandbox', // or SquareClient::ENVIRONMENT_PRODUCTION
        ]);

        $getLocation = $client->getLocationsApi()->listLocations();

        if ($getLocation->isSuccess()) {
            $location = $getLocation->getResult();
            # Your business logic here

            $quickPay = new \Square\Models\QuickPay(
                $name,
                $price_money,
                $location->getLocations()[0]->getId() ?? ""
            );

            $body = new \Square\Models\CreatePaymentLinkRequest();
            $body->setIdempotencyKey(uniqid('', true));
            $body->setQuickPay($quickPay);


            $generatePayment = $client->getCheckoutApi()->createPaymentLink($body);

            if ($generatePayment->isSuccess()) {

                $response = ['http_response_code' => 200, 'status' => 1, 'message' => "Session generated",
                    'redirect_url' => $generatePayment->getResult()->getPaymentLink()->getUrl()];

            } else {
                $response = ['http_response_code' => 500, 'status' => 0, 'message' => $generatePayment->getErrors()];
            }

        } else {
            $response = ['http_response_code' => 500, 'status' => 0, 'message' => $getLocation->getErrors()];
            # Your error-handling code here
        }

    } catch (ApiException $e) {
        $response = ['http_response_code' => 500, 'status' => 0, 'message' => $e->getMessage()];
    }

    var_dump($response);
    exit();

}

this is my function for generating payment link in php

Currently only note will be included with the payment.updated webhook event. If your collecting additional data from a payment link from the custom_fields you’ll need to call ListPaymentLinks and parse the response for a matching order_id.

Also the only value that isn’t safe to share is the access token. I removed it from your post however we recommend that to recycle the token. :slight_smile: