PHP classes that connect to the Quipu API see documentation
The Quipu_Api_Connection class is a singleton class and will keep the connection open for 2 hours. The connection instance must be passed to each class.
$api_connection = Quipu_Api_Connection::get_instance('YOUR_APP_KEY', 'YOUR_APP_SECRET');
Pass the connection class to the numeration class, then call "create_series". The series will either be created or loaded if it already exists.
$quipu_num = new Quipu_Api_Numeration($api_connection);
$quipu_num->create_series('YOUR_PREFIX');
The following parameters can be passed to create a contact.
$contact = array(
"name" => "CONTACT_NAME",
"tax_id" => "CONTACT_VAT_ID",
"phone" => "CONTACT_PHONE ",
"email" => "CONTACT_EMAIL",
"address" => "CONTACT_ADDRESS",
"town" => "CONTACT_CITY",
"zip_code" => "CONTACT_ZIP_CODE",
"country_code" => "CONTACT_CODE"
);
Pass the connection class to the contact class, then call "create_contact", with the array above. The contact will either be created or loaded if they already exist.
$quipu_contact = new Quipu_Api_Contact($api_connection);
$quipu_contact->create_contact($contact);
The following parameters can be passed to create an invoice.
$order = array(
"payment_method" => "PAYMENT_METHOD",
"issue_date" => "YYYY-mm-dd",
"items" => array(
"product" => "PRODUCT_NAME",
"cost" => "PRODUCT_PRICE",
"quantity" => "PRODUCT_QUANTITY",
"vat_per" => "VAT_PERCENTAGE"
);
);
Pass the connection class to the invoice class:
$quipu_invoice = new Quipu_Api_Invoice($api_connection);
You can first set the Numbering Series if one exists:
$quipu_invoice->set_numeration($quipu_num);
A contact is required or the invoice cannot be created:
$quipu_invoice->set_contact($quipu_contact);
Once the contact is passed to the class you can create an invoice
$quipu_invoice->create_invoice($order);
To get the internal Quipu Invoice id. Store locall to use for refunds.
$quipu_invoice->get_id()
The following parameters can be passed to create a refund.
$order = array(
"invoice_id" => "QUIPU_INVOICE_ID",
"refund_date" => "YYYY-mm-dd",
"items" => array(
"product" => "PRODUCT_NAME",
"cost" => "PRODUCT_PRICE",
"quantity" => "PRODUCT_QUANTITY",
"vat_per" => "VAT_PERCENTAGE"
);
);
Pass the connection class to the invoice class:
$quipu_invoice = new Quipu_Api_Invoice($api_connection);
You can first set the Refund Numbering Series if one exists:
$quipu_invoice->set_numeration($refund_num_series);
Call the 'refund_invoice' function to refund an invoice
$quipu_invoice->refund_invoice($order);