Infusionsoft is a sales and marketing automation software. It has a great feature set if you are the owner of a small business and are looking to convert sales into leads as well as automating the whole marketing process painlessly. Of course you have to pay for its yearly subscription but the good thing is it is an Inc5000 listed company, so the credibility area is justified.
But enough of this talk. Let’s get to the real deal.
Infusionsoft API is built upon Java and uses XML-RPC for all procedure calls. They say if you want a RPC mechanism with a lighter footprint, use XML-RPC. So, the guys over at Infusionsoft must have kept this thing in mind. Oh i’m drifting again. Oh my. Ok. Straight to the point, Infusionsoft has a PHP SDK to use Infusionsoft API. It has a lot of methods but we are concerned with two API services which can be used to add Infusionsoft order.
Method 1 : Using Order Service
We can use placeOrder method of the SDK to add an order , like so:
$sdk->placeOrder($contactId, $creditCardId, $payPlanId, $productIds, $subscriptionIds, $processSpecials, $promoCodes, $leadAff = 0, $saleAff = 0)
Following are the descriptions of the input parameters in the above method:
$contactId = Contact ID of existing contact in Infusionsoft
$creditCardId = Credit card ID of existing contact in Infusionsoft
$payPlanId = Payment plan
$productIds = Product IDs to be attached to the product in array form
$subscriptionIds = For products that have subscription plan(s)
$processSpecials = Apply Infusionsoft discounts(set false if you are not using the Infusionsft Ecommerce front)
$promoCodes = Apply promo codes(Depends upon above field)
The placeOrder returns OrderID and InvoiceId on successful operation and returns error message depending upon SDK config.
Method2: Using Invoice Service
We can also create a new order using bloankOrder method of the API. This way we add order details after we have added the blank order.
$sdk->blankOrder($contactId,$description, $orderDate, $leadAffiliate, $saleAffiliate);
All the parameters are self-descriptive. $leadAffiliate and $saleAffiliate are the affiliate IDs to which to assign the order.
This method returns Invoice Id which in most cases is same as the Order ID. We can then use the InvoiceId to add order details using addOrderItem method.
$sdk->addOrderItem($invoiceId, $productId, $type, $price, $quantity, $description, $notes);
Above parameters are again self-explanatory. But you must make sure that you type-cast the float values such as $price, since the API sometimes returns exception of invalid parameters if it’s not sure about the type of data and it happens because as I already mentioned, the API is Java based which itself is strongly type.
Latest posts by alexey (see all)
- Quick Facts About WooCommerce - April 25, 2018
- WordPress stuck on a “Too many redirects” error loop when using SSL - January 17, 2018
- Sails.js + Passport.js : req.user undefined - December 31, 2017