Cannot create an order for SUBSCRIPTION_PLAN_VARIATION

Hello,

I would like to create a payment link for my customer and send it to my customer to subscribe. I cannot use default payment links because I need to pass custom metadata for each and every order that the buyer cannot see.

I have created SUBSCRIPTION_PLAN with ID 26VSWGYP6PEWR55ATI5LEIRT.
Then I have created SUBSCRIPTION_PLAN_VARIATION with ID W6R3JYCK6P5CIWYB6XB2CN6W.

When I try to create a draft order for this SUBSCRIPTION_PLAN_VARIATION

I get this

{:code=>"NOT_FOUND", :detail=>"Item variation with catalog object ID W6R3JYCK6P5CIWYB6XB2CN6W not found.", :category=>"INVALID_REQUEST_ERROR"}

To get the payment link, I must create an order, it seems. I tried using quick_pay but failed, because it creates a fixed payment instead of subscription. If quick_pay can create subscriptions, that would be an option…

: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:

https://developer.squareup.com/docs/app-marketplace/requirements/subscriptions-api

Additional Documentation

Create and Publish Invoices
Create and Publish Invoices
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.

      result = client.orders.create_order(
        body: {
          order: {
            location_id: "",
            line_items: [
              {
                quantity: "1",
                catalog_object_id: "W6R3JYCK6P5CIWYB6XB2CN6W"
              }
            ],
            state: "DRAFT"
          },
          idempotency_key: Digest::UUID.uuid_v4
        }
      )

This is how I try to create a draft.

      client.checkout.create_payment_link(
        body: {
          quick_pay: {
            customer_id: "",
            name: "",
            location_id: "",
            price_money: {
              amount: 999,
              currency: "USD"
            }
          },
          "checkout_options": {
            "subscription_plan_id": "your VARIATION ID here (not plan ID)"
          }
        }
      )

Yo guys that seems to do the trick

Also you can use payment_note to pass in any metadata you need for the subscriptions. :slight_smile:

After passing payment_note where shall I expect it? I cannot find it in Order, Subscription, Invoice and Payment objects. It should be in the Payment object, isn’t it?

I found it. It appears that payment_note is attached to PaymentLink rather than Payment which makes documentation misleading.

How do get PaymentLink if I have only Payment or Order?

Did you look at the checkout? If you RetrievePaymentLink with the payment_link_id it will have the note included. :slight_smile:

I am really having a hard time here. I have created a link with ID LA2O6MO5W7DFRTCM and it has order ID ZGJxPICvxhuShwOF5gpnS7ibERGZY. When I paid for it, in the webhook I received had order ID Lzl4Il0isEJwkW2z0b0pr6pUUz8YY which is different from what was in the payment link.

The question remains. Once I create a payment link and send it to my customer, how do I retrieve the payment link from successful payment event?

I just want to attach extra metadata for subscription but I am really struggle to retrieve it.

How do I know payment_link_id from the invoice?

To put it simply, I just need to attach custom data to a subscription and receive it (or fetch it) when I get payment done.

Hey there! Just followed up in your other thread: