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

Sorry to bring back an old thread, but I am also having this issue.


I have created a plan with a 7-day trial. There is a mandatory, non-recurring addon for this plan of $7 at trial start. ChargeBee docs indicate that this is the right way to create a paid trial.


But when I try to create the subscription, I get this "'Non recurring addon cannot be added now as invoice is not raised immediately." Error.


How can I create a paid trial?

Hey Mike,


Setting up paid trials with the help of addons is definitely possible. Please find below the steps to create a paid trial using auto-addons option. 


1) Create a plan with a free trial period.


2) Create a non-recurring addon with price equal to the amount that you would like to charge for the trial.


3) Navigate to Product Catalog >> Plans >> Choose the Plan >> Edit Plan >> Go to Addons section >> Add addons >> Select the addon >> Choose ‘Mandatory’ >> Charge customers on - Subscription Trial Start >> Apply charge - once/every time the event occurs >> Save. Please refer to the screenshot.


Whenever a checkout happens for this particular plan, your customers will be charged for the addon’s price immediately upon checkout.


Hope this information helps you set up a paid trial. Let us know if you still face errors after following these steps.

Regards,
Sharmili
Chargebee

Login or Signup to post a comment