How to connect WooCommerce with Nummuspay

First of all you have to edit you functions.php file in your theme folder, usually located here: \htdocs\wp-content\themes\storefront\functions.php
Add the following code snipped at the end of the functions.php file and save the file:
	add_action( 'woocommerce_thankyou', 'nummuspay_checkout', 20 );
if (!function_exists( 'nummuspay_checkout' )) {
    function nummuspay_checkout($order_id) {
        if ($order_id > 0) {
            $order = wc_get_order($order_id);
            if ($order instanceof WC_Order) {
                ?>
                <script>$ = jQuery.noConflict(true);</script>
                <script src="https://api.nummuspay.com/Content/js/v1/nummuspay.js"></script>
                <script type="text/javascript">
                    var orderData = <?php echo json_encode($order->get_data()) ?>;
                    Nummuspay.Checkout({
                        merchantUniqueID: orderData.number,
                        publicCheckoutPageID: YOUR_CHECKOUT_PAGE_ID_FROM_NUMMUSPAY,
                        currency: orderData.currency,
                        amount: orderData.total,
                        tax: 0,
                        firstName: orderData.billing.first_name,
                        lastName: orderData.billing.last_name,
                        email: orderData.billing.email,
                        company: orderData.billing.company,
                        phone: orderData.billing.phone,
                        billingAddress1: orderData.billing.address_1,
                        billingAddress2: orderData.billing.address_2,
                        billingCountry: orderData.billing.country,
                        billingState: orderData.billing.state,
                        billingCity: orderData.billing.city,
                        billingZip: orderData.billing.postcode
                    });
                </script>
                <?php
            }
        }
    }
}
The next step will be to go to: WooCommerce > Settings > Payments in order to install a payment method. From this screen enable Check Payments and click on Set up button.

Through this screen you will be able to confiqure your settings: 
  • Enable/Disable – Enable to use. Disable to turn off.
  • Title – Choose the title shown to customers during checkout
  • Description –Add info shown to customers if they choose Check
  • Instructions – Explain how to pay by Check

Please make the proper amendments and save changes.

The next step is to navigate to WooCommerce > Settings > Advanced > REST API > Click "Add key button" in order to create an api key. Choose Read/Write on permissions options and click on "Generate API key"

From this screen you will automatically obtain your credentials:

The next step is to navigate to Nummuspay > Settings > Plugin Settings in order to activate WooCommerce. You have to enter your Woocommerce api credentials and your site url, as well:

Still need help? Contact Us Contact Us