Docs
You are viewing:
Product Catalog 2.0
I am trying to pass the metaData parameter while updating subscriptions using API. However, the response does not have the metaData passed.
Summary
The solution article covers how to pass the metaData parameter while updating subscriptions.
Solution You would need to pass the value for the metaData parameter as a JSON string for this to work. "{"api_key_1":"dfads","api_key_2":"ewrqew"}". You can convert the JSON into JSON string using tool online.
Example API call
curl https://acme-test.chargebee.com/api/v2/subscriptions/16CLw5Taletv39AC/update_for_items
-u test_XXXXXXXXXXXXXXXXXXXX:
-d subscription_items[item_price_id][0]="monthly1-USD-Monthly"
-d subscription_items[unit_price][0]=9000
-d invoice_immediately="true"
-d meta_data="\{"api_key_1":"dfads","api_key_2":"ewrqew"}"
Response
{
"subscription": {
"id": "16CLw5Taletv39AC",
"billing_period": 1,
"billing_period_unit": "month",
"remaining_billing_cycles": 3,
"customer_id": "ac-test",
"status": "active",
"current_term_start": 1680891849,
"current_term_end": 1683483849,
"next_billing_at": 1683483849,
"created_at": 1680891849,
"started_at": 1680891849,
"activated_at": 1680891849,
"updated_at": 1681498006,
"has_scheduled_changes": false,
"channel": "web",
"resource_version": 1681498006793,
"deleted": false,
"object": "subscription",
"currency_code": "USD",
"subscription_items": [{
"item_price_id": "monthly1-USD-Monthly",
"item_type": "plan",
"quantity": 1,
"unit_price": 9000,
"amount": 9000,
"free_quantity": 0,
"billing_cycles": 3,
"object": "subscription_item"
},
{
"item_price_id": "addon1-USD-Monthly",
"item_type": "addon",
"quantity": 1,
"unit_price": 1200,
"amount": 1200,
"object": "subscription_item"
},
{
"item_price_id": "imp-charges1-USD-Monthly",
"item_type": "addon",
"quantity": 1,
"unit_price": 45200,
"amount": 45200,
"object": "subscription_item"
}
],
"due_invoices_count": 0,
"mrr": 96400,
"exchange_rate": 1.0,
"base_currency_code": "USD",
"has_scheduled_advance_invoices": false,
"create_pending_invoices": false,
"auto_close_invoices": true,
"meta_data": {
"api_key_1": "dfads",
"api_key_2": "ewrqew"
}
},
"customer": {
"id": "ac-test",
"auto_collection": "on",
"net_term_days": 0,
"allow_direct_debit": false,
"created_at": 1675706413,
"taxability": "taxable",
"updated_at": 1681047602,
"pii_cleared": "active",
"channel": "web",
"resource_version": 1681047602832,
"deleted": false,
"object": "customer",
"card_status": "valid",
"promotional_credits": 0,
"refundable_credits": 0,
"excess_payments": 0,
"unbilled_charges": 0,
"preferred_currency_code": "USD",
"primary_payment_source_id": "pm_16CLyXTV6jRsn2nX",
"payment_method": {
"object": "payment_method",
"type": "card",
"reference_id": "tok_16CLyXTV6jRsa2nW",
"gateway": "chargebee",
"gateway_account_id": "gw_16BYibTKd9w0i7k1",
"status": "valid"
},
"auto_close_invoices": true
},
"card": {
"status": "valid",
"gateway": "chargebee",
"gateway_account_id": "gw_16BYibTKd9w0i7k1",
"iin": "411111",
"last4": "1111",
"card_type": "visa",
"funding_type": "credit",
"expiry_month": 12,
"expiry_year": 2024,
"created_at": 1675706439,
"updated_at": 1675706439,
"resource_version": 1675706439696,
"object": "card",
"masked_number": "**1111",
"customer_id": "ac-test",
"payment_source_id": "pm_16CLyXTV6jRsn2nX"
},
"credit_notes": []
}
Was this article helpful?