Find Me On

Quick Question?

First Name *
Email *
My Quick Question is:

The vault

Member Login





Lost your password?
Not a member? Sign up here

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. Integer 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 Validates a Credit card based on ID or Card Array. Array 1
deleteInvoice Deletes an invoice from Infusionsoft. Boolean 1
deleteSubscription Deletes a subscription from Infusionsoft. Boolean 1
getInvoiceId Gets the invoice ID for a specific order. Integer 1
getOrderId Gets the order ID for a specific invoice. Integer 1

manualPmt( [int] Invoice ID, [double] Payment Amount, [date] Payment Date, [string] Payment Type, [string] Description, [boolean] Bypass Commisions );

Top Menu

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.

$payDate = $myApp->infuDate("01-12-2007");
echo "Invoice 43 owes: " . $myApp->amtOwed(43) . "<br />";
$operation =$myApp->manualPmt(43,5.06,$payDate,"Check","Personal check",false);
if ($operation) {
    echo "Manual Payment Successful<br />";
} else {
    echo "Manual Payment Failed<br />";
}
echo "Invoice 43 now owes: " . $myApp->amtOwed(43);

The out put from the above code is as follows:

Invoice 43 owes: 34.94
Manual Payment Successful
Invoice 43 now owes: 29.88

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 );

Top Menu

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.

$cDate = $myApp->infuDate("01-12-2007");
$myApp->commOverride(43,1,3,15,5.06,5,"No Description",$cDate);

Function returns a boolean value.


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

Top Menu

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.

$result = $myApp->addOrderItem(23,17,6,23.07,2,"Head gaskets","Price: $23.07");

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 );

Top Menu

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:

  1. Order ID: ID of the Invoice to create the plan for.
  2. Auto Charge: Whether or not to automatically start payments.
  3. Credit Card ID: The ID of the Credit card to use for charges.
  4. Merchant Account ID: The ID of the Merchant Account to process charges.
  5. Days Between Retry: The number of days between charge attempts when a charge fails.
  6. Max Retry: Nummer of times to try and recharge a card that has failed.
  7. 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.
  8. 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).
  9. Plan Start Date: This is the date the payment plan actually starts charging
  10. Number of Payments: The number of payments in this plan, NOT including the first payment.
  11. Days Between Payments: Number of days between payments, any whole number greater than zero.

Below is a sample of the function.

$inDate = $myApp->infuDate("10-11-2008");
$stDate = $myApp->infuDate("10-25-2008");
$result = $myApp->payPlan(43,true,12,1,2,3,25.50,$inDate,$stDate,5,30);

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

Top Menu

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.

$result = $myApp->recurringCommOverride(123,1,25.50,4,"Changed Commision to 25.50");

addRecurring( [int] Contact ID, [boolean] Allow Duplicates, [int] Program ID, [int] Merchant ID, [int] Credit Card ID, [int] Affiliate ID, [int] Days Until Charge );

Top Menu

the addRecurring function will add a recurring order to a contacts record.

Below is a sample of the function.

$result = $myApp->addRecurring(123,false,24,1,16,189,7);

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 );

Top Menu

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.

$payDate = $myApp->infuDate("01-12-2007");
echo "Invoice 43 owes: " . $myApp->amtOwed(43) . "<br />";
$operation = $myApp->manualPmt(43,5.06,$payDate,"Check","Personal check",false);
if ($operation) {
    echo "Manual Payment Successful<br />";
} else {
    echo "Manual Payment Failed<br />";
}
echo "Invoice 43 now owes: " . $myApp->amtOwed(43);

The out put from the above code is as follows:

Invoice 43 owes: 34.94
Manual Payment Successful
Invoice 43 now owes: 29.88

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 );

Top Menu

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 = $myApp->chargeInvoice(16,"Cutomer Paid",2,1,false);

$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 );

Top Menu

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.

$oDate = $myApp->infuDate("8-9-2008");
$result = $myApp->blankOrder(123,"New Order for Contact 123", $oDate,187);

$result will be the ID of the order created.


recurringInvoice( [int] Recurring Order ID );

Top Menu

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 = $myApp->recurringInvoice(123);

$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 );

Top Menu

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

Below is a sample of using the function.

$result = $myApp->locateCard(123,"1234");

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


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

Top Menu

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.

$result = $myApp->validateCard(1);

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.

$card = array('CardType' => 'Visa',
              'ContactId' => 123,
              'CardNumber' => "4111111111111111",
              'ExpirationMonth' => '12',
              'ExpirationYear' => '2009',
              'CVV2' => '123');
$result = $myApp->validateCard($card);

deleteInvoice( [Int] Invoice ID );

Top Menu

This function is used to delete an Invoice from Infusionsoft

$status = $app->deleteInvoice(123);

deleteSubscription( [Int] Subscription ID );

Top Menu

This function is used to delete a subscription from Infusionsoft

$status = $app->deleteSubscription(123);

getInvoiceId( [Int] Order ID );

Top Menu

This function is used to get the ID of an invoice using the Order ID.

The line below will return the Invoice ID for order ID 123.

$invId = $app->getInvoiceId(123);

getOrderId( [Int] Invoice ID );

Top Menu

This function is used to get the ID of an order using the invoice ID.

The line below will return the order ID for invoice ID 123.

$invId = $app->getOrderId(123);

This concludes the Invoice Service functions. Happy Coding!