Invoice Payment for WooCommerce is an extension plugin for WooCommerce that aims to facilitate the management of invoices through the platform. It sends a new invoice email notification for the client and invoice creation with a direct payment link.
Plugin at WordPress marketplace https://wordpress.org/plugins/lkn-wc-gateway-cielo/
Invoice Payment for WooCommerce plugin is dependent on WooCommerce plugin, please make sure WooCommerce is installed and properly configured before starting Invoice Payment for WooCommerce installation.
-
Look in the sidebar for the WordPress plugins area;
-
In installed plugins look for the 'add new' option in the header;
-
Click on the 'submit plugin' option in the page title and upload the lkn-wc-invoice-payment.zip plugin;
-
Click on the 'install now' button and then activate the installed plugin;
The Invoice Payment for WooCommerce plugin is now live and working.
- Within the product editing or creating page, enable the subscription option to configure recurring invoices.
- Specify the frequency of invoice generation according to your preferences.
- In the WordPress sidebar, find and click on "Invoices".
- Configure default settings such as PDF template, logo URL, footer, sender details, and text preceding the payment link.
- To manually add an invoice, visit the "Add Invoice" page, where both standard and recurring invoices can be created.
- Visit the "Add Invoice" page to manually create invoices.
- Choose between standard or recurring invoices, input necessary details, and save.
- To list subscriptions click on "Subscriptions" in the WordPress sidebar.
- To list invoices click on "Invoices" in the WordPress sidebar.
HTML to PDF lib: https://github.com/dompdf/dompdf
Setup a WYSIWYG editor in a textarea: https://codex.wordpress.org/Javascript_Reference/wp.editor
QR Code lib: https://phpqrcode.sourceforge.net/#home
This document explains how to use the lkn_process_subscription_{paymentMethod}
filter to process subscriptions in your system.
The filter name should include the payment method ID. For example, if the payment method is creditCard
, the filter should be named lkn_process_subscription_creditCard
.
The lkn_process_subscription_{paymentMethod}
filter receives three parameters:
- New Subscription Invoice ID (
$newOrderId
): This is the ID of the new invoice generated for the subscription. - Customer ID (
$customerId
): This is the ID of the customer associated with the subscription and invoice. - Retry (
$retry
): This parameter is a boolean that indicates whether the current call is a retry.
The lkn_process_subscription_{paymentMethod}
filter should return an associative array with the following elements:
- status: A boolean value indicating whether the subscription processing was successful. If
true
, the system understands that the payment was completed and calls thepayment_complete()
method to finalize the process. - makeRetry: A boolean value that signals whether a new attempt to process the subscription should be made. This parameter is used when the processing was not successful, but the application logic allows for a retry.
- nextCronHours: A numeric value (integer) that defines the interval, in hours, for the next processing attempt. If
makeRetry
istrue
andnextCronHours
is greater than 0, the system will schedule a new execution of the filter after this interval using thewp_schedule_single_event
function.
add_filter('lkn_process_subscription_genericPayment', 'process_subscription_generic_payment', 10, 3);
function process_subscription_generic_payment($newOrderId, $customerId, $retry) {
// Get the subscription order
$order = wc_get_order($newOrderId);
if (!$order) {
return [
'status' => false,
'makeRetry' => false,
'nextCronHours' => 0
];
}
// Simulate the call to the payment gateway API
$paymentResponse = process_payment_with_gateway($order);
if ($paymentResponse['success']) {
return [
'status' => true, // Successful payment
'makeRetry' => false,
'nextCronHours' => 0
];
} else {
return [
'status' => false, // Payment failed
'makeRetry' => true, // Retry
'nextCronHours' => 6 // Try again in 6 hours
];
}
}
The subscription status is automatically updated only if the success status ($status
) is true
and it is not a retry. If it is a retry, the method itself must change the status.