wpinv_complete_payment

Fires after an invoice has been marked as paid. do_action( ‘wpinv_complete_payment’, int $invoice_id ); Parameters # $invoice_id (int) The Invoice ID. Examples # Simple example to handle paid invoice event. function _wpi_wpinv_complete_payment( $invoice_id ) { // Invoice object $invoice = wpinv_get_invoice( $invoice_id ); // Invoice items $cart_items = $invoice->get_cart_details(); // Do your stuff here } […]

Hooks in Handling Payments

Hooks used in handling payments. wpinv_status_{$new_status} Fires after an invoice status has been changed. wpinv_status_{$old_status}_to_{$new_status} Fires after an invoice status has been changed. wpinv_update_status Fires after an invoice status has been changed. wpinv_complete_payment Fires after an invoice status has been marked as paid. wpinv_post_refund_invoice Fires after an invoice amount has been refunded. wpinv_recurring_add_subscription_payment Fires after […]

wpinv_update_invoice()

Introduction | Parameters | Examples Introduction # Update an invoice. wpinv_update_invoice( array $invoice_data = array(), bool $wp_error = false ) This method allows you to add/remove items to an invoice, add/remove discount for invoice, update billing address, update payment details etc. To update an invoice the $invoice_data must have a parameter ‘ID’ with an invoice […]

wpinv_insert_invoice()

Introduction | Parameters | Examples Introduction # Create an invoice. wpinv_insert_invoice( array $invoice_data = array(), bool $wp_error = false ) Parameters # $invoice_data (array) (Required) An array of elements to insert an invoice. status(string) (Optional) The invoice status. Learn more about invoice statuses.Default: ‘wpi-pending’ user_id(int) (Optional) The invoice user id.Default: user ID of current logged […]

wpinv_update_item()

Introduction | Parameters | Examples Introduction # Update an item. wpinv_update_item( array $args = array(), bool $wp_error = false ) Item data will be updated for the value set in ‘ID’ parameter. It only updates data which are passed to $args array. Parameters # $args (array) (Required) An array of elements to update an item. […]

wpinv_create_item()

Introduction | Parameters | Examples Introduction # Create a new item. wpinv_create_item( array $args = array(), bool $wp_error = false, bool $force_update = false ) If the $args parameter has ‘custom_id’ set to a value and $force_update is true, then item will be updated for matching ‘item_id’ and ‘type’. Parameters # $args (array) (Required) An […]

Adding a Custom Item Type

Getting started In this post describes example of how to create a custom item with custom item type and accept payments. You can download our sample plugin here: wpinv-custom-item.zip Register a item type Let’s start by registering a custom item type “product” with the title “Product”. /** * Register the custom item type. */ function […]

Creating a Payment Gateway

Introduction Registering the gateway Gateway backend settings Add support for recurring payments Set up the credit card form, if any Processing the payment Validating the payment Handling the Payment Gateway Callbacks 1) Registering the gateway public function add_gateway( $gateways = array() ) { /** * $gateways[{GATEWAY_ID}] = array( * ‘admin_label’ => __( ‘Custom Gateway’, ‘my-textdomain’ […]