Ads by Google

Infusionsoft SDK Invoice Service

The InvoiceService exposes functions to be performed on invoices, including creating invoices, recurring orders, locating and creating credit cards, charging cards, setting up payment plans, etc. there are orders, recurring orders, and invoices. There is a one-to-one relationship between orders and invoices (although they may not always have the same id) and a one-to-many relationship between recurring orders and invoices (a new invoice is created each time the recurring order billing cycle comes due).

In the SDK you get access to the invoice service functions by including the file “InvoiceService.php” in your code. Below is a list of the functions, their return values and the arguments they accept.

Function Description Return Value Arguments
manualPmt Adds a manual payment to an Infusionsoft Invoice. Boolean 6
commOverride Adds a commision override to a one time order. Boolean 8
addOrderItem Adds an item to an order. Boolean 7
payPlan Adds a payment plan to an order. Boolean 11
recurringCommOverride Adds a commision override to a recurring order. Boolean 5
addRecurring Adds a recurring order to a contact. Integer 7
amtOwed Calculates the total due on an invoice. Double 1
chargeInvoice Charges an invoice for the amount currently due on it. Array 5
blankOrder Creates a blank order for a contact. Array 5
recurringInvoice Creates an invoice for all charges due on a recurring order. Integer 1
locateCard Locates a credit card for a contact based on the last 4 digits. Integer 2
validateCard UValidates a Credit card based on ID or Card Array. Boolean 1

manualPmt( [int] Invoice ID, [double] Payment Amount, [date] Payment Date, [string] Payment Type, [string] Description, [boolean] Bypass Commisions );
This function will add a manual payment to an invoice, you must specify the Invoice, Amount, Date, Payment Type, description and if you want to bypass commisions. Listed below is a code example.

The out put from the above code is as follows:

Note that Invoices do not share ID’s with Orders, if you need to locate an invoice ID see the query function located in the data service.

For more information on the infuDate() function please look at Additional Functions and Services.

commOverride( [int] Invoice ID, [int] Affiliate ID, [int] Product ID, [int] Percentage, [double] Amount, [int] Payout Type, [string] Description, [date] Date );

Adds a commission override to a one time order, using a combination of percentage and hard-coded amounts. The Payout types are as follows:

4 = Pay Upfront
5 = Pay on receipt

Below is sample code of the function.

Function returns a boolean value.

addOrderItem( [int] Order ID, Product ID, [int] Type, [double] Price, [int] Quantity, [string] Description, [string] Notes );

The addOrderItem function is used to add items to orders. This function will return a boolean value to let you know if it succeeded or not. The product type argument will take the following values:

FINANCECHARGE = 6;
PRODUCT = 4;
SERVICE = 3;
SHIPPING = 1;
SPECIAL = 7;
TAX = 2;
UNKNOWN = 0;
UPSELL = 5;

Below we have a sample call to this function.

payPlan( [int] Order ID, [boolean] Auto Charge, [int] Credit Card ID, [int] Merchant Account ID, [int] Days Between Retry, [int] Max Retry, [double] Initial Payment Amount, [date] Initial Date, [date] Plan Start Date, [int] Number of Payments, [int] Days Between Payments );

This function adds a payment plan to an existing invoice. This will not charge the invoice, but rather set up the payment plan. The autocharger will pick it up and charge it within 24 hours.

This api call works exactly the same as the add payment plan screen in Infusionsoft.

Argument Breakdown:

  • Order ID: ID of the Invoice to create the plan for.
  • Auto Charge: Whether or not to automatically start payments.
  • Credit Card ID: The ID of the Credit card to use for charges.
  • Merchant Account ID: The ID of the Merchant Account to process charges.
  • Days Between Retry: The number of days between charge attempts when a charge fails.
  • Max Retry: Nummer of times to try and recharge a card that has failed.
  • Initial Payment Amount: This is usually set to the shipping or tax amount, or any other amount that you want paid up front. The remainder of the order will be broken up evenly among the other payments.
  • Initial Payment Date: This is the payment date for the initial payment entered above. You may want the shipping to be paid up front in full, but the payment plan won’t actually start charging for 45 days (a free trial).
  • Plan Start Date: This is the date the payment plan actually starts charging
  • Number of Payments: The number of payments in this plan, NOT including the first payment.
  • Days Between Payments: Number of days between payments, any whole number greater than zero.

