Module: Infusionsoft::Client::Invoice

Included in:
Infusionsoft::Client
Defined in:
lib/infusionsoft/client/invoice.rb

Overview

The Invoice service allows you to manage eCommerce transactions.

Instance Method Summary collapse

Instance Method Details

#add_manual_payment(invoice_id, amount, date, payment_type, description, bypass_commission) ⇒ Object

adding a manual payment for an invoice. This can be useful when the payments are not handled by Infusionsoft but you still needs to makethe invoice as paid

Parameters:

  • invoice_id (Integer)
  • amount (Float)
  • date (Date)

    (time)

  • payment_type (String)
    • E.g ‘Credit Card’

  • description (String)
  • bypass_commissions (Boolean)

    (Whether this payment should count towards affiliate commissions.)



283
284
285
286
# File 'lib/infusionsoft/client/invoice.rb', line 283

def add_manual_payment(invoice_id, amount, date, payment_type, description, bypass_commission)
  response = xmlrpc('InvoiceService.addManualPayment', invoice_id, amount,
                 date, payment_type, description, bypass_commission)
end

#invoice_add_manual_payment(invoice_id, amount, date, type, description, bypass_commissions) ⇒ Boolean

Adds a payment to an invoice without actually processing a charge through a merchant.

Parameters:

  • invoice_id (Integer)
  • amount (Float)
  • date (Date)
  • type (String)

    Cash, Check, Credit Card, Money Order, PayPal, etc.

  • description (String)

    an area useful for noting payment details such as check number

  • bypass_commissions (Boolean)

Returns:

  • (Boolean)


136
137
138
139
# File 'lib/infusionsoft/client/invoice.rb', line 136

def invoice_add_manual_payment(invoice_id, amount, date, type, description, bypass_commissions)
  response = xmlrpc('InvoiceService.addManualPayment', invoice_id, amount, date, type,
                 description, bypass_commissions)
end

#invoice_add_order_commission_override(invoice_id, affiliate_id, product_id, percentage, amount, payout_type, description, date) ⇒ Boolean

Adds a commission override to a one time order, using a combination of percentage and hard-coded amounts.

