WP-Invoice API

XML-RPC based API for interacting with the internal WP-Invoice API.

Original WordPress XML-RPC API (http://codex.wordpress.org/XML-RPC_WordPress_API)

Extending (http://codex.wordpress.org/XML-RPC_Extending)


XML-RPC Method

There is a single XML-RPC method wp.invoice which is in fact used as something like NAMESPACE. Three different arguments should be passed during request to this method in following order:

  1. Internal Method Name
  2. Credentials
  3. Internal Method Arguments

Internal Methods

Current API is new and we are going to add new methods for some time.

Create Invoice

Allows to create invoices from the information passed.

Method: create_invoice

Get Invoice

Returns invoice object by passed ID.

Method: get_invoice

Delete Invoice

Deletes invoice object by passed ID and returns boolean.

Method: delete_invoice

Refund Invoice

Refund invoice by ID. Note that it does not do refund on merchant side.

Method: refund_invoice

Pay Invoice

Pay invoice by ID

Method: pay_invoice

Update Invoice

Update some of the invoice attributes.

Method: update_invoice


Credentials

Credentials are simply WordPress login and password of WordPress user.


Internal Method Arguments

It is the third argument that should contain an Associative Array of parameters. It varies depending on methods. Detailed lists of arguments you can find in WP-Invoice installation. Settings->Help->WP-Invoice XML-RPC API Reference.


Examples

Creating an invoice

include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );

$client = new WP_HTTP_IXR_Client( 'http://example.site.com/xmlrpc.php' );

$client->query('wp.invoice', array(
  $method = 'create_invoice',
  $credentials = array('xmlrpc-user', 'password'),
  $args = array(
      'subject'     => 'Test API Invoice',
      'description' => 'Invoice descriptive information.',
      'type'        => 'invoice',
      'user_data'   => array(
          'user_email' => 'recipient@email.com',
          'first_name' => 'John',
          'last_name'  => 'Smith'
      ),
      'deposit'     => 15.99,
      'due_date'    => array(
          'month' => '09',
          'day'   => '10',
          'year'  => '2013'
      ),
      'currency'    => 'USD',
      'tax'         => 10.5,
      'tax_method'  => 'after_discount',
      'status'      => 'active',
      'discount'  => array(
          'name'   => 'Your Discount',
          'type'   => 'amount',
          'amount' => 1.20
      ),
      'items' => array(
          array(
              'name' => 'Test item 1',
              'description' => 'Item 1 description',
              'quantity' => 2,
              'price' => 2.65,
              'tax_rate' => 1 //global 'tax' will be used in order to priority
          ),
          array(
              'name' => 'Test item 2',
              'description' => 'Item 2 description',
              'quantity' => 4,
              'price' => 3.85
          )
      ),
      'charges' => array(
          array(
              'name' => 'Fee 1',
              'amount' => 0.56
          ),
          array(
              'name' => 'Fee 2',
              'amount' => 0.99,
              'tax' => 15 //global 'tax' will be used in order to priority
          )
      )
  )
));

$new_invoice = $client->getResponse();

Getting an invoice

include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );

$client = new WP_HTTP_IXR_Client( 'http://example.site.com/xmlrpc.php' );

$client->query('wp.invoice', array(
    $method = 'get_invoice',
    $credentials = array('xmlrpc-user', 'password'),
    $args = array(
        'ID' => 43508300
    )
));

$the_invoice = $client->getResponse();

Deleting an invoice

include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' );

$client = new WP_HTTP_IXR_Client( 'http://example.site.com/xmlrpc.php' );

$client->query('wp.invoice', array(
    $method = 'delete_invoice',
    $credentials = array('xmlrpc-user', 'password'),
    $args = array(
        'ID' => 43508300
    )
));

if ( $client->getResponse() ) {
  echo 'Invoice has been deleted';
} else {
  echo 'Cannot delete invoice';
}

WP-Invoice

  1. WP-Invoice & WP-CRM Integration
  2. Installing WP-Invoice Add ons
  3. WP-Invoice - Home
  4. How to create custom template for invoice page in WP-Invoice plugin?
  5. WP-Invoice settings Payment tab
  6. WP-Invoice Settings Business Process tab
  7. WP-Invoice Settings Main tab
  8. WP-Invoice API
  9. WP-Invoice Shortcodes
  10. WP-Invoice Plugin Just [wp Invoice] Shortcode On The Page
  11. WP-Invoice Widgets
  12. WP-Invoice Settings Line Items Tab
  13. WP-Invoice Settings E Mail Templates Tab
  14. WP-Invoice PayPal Partial Payment. Reporting That Invoice Already Paid.
  15. WP-Invoice - Translating Wp Invoice
  16. Setting Up Recurring Billing In WP-Invoice Plugin
  17. Redirection Loop On Single Invoice Page In WP-Invoice Plugin
  18. Quotes Response Form Do Not Appear In WP-Invoice Plugin
  19. Plugin Throws 404 403 500 Error After Save Setting In WP-Invoice Plugin
  20. PayPal. Invoice Is Not Updated With Paid Status In WP-Invoice Plugin.
  21. PayPal Username And Sandbox Error In WP-Invoice Plugin
  22. PayPal Payment Settings In WP-Invoice Plugin
  23. Page Not Found (404 Error) When Trying To View Invoice In WP-Invoice Plugin
  24. MerchantPlus And Other Authorize Gateways In WP-Invoice Plugin
  25. Installing WP-Invoice
  26. How To Replace The "Access Denied" With The Login Box In WP-Invoice?
  27. Global Or Specific Invoice Payment Settings In WP-Invoice Plugin
  28. Billing With WP-Invoice
  29. How To Create Custom Template For Invoice Page In WP-Invoice Plugin?
  30. Empty Blank Invoice Page Or Just [wp Invoice] Instead Of Invoice In WP-Invoice Plugin
  31. Editing An Invoice In WP-Invoice Plugin
  32. Creating An Invoice In WP-Invoice Plugin
  33. WP-Invoice and WooCommerce compatibility

Feedback and Knowledge Base