Created a paymentlink via API for a subscription.
Got link.
Redirected user to the URL
Filled in / paid for it ($1 test subscription since sandbox sucks and can't test in sandbox)
Square Support has told me multiple times that I probably have invalid card data. It's the right card, it works, I even get the preauth approval notices from my bank.
If I do the subscription manually through the square dashboard, it works and goes through with the same exact card.
So user gets this message on the screen:

"Sorry. Your order didn't go through. Please try again".
Trying again doesn't work.
In Chrome developer tools, I can see this error appearing:
Failed to load resource: the <url here> server responded with a status of 422
Full URL:

Again - note that I am not calling that endpoint, I've redirected the user to the paymentlink URL, so this is all hosted/happening on Square's servers at this point.
Digging further into it, it appears to be getting this response from the subscribe endpoint. This is the CHECKOUT page calling this and generating this error, so I have no idea what I did wrong to get this to not work right....
{
"error": "Client error: `POST https:\/\/connect.squareup.com\/v2\/subscriptions` resulted in a `400 Bad Request` response:\n{\"errors\": [{\"code\": \"CONFLICTING_PARAMETERS\",\"detail\": \"Phases with RELATIVE pricing type must have phases on the subsc (truncated...)\n"
}
Can anyone explain what RELATIVE pricing type and phases on the subscription is? The subscription plan works fine when I manually create a subscription through the website, so what am I supposed to pass into the payment link API to create a checkout for the subscription?
Yes, I'm sure the itemvariationcatalogid variable is set properly.
price variable is 1 ($1 for a testing since we have to test this in production since the sandbox sucks and can't do this)
.NET Code:
// Create Order Lines
var lineItem = new OrderLineItem
{
Quantity = "1",
CatalogObjectId = itemvariationcatalogid,
BasePriceMoney = new Money { Amount = (long)price * 100, Currency = square.SquareCurrency }
};
var lineItems = new List<OrderLineItem>();
lineItems.Add(lineItem);
// Create Order
var orderMetadata = new Dictionary<string, string?>();
orderMetadata.Add("UserId", vm.User.Id);
orderMetadata.Add("UserName", vm.User.UserName);
orderMetadata.Add("UserEmail", vm.User.Email);
orderMetadata.Add("SubscriptionTier", vm.Tier);
orderMetadata.Add("SubscriptionPrice", vm.Price.ToString());
orderMetadata.Add("SubscriptionCredits", vm.Credits.ToString());
string referenceId = System.Guid.NewGuid().ToString();
var order = new Order
{
CustomerId = squareCustomer.Id,
LocationId = square.SquareLocationId,
LineItems = lineItems,
Metadata = orderMetadata,
ReferenceId = referenceId
};
// Create Payment Link
string redirectUrl = String.Format("{0}://{1}/Credits/PaymentProcessed/{2}", Request.Scheme, Request.Host, referenceId);
var paymentRequest = new CreatePaymentLinkRequest
{
IdempotencyKey = squareIdempotencyKey,
Order = order,
CheckoutOptions = new CheckoutOptions
{
SubscriptionPlanId = planccatalogid,
RedirectUrl = redirectUrl,
MerchantSupportEmail = SundaySolved.Constants.kSupportEmail
}
};
var response = await squareClient.Checkout.PaymentLinks.CreateAsync(paymentRequest);
return Redirect(response.PaymentLink.Url);