Or perhaps there is a better way to generate an invoice on submit of my gravity form. Perhaps the API is not needed if I am within the same site. Are there already functions, hooks, filters, that I can use within the plug in to submit an invoice?
My solution given that I am trying to integrate with Gravity Forms and I am already within the server is to do this:
<?php
include ( "wp-load.php" );
$args = array(
'subject' => 'Test API Invoice',
'description' => 'Invoice descriptive information.',
'type' => 'invoice',
'user_data' => array(
'user_email' => '[email protected]',
'first_name' => 'Lary',
'last_name' => 'Test'
),
'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
)
)
);
$WPI_XMLRPC_API = new WPI_XMLRPC_API();
$new_invoice = $WPI_XMLRPC_API->create_invoice($args);
It does the job and I can build a function to gather the form field data from my gravity form and replace the values with variables from the form and have an invoice created. Perfect.
-
This reply was modified 6 years, 8 months ago by
cravaus.