Skip to content

Instantly share code, notes, and snippets.

@jaredk2g
Created May 25, 2018 14:12
Show Gist options
  • Save jaredk2g/43ef78c206bba9a62c7715c3ba4197ed to your computer and use it in GitHub Desktop.
Save jaredk2g/43ef78c206bba9a62c7715c3ba4197ed to your computer and use it in GitHub Desktop.
Editing subscription with coupons
curl https://api.sandbox.invoiced.com/subscriptions \
	-u 1234: \
	-d customer=137208 \
	-d plan=starter \
	-d discounts="test"
{
    "addons": [],
    "approval": null,
    "cancel_at_period_end": false,
    "canceled_at": null,
    "contract_period_end": null,
    "contract_period_start": null,
    "contract_renewal_cycles": null,
    "contract_renewal_mode": "none",
    "created_at": 1527257470,
    "customer": 137208,
    "cycles": null,
    "discounts": [
        {
            "created_at": 1478549653,
            "currency": "usd",
            "duration": 0,
            "exclusive": false,
            "expiration_date": null,
            "id": "test",
            "is_percent": false,
            "max_redemptions": 0,
            "name": "Test",
            "value": 11,
            "object": "coupon",
            "metadata": {}
        }
    ],
    "id": 6017,
    "metadata": {},
    "object": "subscription",
    "payment_source": null,
    "period_end": 1529935870,
    "period_offset_days": 0,
    "period_start": 1527257470,
    "plan": "starter",
    "quantity": 1,
    "renewed_last": 1527257470,
    "renews_next": 1529935870,
    "start_date": 1527257470,
    "status": "active",
    "taxes": [],
    "url": "https:\/\/acmecorp.sandbox.invoiced.com\/subscriptions\/YkvYwicQlmhvgzwtRGmWi5YB"
}
curl https://api.sandbox.invoiced.com/subscriptions/6017 \
	-u 1234: \
	-d plan=basic \
	-X PATCH
{
    "addons": [],
    "approval": null,
    "cancel_at_period_end": false,
    "canceled_at": null,
    "contract_period_end": null,
    "contract_period_start": null,
    "contract_renewal_cycles": null,
    "contract_renewal_mode": "none",
    "created_at": 1527257470,
    "customer": 137208,
    "cycles": null,
    "discounts": [
        {
            "created_at": 1478549653,
            "currency": "usd",
            "duration": 0,
            "exclusive": false,
            "expiration_date": null,
            "id": "test",
            "is_percent": false,
            "max_redemptions": 0,
            "name": "Test",
            "value": 11,
            "object": "coupon",
            "metadata": {}
        }
    ],
    "id": 6017,
    "metadata": {},
    "object": "subscription",
    "payment_source": null,
    "period_end": 1529935870,
    "period_offset_days": 0,
    "period_start": 1527257470,
    "plan": "basic",
    "quantity": 1,
    "renewed_last": 1527257470,
    "renews_next": 1529935870,
    "start_date": 1527257470,
    "status": "active",
    "taxes": [],
    "url": "https:\/\/acmecorp.sandbox.invoiced.com\/subscriptions\/YkvYwicQlmhvgzwtRGmWi5YB"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment