InvoiceService create subscription with RecurringOrder.OriginatingOrderId


I am trying to create an order with a subscription. When the standard IS order forms create an order for a subscription the RecurringOrder’s OriginatingOrderId field stores the ID of the order (Job).

Subscription renewal orders (Jobs) connect to the RecurringOrder through JobRecurringId.

This way you can find the initial order of a subscription through RecurringOrder.OriginatingOrderId and renewal orders through Job.JobRecurringId.

We use this in our data analytics to show which orders belong to which subscription.

Now we want to use the API to create upsell orders, but I can’t figure out how to create a subscription and correctly associate it with the originating order when using the InvoiceService.

Here’s what an order created using a standard IS order form looks like:

The subscription picks up the originating order and displays it in the subscription list.

But when you create the subscription through the InvoiceSergice, there isn’t a way to associate it…

Here’s my code:

isapi = Infusionsoft('app', 'key')

contact_id = 932817
invoice_id = isapi.InvoiceService('createBlankOrder', contact_id, 'Upsell: Test',, 0, 0);
                     120, # product id
                     9, #type Subscription Plan
                     995.00, # price,
                     1, #quantity
                     'No note')

                     True, # allow dupes
                     120, # subscription plan id
                     1, # quantity
                     995.00, #price
                     False, #taxable
                     13, # merchant account
                     113047, # credit card id
                     0, # affiliateID
                     0 # trialPeriod

Clearly it’s not working since the originating order id is not set anywhere. But in the API documentation that field is read only. So it’s not possible to change it either.

How can I properly create an order for a subscription?

I have tried reading all of the documentation and every psot about subscriptions here on the forum, but still couldn’t find anything.

Thanks, in advance.

Your approach is fine but that field is set according to the date the order is created and you won’t be able to override that (the originating order date that is).

Thanks, John.

So what you are saying is that IS links the two orders automatically IF they are created at exactly the same time?

That seems to be impossible to do since the order creation API call requires some time to execute and then the Invoice one too.

Is there no other solution to get these linked up like the standard order form does?

Anytime an order is created an invoice is also created (just fyi) which contains the original order id. What I would do at the time an order is created would be to immediately look for the most recent order by date and then with that you can gather the remaining information (ie the original order id). You may have to store that information in a field or something if that’s still needed later but in the context of campaign builder that gets far more difficult so it would seem the issue for you isn’t just in coding but relating that into actionable details for use in IS as well?

Thanks, John this makes sense and I can solve it on my data warehouse side.

But it still doesn’t answer the question of how can a developer properly implement an order form that can order subscriptions and properly associate them with their original order the way it’s meant to be.

Surely, ordering subscriptions properly is something that can be done through the API.