Documentation

LHV hire-purchase for WooCommerce

The plugin source code is available on Github. Please feel free to open a feature request, issue or pull request.
LHV Hire Purchase for WooCommerce is maintained and supported by Codelight.
If you run into any bugs, technical issues or have trouble with installing or configuring the plugin, please contact our support.

Requirements

  • PHP > 5.6,
  • WP > 4.8,
  • WooCommerce > 3.0

Setting up a contract with AS LHV Finance

In order to accept payments via LHV Hire Purchase payment gateway, you will need a valid contract with AS LHV Finance. Apply for a contract here.
During the signing process, you will be asked to generate a public and private key pair in your server. If you are not sure how to do that, contact your customer support representative or follow the process described in LHV payment gateway pluginMake sure you save the private key – you will need it later.

Note that if you already have an existing contract for LHV Bank link payments, you will still need to sign a separate contract for LHV Hire Purchase.

Plugin installation and configuration

Install and activate LHV Hire Purchase for Woocommerce just like any other WordPress plugin. If you don’t know how to do that, WPBeginner has an excellent video teaching the basics of plugin installation. Watch it here.

To configure the plugin, log in to your WordPress admin, then navigate to WooCommerce > Settings > Checkout > LHV Hire Purchase.

Merchant ID

Fill in your Merchant ID field (also known as VK_SND_ID). You should be able to find it from an email sent by AS LHV Finance after your contract was signed. If you do not know your merchant ID or cannot find it, please contact AS LHV Finance customer support:
Email: finance@lhv.ee
Phone: (+372) 680 2700

Private key

When you signed the contract with AS LHV Finance, you were requested to generate a public and private key pair and send the public key to AS LHV Finance. Find the private key that you generated, open it with a text editor and copy-paste the contents into this field. The key should start with —–BEGIN RSA PRIVATE KEY—– and look like something in the above screenshot.

Private key password
3-3-private-key-pass
If you protected your private key with a password during the generation process, enter that password. If you are not sure, just leave this field blank.

LHV test mode

If LHV test mode is enabled, real transactions will not be made. Instead, you can make mock transactions and choose their returned status, i.e. if they should be accepted or rejected by LHV.

Website test mode
3-1-website-testmode
If website test mode is enabled, only logged-in Administrators will be able to see and use this gateway. It will be hidden from regular customers. This can be useful if you want to test the gateway in a live system.

Debugging, logs and error messages

If a customer runs into a technical error, they will be spared the technical details and will see only the following message:
We were unable to process the order using LHV Hire Purchase due to a technical error. Please contact the store support or use a different payment method. 

However, the actual error details will be logged in your WooCommerce logs. To view them, go to WooCommerce > Status > Logs and on the right side of the page, choose a log that starts with ‘lhv’:

For even easier debugging, we recommend adding the following line to wp-config.php

define( 'WC_LOG_HANDLER', 'WC_Log_Handler_DB' );

Place this line of code just above the following lines:

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

This will enable logging errors to database, which includes the ability to comfortably filter error messages by type:

Error messages

Below is a list of all errors with a quick explanation.

Failed to verify signature!
This error is triggered if the plugin is unable to validate the hashed response from AS LHV Finance. This probably means that the public key entered on the plugin’s Settings page is wrong. If you spot this error, please contact your AS LHV Finance customer support representative and ask them for the correct public key. If the new key doesn’t work either, please contact plugin support.

Error opening default public key file!
This error is triggered if WordPress cannot access the default public key file located in the plugin folder. It probably means there’s an issue with file permissions in the server. If you spot this error, please contact your web host.

Error verifying signature using openssl_verify()!
This error is triggered if there’s a technical problem with validating the hashed response from LHV bank, i.e. openssl_verify() returning -1. If you spot this error, please contact your web host.

Unable to open private key! Maybe a bad password?
This error is triggered if openssl_pkey_get_private() fails to open the provided private key. This could be caused by a wrong password. If you spot this error, double-check the password you entered on the plugin settings page. If you don’t remember your password or didn’t even create a password, you will unfortunately need to generate a new keypair and send the new public key to your customer support representative at LHV again.

Unable to sign the request! [error message]
This error is triggered if openssl_sign() fails. The details of the error message should be logged on the same line. This means there’s probably an issue with your server configuration. Please contact your web host and show them this error.

Invalid order ID: [order id]
This error is triggered if the customer is attempting to pay for a non-existing order. This could be caused by an outdated payment link in the browser history or a conflict with a plugin. If you see this error more than once, please contact plugin support.

Attempting to process an empty order!
This error is triggered if the customer somehow manages to attempt to pay for an empty order, i.e. one that doesn’t contain an order item or a shipping method. This could be caused by a conflict with other plugins. If you spot this error, please contact plugin support.

Unknown status (VK_SERVICE) returned by LHV!
This error is triggered if the response status from LHV is something other than described by their documentation. If you spot this error, please contact plugin support.

Error messages from LHV

In some cases, an error message is displayed by LHV after you are redirected to the bank for payment (note that you need to have LHV test mode enabled for this). These messages are not logged.

Coflink service request has invalid param value: VK_MAC
This error indicates that there is a problem with your key pair – the private key entered in the plugin settings does not match the certificate request (public key) you sent to LHV. Please check if the keys match – instructions here. If they don’t match, then please generate a new keypair while carefully following the instructions provided by LHV and send them the new certificate request.

NB! In some cases, even though the keys matched, generating a new keypair and asking LHV to use the new key has solved this problem.

Developer docs: Actions & Filters

The plugin uses WordPress filters extensively so it’s possible to customize almost everything.

Filters

Below is an incomplete list of the most useful filters. See the source code on github for all filters.

lhv/hire-purchase/method_icon
This filter allows you to change the payment method icon visible to customers.

lhv/hire-purchase/message-rejected-bank
This filter allows you to change the message displayed to a customer if their application is rejected by AS LHV Finance.

lhv/hire-purchase/message-technical-error
This filter allows you to change the message displayed to a customer in case of a technical error.

lhv/hire-purchase/redirect-success
This filter allows you to change the redirect URL after a successful order.

lhv/hire-purchase/redirect-rejected
This filter allows you to change the redirect URL if a customer’s application is rejected by AS LHV Finance.

lhv/hire-purchase/process_payment_callback
This filter allows you to change the process_payment() callback, allowing you to use your own order processing function.

Actions

Below is an incomplete list of the most useful actions. See the source code on github for all actions.

lhv/hire-purchase/order-confirmed
This action is triggered when a hire-purchase order is successful.

lhv/hire-purchase/order-rejected-merchant
This action is triggered when a hire-purchase order is rejected because you have disabled manual signature support.

lhv/hire-purchase/order-rejected-bank
This action is triggered when a hire-purchase order is rejected by AS LHV Finance.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×