Blank Page with "Something Went Wrong" Error When Accessing Square Checkout Link - Sandbox

I am using Square’s API to create a checkout link. The API request succeeds, and I receive a valid response, including the checkout URL. However, when I attempt to open the generated URL, I see a blank page with the error message: “Something went wrong”.


Code Snippet:

Below is the CreateCheckout function used to create the checkout link:

func CreateCheckout(amount int64, buyerEmail string) (*CreateCheckoutResponse, error) {
	idempotencyKey := uuid.NewString()

	var redirectURL string
	if config.Env.Environment == "development" {
		redirectURL = "http://localhost:4321/"
	} else {
		redirectURL = "{PROD_URL}"
	}

	reqBody := createCheckoutRequest{
		CheckoutOptions: checkoutOptions{
			AllowTipping:          false,
			AskForShippingAddress: false,
			EnableCoupon:          false,
			EnableLoyalty:         false,
			MerchantSupportEmail:  "support@{DOMAIN}",
			RedirectURL:           redirectURL,
		},
		IdempotencyKey: idempotencyKey,
		QuickPay: quickPay{
			LocationID: "{LOCATION_ID}",
			Name:       "Deposit",
			PriceMoney: priceMoney{
				Amount:   amount,
				Currency: "USD",
			},
		},
		PrePopulatedData: prePopulatedData{
			BuyerEmail: buyerEmail,
		},
	}

	data, err := json.Marshal(reqBody)
	if err != nil {
		return nil, fmt.Errorf("failed to marshal request body: %w", err)
	}

	var url string
	if config.Env.Environment == "development" {
		url = "https://connect.squareupsandbox.com/v2/online-checkout/payment-links"
	} else {
		url = "https://connect.squareup.com/v2/online-checkout/payment-links"
	}

	req, err := http.NewRequestWithContext(context.TODO(), http.MethodPost, url, bytes.NewBuffer(data))
	if err != nil {
		return nil, fmt.Errorf("failed to create request: %w", err)
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Square-Version", "2024-11-20")
	req.Header.Set("Authorization", "Bearer "+config.Env.SquareAccessToken)

	client := &http.Client{Timeout: 10 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		return nil, fmt.Errorf("request error: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode < 200 || resp.StatusCode > 299 {
		return nil, fmt.Errorf("received non-2xx response: %d", resp.StatusCode)
	}

	var result CreateCheckoutResponse
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		return nil, fmt.Errorf("failed to decode response: %w", err)
	}

	return &result, nil
}

Error Page Screenshot:


Issue Details:

  1. The API request to create the checkout link returns a successful response with a 200 OK status code.
  2. The returned URL appears valid.
  3. When I visit the URL in a browser, I receive a “Something went wrong” error and the page remains blank.

I cannot continue development until this is solved, any help is appreciated thank you!

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Checkout API
Build a Payment Integration and Take Payments Online
Quick Pay Checkout

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

What’s the payment link that’s throwing this error? :slightly_smiling_face:

Hey Bryan,

Thanks for the quick response. I’ve created many, but here’s a recent one I generated. They all give me the same issue.

https://sandbox.square.link/u/5qMxxLXC

Thanks!

To add; when creating it with production credentials the link works as expected.

I also do not have access to the sandbox-testing-panel. Does this feature not exist anymore?

Have found any solution for this yet?

Unfortunately no solution yet. Hoping @Bryan-Square (or any one else) can help me out :slight_smile:

The team is currently working on a fix. :slightly_smiling_face:

This has been fixed now. :slightly_smiling_face:

Amazing, can confirm it is working. Thank you!