How to Connect an SMM Panel API to WordPress and WooCommerce (2026 Guide)

How to Connect an SMM Panel API to WordPress and WooCommerce (2026 Guide)

Running an SMM store on WordPress is a great way to sell to your own customers, but copying every paid order into a panel by hand is slow and full of mistakes. The fix is to connect WooCommerce directly to your provider's API, so every paid order is sent automatically and its status updates on its own.

This guide shows the full setup in simple steps: how the connection works, how to set up products, and a small, ready-to-use plugin that sends paid orders to the SafeSMM API and syncs their statuses. You don't need to be an expert developer, but you should be comfortable uploading a plugin and editing one setting.

Quick answer: Create a WooCommerce product for each package, save the SafeSMM service ID and package size on the product, ask the customer for their link, and when the order is paid send an add request to https://safesmm.net/api/v2. Then check the order with the status action every few minutes and update the WooCommerce order.


How the Connection Works

  1. The customer picks a package, enters their link and pays.
  2. WooCommerce marks the order as Processing after payment.
  3. Your plugin sends the order to SafeSMM with the service ID, link and quantity.
  4. SafeSMM returns an order ID, which is saved on the WooCommerce order.
  5. Every 10 minutes your site checks the status of open orders.
  6. When everything is delivered, the WooCommerce order is marked Completed. Partial or Canceled orders are put On hold so you can refund the customer.

If you are new to how panels pass orders to each other, start with how SMM panels work. For all API actions and responses, read our SMM panel API guide.


What You Need

RequirementWhy
WordPress with WooCommerceHandles your products, checkout and payments
A SafeSMM account and API keyThe key is on your Account page after you sign up
Balance on SafeSMMAPI orders are charged from your balance
SSL (https) on your siteProtects your customers and payments
A payment gatewaySo orders become Processing automatically after payment

Plugin or Custom Code?

There are paid WordPress plugins made for SMM stores. They are quick to set up, but you depend on the plugin author for updates and fixes. A small custom plugin, like the one below, gives you full control and works with any provider that uses the standard SMM API v2 format. If you have only a few products, the custom route is simple and easy to maintain.


Step 1: Set Up Your Products

Create one simple, virtual product for each package, for example "1,000 Instagram Likes". Then add two custom fields to the product (turn on Custom Fields under Screen Options on the product edit page if you don't see them):

Field nameValueExample
safesmm_serviceThe service ID from the SafeSMM services list22
safesmm_qtyHow many units one package contains1000

Check the service's min and max on the services page so your package size is allowed. If a customer buys 2 packages, the plugin sends 2 × safesmm_qty.


Step 2: Add Your API Key Safely

Never put your API key inside product pages or theme files. Add it to wp-config.php, above the line that says "That's all, stop editing":

define('SAFESMM_KEY', 'your_api_key');

Your key can spend your balance, so treat it like a password.


Step 3: Create the Plugin

Create a file named safesmm-connect.php, paste the four code blocks below into it in order, zip it, and upload it from Plugins → Add New → Upload Plugin. Then activate it.

Part A: Plugin header and API helper

The first line of the file must be the standard PHP opening tag. Paste this part directly below it. It tells WooCommerce the plugin works with its newer order storage (HPOS) and creates one function that talks to the SafeSMM API.

/*
Plugin Name: SafeSMM Connect
Description: Sends paid WooCommerce orders to the SafeSMM API.
*/
// Add your key to wp-config.php: define('SAFESMM_KEY', 'your_api_key');

add_action('before_woocommerce_init', function () {
    if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
        \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
    }
});

function safesmm_api($params) {
    $params['key'] = SAFESMM_KEY;
    $res = wp_remote_post('https://safesmm.net/api/v2', array('body' => $params, 'timeout' => 30));
    if (is_wp_error($res)) return array('no_response' => $res->get_error_message());
    $data = json_decode(wp_remote_retrieve_body($res), true);
    return is_array($data) ? $data : array('no_response' => 'Invalid response');
}