Below is a sample of the function.

arecurringCommOverride( [int] Recurring Order Override, [int] Affiliate ID, [double] Amount, [int] Payout Type, [string] Description );

Adds a commission override to a recurring order. Will not add commissions to invoices previously generated by this recurring order.

Payout Type: 4=Payment Up Front, 5=Payment when Customer Pays

Below is a sample of the function.

addRecurring( [int] Contact ID, [boolean] Allow Duplicates, [int] Program ID, [int] Merchant ID, [int] Credit Card ID, [int] Affiliate ID, [int] Days Until Charge );
the addRecurring function will add a recurring order to a contacts record.

Below is a sample of the function.

The above code will add a recurring order to contact 123, It will not add it if there is a duplicate order since we specified false, it will use the continuity program with the ID 24, it will user merchant account 1, Credit card ID 16, Affiliate ID 189 and it will wait 7 days to charge the first payment(7 day free trial).

$result will contain the Recurring Order’s ID.

amtOwed( [int] Invoice ID );
amtOwed is a very simple function to use, you pass it the ID of an invoice and it returns a double containing the currently due balance of that invoice.

Below we have a sample of it in action.

The out put from the above code is as follows:

Note that Invoices do not share ID’s with Orders, if you need to locate an invoice ID see the query function located in the data service.

For more information on the infuDate() function please look at Additional Functions and Services.

chargeInvoice( [int] Invoice ID, [string] Notes, [int] Credit Card ID, [int] Merchant ID, [boolean] Bypass Commissions );
the chargeInvoice function will charge an invoice with amount currently due on it. You can Specify the Credit Card and Merchant Account to use for the transaction.

$result will be an array containing payment details. The array will contain the following keys:

[Successful] – true or false on whether or not the card was charged. (If there was nothing to charge, this will be false)
[Code] – The approval code: APPROVED, DECLINED, ERROR, SKIPPED (there was no balance to charge)
[RefNum] – If charge was successful, this is the reference number passed back by the merchant account
[Message] – Error message, if any, for the transaction.

blankOrder( [int] Contact ID, [string] Description, [date] Order Date, [int] Lead Affiliate ID, [int] Sale Affiliate ID );
Creates a blank order with no items. You’ll have to use this first when creating an order, then you can use addOrderItem or payPlan etc.

Below we have a sample of creating a blank order.

$result will be the ID of the order created.

recurringInvoice( [int] Recurring Order ID );
This will create an invoice for all charges due on a recurring order. If the recurring order has three billing cycles that are due, it will create one invoice with three items attached to it.

Below is a sample of the function.

$result will be either the ID of the invoice that was created or 0 if there were not any cycles due.

locateCard( [int] Contact ID, [string] Last 4 Digits );

This function is used to locate a credit card ID for a contact.

Below is a sample of using the function.

$result will be the ID of the credit card located.

validateCard( [int] Credit Card ID -OR- [array] Credit Card Details );

the Validate card function is used to validate a credit cards details based off of its ID, or before you add it to the system. If you pass it an integer it will attempt to validate a card in the system, if you pass it an array of card details it will validate the array. This check will not determine if the card has an available balance.

Below is a sample of the function being used with a credit card ID.

The returned value of $result will be an array with the following elements.

[Valid] – true or false
[Message] – Any message about the card validation, including why it didn’t validate.

Below is a sample of using the function with a credit card array.

 

Summary
Infusionsoft SDK Invoice Service
Article Name
Infusionsoft SDK Invoice Service
Description
The InvoiceService exposes functions to be performed on invoices, including creating invoices, recurring orders, locating and creating credit cards, charging cards, setting up payment plans, etc. there are orders, recurring orders, and invoices.
Author
www.CreativForm.com