Subscription Plan ID max length? - Wrong error message when too long

This one was scratching my head for a long time.

When you create a subscription plan you can optionally pass in your own ID instead of allowing Rapyd to create one for you.

I discovered after many hours of frustration / confusion.

If you pass in a plan.id with around 45,46 characters or more, you receive this message back from the API:

{
    "status": {
        "error_code": "ERROR_CREATE_PLAN",
        "status": "ERROR",
        "message": "The request tried to create a plan, but the 'type' field of a product is set to 'goods'. The request was rejected. Corrective action: Add only products that have 'type' set to 'service'.",
        "response_code": "ERROR_CREATE_PLAN",
        "operation_id": "6421c100-c2e8-4f5b-8d5c-3e49668365b1"
    }
}

This is error message seems to be incorrectly mapped, as the error has nothing to do with the Product. The product does have the type set to service and as long as the ID is shorter then 45 characters, there is no issues.

Just wanted to share as you might add to the docs a max length on the subscription.plan.id or add a targeted error message.

Hi may191,
Thanks for the feedback! Can you please send the request as well, so we can fully inspect this issue.

Thanks

Sure thing the below is all in sandbox:

A request like below to /pans:

{
    "id": "12345678901234567hfdsghjsdfhgjkhjsdhjkdsfhjkdfshjkdsfghjksdafhfgdfghfdghfdghfdghhfasd",
    "product": "g_forms_VJUF39",
    "currency": "SGD",
    "interval": "month",
    "nickname": "Gold Plan (Weekly Mowing) + Use bagger for clippings - $ + Water gardens and flowers - $",
    "amount": 110.83
}

returns:

{
    "status": {
        "error_code": "ERROR_CREATE_PLAN",
        "status": "ERROR",
        "message": "The request tried to create a plan, but the 'type' field of a product is set to 'goods'. The request was rejected. Corrective action: Add only products that have 'type' set to 'service'.",
        "response_code": "ERROR_CREATE_PLAN",
        "operation_id": "72800882-bd4f-48ad-8bbb-d22cd3ca3358"
    }
}

Then if a shorten the plan.id to something smaller and random:

{
    "id": "123456789hfdghfdghfdghhfasd",
    "product": "g_forms_VJUF39",
    "currency": "SGD",
    "interval": "month",
    "nickname": "Gold Plan (Weekly Mowing) + Use bagger for clippings - $ + Water gardens and flowers - $",
    "amount": 110.83
}

You then get back:

{
    "status": {
        "error_code": "",
        "status": "SUCCESS",
        "message": "",
        "response_code": "",
        "operation_id": "2b723a32-9736-4c50-a051-f2e1461714cc"
    },
    "data": {
        "id": "123456789hfdghfdghfdghhfasd",
        "aggregate_usage": "sum",
        "amount": 110.83,
        "billing_scheme": "per_unit",
        "created_at": 1625669553,
        "currency": "SGD",
        "interval": "month",
        "interval_count": 1,
        "metadata": {},
        "product": {
            "id": "g_forms_VJUF39",
            "active": true,
            "attributes": [],
            "created_at": 1625351155,
            "description": "We get your lawn mowed quick and easy.",
            "images": [],
            "metadata": {
                "google_form_url": "https://docs.google.com/forms/d/1f_RxQOrQ0fBPucEi5_AaVSfCk21DRJddik3nJakSdF4/viewform"
            },
            "name": "Rapyd Lawn Mowing",
            "package_dimensions": {
                "height": 0,
                "length": 0,
                "weight": 0,
                "width": 0
            },
            "shippable": false,
            "skus": [],
            "statement_descriptor": "",
            "type": "service",
            "unit_label": "",
            "updated_at": 1625351155
        },
        "nickname": "Gold Plan (Weekly Mowing) + Use bagger for clippings - $ + W",
        "tiers": [],
        "tiers_mode": "",
        "transform_usage": {
            "divide_by": 1,
            "round": "up"
        },
        "trial_period_days": 0,
        "usage_type": "licensed"
    }
}

While your team is looking at it - The same error seems to be mapped for a duplicate plan.id.

If you say try to create 2 plans with the same ID. On the second request you will get:

{
    "status": {
        "error_code": "ERROR_CREATE_PLAN",
        "status": "ERROR",
        "message": "The request tried to create a plan, but the 'type' field of a product is set to 'goods'. The request was rejected. Corrective action: Add only products that have 'type' set to 'service'.",
        "response_code": "ERROR_CREATE_PLAN",
        "operation_id": "37f3bd54-5c64-4ff7-aa1f-696438fb86e2"
    }
}

When in reality… I assume that one should say something like “ID Already Used”

Hi,
Thanks for noticing the issues. I tried this myself, and a plan id that is longer than 44 characters does cause issues (our documentation currently states that the limit is 50 characters). This will be updated. The second issue about the inaccurate error message for an ID that was previously used will also be updated.

Thanks