Part B: Ask for the customer's link

This adds a link field on SafeSMM products only, checks that it is a valid URL, and saves it on the order.

// Show a link field on SafeSMM products
add_action('woocommerce_before_add_to_cart_button', function () {
    global $product;
    if (!get_post_meta($product->get_id(), 'safesmm_service', true)) return;
    woocommerce_form_field('safesmm_link', array('type' => 'url', 'label' => 'Your link', 'required' => true));
});

// Check the link before adding to cart
add_filter('woocommerce_add_to_cart_validation', function ($ok, $product_id) {
    if (!get_post_meta($product_id, 'safesmm_service', true)) return $ok;
    $link = isset($_POST['safesmm_link']) ? wp_unslash($_POST['safesmm_link']) : '';
    if (!wp_http_validate_url($link)) {
        wc_add_notice('Please enter a valid link.', 'error');
        return false;
    }
    return $ok;
}, 10, 2);

// Keep the link in the cart and save it on the order
add_filter('woocommerce_add_cart_item_data', function ($data) {
    if (!empty($_POST['safesmm_link'])) {
        $data['safesmm_link'] = esc_url_raw(wp_unslash($_POST['safesmm_link']));
    }
    return $data;
});
add_action('woocommerce_checkout_create_order_line_item', function ($item, $key, $values) {
    if (!empty($values['safesmm_link'])) $item->add_meta_data('Link', $values['safesmm_link']);
}, 10, 3);

Part C: Send the order after payment

When an order becomes Processing, each SafeSMM item is sent once. The plugin saves a "sent" mark before calling the API, so a page refresh or a repeated hook can't create a duplicate order. If SafeSMM clearly refuses the order (for example, not enough balance), the mark is removed so you can retry. If there is no reply at all, it is kept, and you should check your SafeSMM orders before sending again.

// Send each SafeSMM item once the order is paid
add_action('woocommerce_order_status_processing', 'safesmm_send_order');
function safesmm_send_order($order_id) {
    $order = wc_get_order($order_id);
    foreach ($order->get_items() as $item) {
        $pid     = $item->get_product_id();
        $service = get_post_meta($pid, 'safesmm_service', true);
        $pack    = (int) get_post_meta($pid, 'safesmm_qty', true);
        if (!$service || $item->get_meta('_safesmm_sent')) continue;

        $item->update_meta_data('_safesmm_sent', time()); // save first, then send
        $item->save();

        $r = safesmm_api(array(
            'action'   => 'add',
            'service'  => $service,
            'link'     => $item->get_meta('Link'),
            'quantity' => $pack * $item->get_quantity(),
        ));

        if (!empty($r['order'])) {
            $item->update_meta_data('_safesmm_order', $r['order']);
            $order->update_meta_data('_safesmm_active', 'yes');
            $order->add_order_note('SafeSMM order ID: ' . $r['order']);
        } elseif (isset($r['error'])) {
            $item->delete_meta_data('_safesmm_sent'); // refused, safe to retry
            $order->add_order_note('SafeSMM error: ' . $r['error']);
        } else {
            $order->add_order_note('No reply from SafeSMM. Check your SafeSMM orders before sending again.');
        }
        $item->save();
    }
    $order->save();
}

Part D: Sync statuses automatically

Every 10 minutes the plugin checks open orders. When all items are Completed, the WooCommerce order is completed. If an item ends as Partial or Canceled, the order is put On hold with a note showing the remains value, so you can refund your customer for the undelivered part. SafeSMM refunds that part to your balance.

// Check statuses every 10 minutes
add_filter('cron_schedules', function ($s) {
    $s['safesmm_10min'] = array('interval' => 600, 'display' => 'Every 10 minutes');
    return $s;
});
add_action('init', function () {
    if (!wp_next_scheduled('safesmm_sync')) wp_schedule_event(time(), 'safesmm_10min', 'safesmm_sync');
});

