I have created plan and got plan id from response but when i passing that planid in createpaymentlink request that time it is showing something like below.
{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “Invalid object OI6R2HGECR5ETQNXAMI62UHL
: incorrect object type SUBSCRIPTION_PLAN
.”,
“field”: “subscription_plan_id”
}
]
}
Create Plan request as below
curl https://connect.squareupsandbox.com/v2/catalog/object
-X POST
-H ‘Square-Version: 2023-09-25’
-H ‘Authorization: Bearer ACCESS_TOKEN’
-H ‘Content-Type: application/json’
-d ‘{
“idempotency_key”: “f9ab22ee-5046-4e39-9963-59a02ba875e3”,
“object”: {
“type”: “SUBSCRIPTION_PLAN”,
“id”: “#1990”,
“subscription_plan_data”: {
“name”: “testetstet”,
“phases”: [
{
“cadence”: “MONTHLY”,
“recurring_price_money”: {
“amount”: 1500,
“currency”: “USD”
}
},
{
“cadence”: “MONTHLY”,
“recurring_price_money”: {
“amount”: 1500,
“currency”: “USD”
}
}
],
“all_items”: true
}
}
}’
Create Plan response as below
{
“catalog_object”: {
“type”: “SUBSCRIPTION_PLAN”,
“id”: “OI6R2HGECR5ETQNXAMI62UHL”,
“updated_at”: “2023-10-02T09:29:42.987Z”,
“created_at”: “2023-10-02T09:29:42.987Z”,
“version”: 1696238982987,
“is_deleted”: false,
“present_at_all_locations”: true,
“subscription_plan_data”: {
“name”: “testetstet”,
“all_items”: true
}
},
“id_mappings”: [
{
“client_object_id”: “#189”,
“object_id”: “OI6R2HGECR5ETQNXAMI62UHL”
}
]
}
Createpayment link request as below
curl https://connect.squareupsandbox.com/v2/online-checkout/payment-links
-X POST
-H ‘Square-Version: 2023-09-25’
-H ‘Authorization: Bearer ACCESS_TOKEN’
-H ‘Content-Type: application/json’
-d ‘{
“idempotency_key”: “57291bd7-dce4-4617-ba9a-944ae4d7cd08”,
“quick_pay”: {
“name”: “Gym membership fees”,
“price_money”: {
“amount”: 1500,
“currency”: “USD”
},
“location_id”: “LTBWC2JWZ5WV6”
},
“checkout_options”: {
“subscription_plan_id”: “OI6R2HGECR5ETQNXAMI62UHL”
}
}’
Createpaymentlink response as below
{
“errors”: [
{
“category”: “INVALID_REQUEST_ERROR”,
“code”: “INVALID_VALUE”,
“detail”: “Invalid object OI6R2HGECR5ETQNXAMI62UHL
: incorrect object type SUBSCRIPTION_PLAN
.”,
“field”: “subscription_plan_id”
}
]
}
Api log request as below
{
“idempotency_key”: “57291bd7-dce4-4617-ba9a-944ae4d7cd08”,
“quick_pay”: {
“name”: “Gym membership fees”,
“price_money”: {
“amount”: 1500,
“currency”: “USD”
},
“location_id”: “LTBWC2JWZ5WV6”
},
“checkout_options”: {
“subscription_plan_id”: “OI6R2HGECR5ETQNXAMI62UHL”
}
}