Parameters:

  • invoice_id (Integer)
  • affiliate_id (Integer)
  • product_id (Integer)
  • percentage (Integer)
  • amount (Float)
  • payout_type (Integer)

    how commision should be earned (4 - up front in full, 5 - upon customer payment

  • description (String)

    a note about this commission

  • date (Date)

    the commission was generated, not necessarily earned

Returns:

  • (Boolean)


264
265
266
267
268
# File 'lib/infusionsoft/client/invoice.rb', line 264

def invoice_add_order_commission_override(invoice_id, affiliate_id, product_id, percentage,
                                          amount, payout_type, description, date)
  response = xmlrpc('InvoiceService.addOrderCommissionOverride', invoice_id, affiliate_id,
                 product_id, percentage, amount, payout_type, description, date)
end

#invoice_add_order_item(invoice_id, product_id, type, price, quantity, description, notes) ⇒ Boolean

Adds a line item to an order. This used to add a Product to an order as well as any other sort of charge/discount.

Parameters:

  • invoice_id (Integer)
  • product_id (Integer)
  • type (Integer)

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

  • price (Float)
  • quantity (Integer)
  • description (String)

    a full description of the line item

  • notes (String)

Returns:

  • (Boolean)

    returns true/false if it was added successfully or not



31
32
33
34
# File 'lib/infusionsoft/client/invoice.rb', line 31

def invoice_add_order_item(invoice_id, product_id, type, price, quantity, description, notes)
  response = xmlrpc('InvoiceService.addOrderItem', invoice_id, product_id, type, price,
                 quantity, description, notes)
end

#invoice_add_payment_plan(invoice_id, auto_charge, credit_card_id, merchant_account_id, days_between_retry, max_retry, initial_payment_amount, initial_payment_date, plan_start_date, number_of_payments, days_between_payments) ⇒ Boolean

Adds a payment plan to an existing invoice.

Parameters:

  • invoice_id (Integer)
  • (Boolean)
  • credit_card_id (Integer)
  • merchant_account_id (Integer)
  • days_between_retry (Integer)

    the number of days Infusionsoft should wait before re-attempting to charge a failed payment

  • max_retry (Integer)

    the maximum number of charge attempts

  • initial_payment_ammount (Float)

    the amount of the very first charge

  • initial_payment_date (Date)
  • plan_start_date (Date)
  • number_of_payments (Integer)

    the number of payments in this payplan (does not include initial payment)

  • days_between_payments (Integer)

    the number of days between each payment

Returns:

  • (Boolean)


167
168
169
170
171
172
173
174
175
# File 'lib/infusionsoft/client/invoice.rb', line 167

def invoice_add_payment_plan(invoice_id, auto_charge, credit_card_id,
                             , days_between_retry, max_retry,
                             initial_payment_amount, initial_payment_date, plan_start_date,
                             number_of_payments, days_between_payments)
  response = xmlrpc('InvoiceService.addPaymentPlan', invoice_id, auto_charge,
                 credit_card_id, , days_between_retry, max_retry,
                 initial_payment_amount, initial_payment_date, plan_start_date, number_of_payments,
                 days_between_payments)
end

#invoice_add_recurring_commission_override(recurring_order_id, affiliate_id, amount, payout_type, description) ⇒ Boolean

This modifies the commissions being earned on a particular subscription. This does not affect previously generated invoices for this subscription.

Parameters:

  • recurring_order_id (Integer)
  • affiliate_id (Integer)
  • amount (Float)
  • paryout_type (Integer)

    how commissions will be earned (possible options are 4 - up front earning, 5 - upon customer payment) typically this is 5

Returns:

  • (Boolean)


121
122
123
124
125
# File 'lib/infusionsoft/client/invoice.rb', line 121

def invoice_add_recurring_commission_override(recurring_order_id, affiliate_id,
                                              amount, payout_type, description)
  response = xmlrpc('InvoiceService.addRecurringCommissionOverride', recurring_order_id,
                 affiliate_id, amount, payout_type, description)
end

#invoice_add_recurring_order(contact_id, allow_duplicate, cprogram_id, merchant_account_id, credit_card_id, affiliate_id, days_till_charge) ⇒ Object

Creates a subscription for a contact. Subscriptions are billing automatically by infusionsoft within the next six hours. If you want to bill immediately you will need to utilize the create_invoice_for_recurring and then charge_invoice method to accomplish this.

Parameters:

  • contact_id (Integer)
  • allow_duplicate (Boolean)
  • cprogram_id (Integer)

    the subscription id

  • merchant_account_id (Integer)
  • credit_card_id (Integer)
  • affiliate_id (Integer)
  • days_till_charge (Integer)

    number of days you want to wait till it’s charged



72
73
74
75
76
77
78
79
80
81
# File 'lib/infusionsoft/client/invoice.rb', line 72

def invoice_add_recurring_order(contact_id, allow_duplicate, cprogram_id,
                                , credit_card_id, affiliate_id,
                                days_till_charge)

  api_logger.warn "[DEPRECATION WARNING]: The invoice_add_subscription method more fully complies with Infusionsoft's published API documents. User is advised to review Infusionsoft's API and this gem's documentation for changes in parameters."

  response = xmlrpc('InvoiceService.addRecurringOrder', contact_id,
                 allow_duplicate, cprogram_id, , credit_card_id,
                 affiliate_id, days_till_charge)
end

#invoice_add_recurring_order_with_price(contact_id, allow_duplicate, cprogram_id, qty, price, allow_tax, merchant_account_id, credit_card_id, affiliate_id, days_till_charge) ⇒ Object

Deprecated - Adds a recurring order to the database.



290
291
292
293
294
295
296
# File 'lib/infusionsoft/client/invoice.rb', line 290

def invoice_add_recurring_order_with_price(contact_id, allow_duplicate, cprogram_id, qty,
                                           price, allow_tax, ,
                                           credit_card_id, affiliate_id, days_till_charge)
  response = xmlrpc('InvoiceService.addRecurringOrder', contact_id, allow_duplicate,
                 cprogram_id, qty, price, allow_tax, , credit_card_id,
                 affiliate_id, days_till_charge)
end

#invoice_add_subscription(contact_id, allow_duplicate, cprogram_id, qty, price, allow_tax, merchant_account_id, credit_card_id, affiliate_id, days_till_charge) ⇒ Object

This is a replacement method for invoice_add_recurring_order in order to fully support and comply with the Infusionsoft API documentation.

Parameters:

  • contact_id (Integer)
  • allow_duplicate (Boolean)
  • cprogram_id (Integer)

    the subscription id

  • qty (Integer)
  • price (Float)
  • allow_tax (Boolean)
  • merchant_account_id (Integer)
  • credit_card_id (Integer)
  • affiliate_id (Integer)
  • days_till_charge (Integer)

    number of days you want to wait till it’s charged



100
101
102
103
104
105
106
107
# File 'lib/infusionsoft/client/invoice.rb', line 100

def invoice_add_subscription(contact_id, allow_duplicate, cprogram_id,
                                qty, price, allow_tax,
                                , credit_card_id, affiliate_id,
                                days_till_charge)
  response = xmlrpc('InvoiceService.addRecurringOrder', contact_id,
                 allow_duplicate, cprogram_id, qty, price, allow_tax, , credit_card_id,
                 affiliate_id, days_till_charge)
end

#invoice_calculate_amount_owed(invoice_id) ⇒ Float

Calculates the amount owed for a given invoice.

Parameters:

  • invoice_id (Integer)

Returns:

  • (Float)


181
182
183
# File 'lib/infusionsoft/client/invoice.rb', line 181

def invoice_calculate_amount_owed(invoice_id)
  response = xmlrpc('InvoiceService.calculateAmountOwed', invoice_id)
end

#invoice_charge_invoice(invoice_id, notes, credit_card_id, merchant_account_id, bypass_commissions) ⇒ Hash

This will cause a credit card to be charged for the amount currently due on an invoice.

Parameters:

  • invoice_id (Integer)
  • notes (String)

    a note about the payment

  • credit_card_id (Integer)
  • merchant_account_id (Integer)
  • bypass_commission (Boolean)

Returns:

  • (Hash)

    containing the following keys => [Boolean], ‘Code’ => [String], ‘RefNum’ => [String], ‘Message’ => [String]



45
46
47
48
49
# File 'lib/infusionsoft/client/invoice.rb', line 45

def invoice_charge_invoice(invoice_id, notes, credit_card_id, ,
                           bypass_commissions)
  response = xmlrpc('InvoiceService.chargeInvoice', invoice_id, notes, credit_card_id,
                      , bypass_commissions)
end

#invoice_create_blank_order(contact_id, description, order_date, lead_affiliate_id, sale_affiliate_id) ⇒ Integer

Creates a blank order with no items.

Parameters:

  • contact_id (Integer)
  • description (String)

    the name this order will display

  • order_date (Date)
  • lead_affiliate_id (Integer)

    0 should be used if none

  • sale_affiliate_id (Integer)

    0 should be used if none

Returns:

  • (Integer)

    returns the invoice id



13
14
15
16
17
# File 'lib/infusionsoft/client/invoice.rb', line 13

def invoice_create_blank_order(contact_id, description, order_date, lead_affiliate_id,
                               sale_affiliate_id)
  response = xmlrpc('InvoiceService.createBlankOrder', contact_id, description, order_date,
                  lead_affiliate_id, sale_affiliate_id)
end

#invoice_create_invoice_for_recurring(recurring_order_id) ⇒ Integer

This will create an invoice for all charges due on a Subscription. If the subscription has three billing cycles that are due, it will create one invoice with all three items attached.

Parameters:

  • recurring_order_id (Integer)

Returns:

  • (Integer)

    returns the id of the invoice that was created



147
148
149
# File 'lib/infusionsoft/client/invoice.rb', line 147

def invoice_create_invoice_for_recurring(recurring_order_id)
  response = xmlrpc('InvoiceService.createInvoiceForRecurring', recurring_order_id)
end

#invoice_delete_subscription(cprogram_id) ⇒ Boolean

Deletes the specified subscription from the database, as well as all invoices tied to the subscription.

Parameters:

  • cprogram_id (Integer)

    the id of the subscription being deleted

Returns:

  • (Boolean)


56
57
58
# File 'lib/infusionsoft/client/invoice.rb', line 56

def invoice_delete_subscription(cprogram_id)
  response = xmlrpc('InvoiceService.deleteSubscription', cprogram_id)
end

#invoice_get_all_payment_otpionsArray

Retrieve all Payment Types currently setup under the Order Settings section of Infusionsoft.

Returns:

  • (Array)


188
189
190
# File 'lib/infusionsoft/client/invoice.rb', line 188

def invoice_get_all_payment_otpions
  response = xmlrpc('InvoiceService.getAllPaymentOptions')
end

#invoice_get_all_shipping_optionsArray

Retrieves the shipping options currently setup for the Infusionsoft shopping cart.

Returns:

  • (Array)


237
238
239
# File 'lib/infusionsoft/client/invoice.rb', line 237

def invoice_get_all_shipping_options
  response = xmlrpc('Invoice.getAllShippingOptions')
end

#invoice_get_invoice_id(order_id) ⇒ Object

Deprecated - returns the invoice id from a one time order.



299
300
301
# File 'lib/infusionsoft/client/invoice.rb', line 299

def invoice_get_invoice_id(order_id)
  response = xmlrpc('InvoiceService.getInvoiceId', order_id)
end

#invoice_get_payments(invoice_id) ⇒ Array<Hash>

Retrieves all payments for a given invoice.

Parameters:

  • invoice_id (Integer)

Returns:

  • (Array<Hash>)

    returns an array of payments



196
197
198
# File 'lib/infusionsoft/client/invoice.rb', line 196

def invoice_get_payments(invoice_id)
  response = xmlrpc('Invoice.getPayments', invoice_id)
end

#invoice_locate_existing_card(contact_id, last_four) ⇒ Integer

Locates an existing card in the system for a contact, using the last 4 digits.

Parameters:

  • contact_id (Integer)
  • last_four (Integer)

Returns:

  • (Integer)

    returns the id of the credit card



205
206
207
# File 'lib/infusionsoft/client/invoice.rb', line 205

def invoice_locate_existing_card(contact_id, last_four)
  response = xmlrpc('InvoiceService.locateExistingCard', contact_id, last_four)
end

#invoice_recalculate_tax(invoice_id) ⇒ Boolean

Calculates tax, and places it onto the given invoice.

Parameters:

  • invoice_id (Integer)

Returns:

  • (Boolean)


213
214
215
# File 'lib/infusionsoft/client/invoice.rb', line 213

def invoice_recalculate_tax(invoice_id)
  response = xmlrpc('InvoiceService.recalculateTax', invoice_id)
end

#invoice_update_recurring_next_bill_date(job_recurring_id, next_bill_date) ⇒ Boolean

Changes the next bill date on a subscription.

Parameters:

  • job_recurring_id (Integer)

    this is the subscription id on the contact

  • next_bill_date (Date)

Returns:

  • (Boolean)


246
247
248
# File 'lib/infusionsoft/client/invoice.rb', line 246

def invoice_update_recurring_next_bill_date(job_recurring_id, next_bill_date)
  response = xmlrpc('InvoiceService.updateJobRecurringNextBillDate', job_recurring_id, next_bill_date)
end

#invoice_validate_card(data) ⇒ Hash

This will validate a credit card by passing in values of the card directly (this card doesn’t have to be added to the system).

Parameters:

  • data (Hash)

Returns:

  • (Hash)

    returns a hash { ‘Valid’ => false, ‘Message’ => ‘Card is expired’ }



221
222
223
# File 'lib/infusionsoft/client/invoice.rb', line 221

def invoice_validate_card(credit_card_id)
  response = xmlrpc('InvoiceService.validateCreditCard', credit_card_id)
end