add_action('safesmm_sync', function () {
    $orders = wc_get_orders(array('limit' => 50, 'meta_key' => '_safesmm_active', 'meta_value' => 'yes'));
    foreach ($orders as $order) {
        $open = false;
        $problem = false;
        foreach ($order->get_items() as $item) {
            $id = $item->get_meta('_safesmm_order');
            if (!$id) continue;
            $status = $item->get_meta('_safesmm_status');
            if (!in_array($status, array('Completed', 'Partial', 'Canceled'))) {
                $r = safesmm_api(array('action' => 'status', 'order' => $id));
                if (empty($r['status'])) { $open = true; continue; }
                $status = $r['status'];
                $item->update_meta_data('_safesmm_status', $status);
                $item->save();
                if ($status === 'Partial' || $status === 'Canceled') {
                    $order->add_order_note("SafeSMM order $id: $status, remains {$r['remains']}.");
                }
            }
            if ($status === 'Partial' || $status === 'Canceled') $problem = true;
            elseif ($status !== 'Completed') $open = true;
        }
        if ($open) continue;
        $order->delete_meta_data('_safesmm_active');
        if ($problem) $order->update_status('on-hold', 'Refund the undelivered part to your customer.');
        else $order->update_status('completed', 'All SafeSMM orders completed.');
    }
});

WordPress cron runs when someone visits your site. On a quiet site, ask your host to set up a real server cron that loads wp-cron.php every few minutes.


Step 4: Retry a Failed Order

If an order note says "SafeSMM error", fix the cause first (for example, top up your balance or correct the link). Then change the order status to On hold and back to Processing. The plugin only sends items that were not sent before, so completed items are never sent twice.

Order noteWhat to do
SafeSMM order ID: 23501Nothing. It was sent successfully
SafeSMM error: (message)Fix the cause, then set the order On hold and back to Processing
No reply from SafeSMMCheck your SafeSMM orders first. If the order is not there, place it manually
Partial or Canceled, remains XRefund your customer for the undelivered part

Status meanings are explained in SMM panel order status meanings, and slow starts in why an order stays Pending.


Step 5: Set Your Prices

The rate in the SafeSMM services list is the price per 1,000 units. Your cost for a package is rate × package size ÷ 1,000. Add your margin, plus your payment gateway fee, and that is your product price. Prices can change, so re-check rates regularly and update your products. For more on margins, see our SMM reseller business guide.


Step 6: Test Before Going Live

  • Place a small real order on your own site with a cheap service
  • Check that the order note shows a SafeSMM order ID
  • Confirm the same order appears on your SafeSMM orders page
  • Wait for the status sync and check the WooCommerce order is completed
  • Test a wrong link to see the error message
  • Refresh the thank-you page and confirm no second order is created

Need a small balance to test? After you sign up, message @SafeSMM_Admin on Telegram and ask for the $0.10 test balance.


Frequently Asked Questions

Do I need a plugin to connect an SMM panel API to WordPress?

You need some code that talks to the API. That can be a paid SMM plugin or a small custom plugin like the one in this guide.

Does this work with WooCommerce HPOS?

Yes. The code uses WooCommerce order functions instead of direct database queries and declares HPOS compatibility.

Does it work with the block checkout?

Yes. The link is collected on the product page before the item is added to the cart, so it works with both the classic and block checkout.

Can I offer drip-feed orders?

Yes. For drip-feed services, send quantity per run plus runs and interval. Allowed intervals are listed in the SafeSMM API documentation.

What happens if my SafeSMM balance runs out?

The API refuses the order and the plugin adds the error as an order note. Top up, then set the order On hold and back to Processing to resend.


Final Words

Connecting WooCommerce to an SMM panel API turns your WordPress site into a store that works on its own: customers pay, orders are sent, and statuses update without you. Start with a few products, test with small orders, keep your key in wp-config.php, and always check before resending an order with no reply.

Ready to build your store? Create your free SafeSMM account, read the API documentation, and see what we offer resellers on our SMM reseller panel page.

More guides for resellers
Popular SafeSMM guides