Start a new topic
Implemented

Create Subscription with custom field for subscription

I added a custom fiel url to my subscription the dialog says the id is cf_url when I try to add a value to that field the subscription is added but the value for cf_url is empty. Here is the curl example I use:


curl  https://sabio-test.chargebee.com/api/v2/subscriptions      -u secret:      -d customer[email]="john@user.com"      -d customer[first_name]="John"      -d customer[last_name]="Doe"      -d customer[phone]="+1-949-999-9999"      -d plan_id="trial"      -d addons[id][1]="cbdemo_setuphelp"      -d billing_address[first_name]="John"      -d billing_address[last_name]="Doe"      -d billing_address[line1]="PO Box 9999"      -d billing_address[city]="Walnut"      -d billing_address[state]="California"      -d billing_address[zip]="91789"      -d billing_address[country]="US -d cf_url="test""


Is there something special to subscription custom fields? 


Hi Christian,


We tested your API call on your test site and got the following error message: 


{"message":"Non recurring addon cannot be added now as invoice is not raised immediately.","type":"invalid_request","api_error_code":"invalid_request","error_code":"non_recurring_addon_not_supported","error_msg":"Non recurring addon cannot be added now as invoice is not raised immediately.","http_status_code":400}


This error occurs when a non recurring addon is added to a plan which has a trial period. As the invoice is not raised immediately in this case, which is required for a non recurring addon to get added successfully, this would be the response that is returned and the subscription will not be created in this case. 


Please retry the same call on a plan that doesn't have a trial period associated with it and let us know if the issue still persists. Alternately, you can also try the API call without the addon. 


1 person likes this

Hi,


sorry I used the wrong command from my history. This was the one I wanted to execute and this one works fine.


url  https://sabio-test.chargebee.com/api/v2/subscriptions      -u secret      -d customer[email]="john@user.com"      -d customer[first_name]="John"      -d customer[last_name]="Doe"      -d customer[phone]="+1-949-999-9999"      -d plan_id="trial"      -d cf_url="test"


Sorry and thanks for your answer.

Hi,


I try to add the same custom field using javascript your client library and everything works find but cf_url is empty in the subscription. I added the code to this ticket. Can you please help me what is wrong?


Thanks in advance


Christian

zip
(24 KB)

Hi Christian,


Thank you for your patience.


As a workaround to get this working for now, please change this line, 


ChargeBee.configure({site: 'sabio-test', api_key: ""});


to 


ChargeBee.configure({site: 'sabio-test', api_key: "", apiPath: '/api/js/v2'});


This would make our system handle your request using API v2, adding the value to subscription custom field. 


This is a temporary workaround as we've not yet released JS API v2 while subscription level custom fields are supported only on JS API v2. We're working on revamping JS for API v2 and we'll give you an update as soon as it's released. 


Let us know if you've more questions.

Cheers,

LN | Happiness Enthusiast

Getting Started with Subscription Billing

Login or Signup to post a comment