SureCart – Checkout Confirmed Payload

Tech Articles | May 16, 2025 | Automation, Bubble, Coding, SureCart, Wordpress

In this really short article to accompany a video, I will briefly discuss surecart/checkout_confirmed as an action hook and the payload it can deliver.

This is the main fired hook in Surecart for a purchase, as it is fired every time there is a purchase in the article and the video. We are going to do two things:

  • Output the checkout payload to our error log
  • Look through the payload to see if we can match a Price ID

From here, you could add membership levels, trigger a webhook or any number of different solutions.

You can read more about action hooks here in the documentation

Lets log our payload

This is easy, we want to call a function when surecart/checkout_confirmed is triggered and dumps it to our error log.

// Use the correct hook name:
add_action( 'surecart/checkout_confirmed', 'sc_log_checkout_and_check_price', 10, 1 );

function sc_log_checkout_and_check_price( $checkout_payload ) {
    // 1) Log the full payload
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        error_log( 'SureCart Checkout Payload: ' . print_r( $checkout_payload, true ) );
    }
}
PHP

This will give us a payload in our error log

SureCart Checkout Payload: SureCart\Models\Checkout Object ( [attributes:protected] => Array ( [email] => automation@wpcode.dev [customer] => SureCart\Models\Customer Object ( [attributes:protected] => Array ( [id] => 118337bd-2b02-4fa7-ad35-33207baeb9a4 [object] => customer [affiliation_expires_at] => [billing_matches_shipping] => 1 [email] => automation@wpcode.dev [first_name] => TD-Support [indexed] => 1 [last_name] => [live_mode] => [name] => TD-Support [phone] => [unsubscribed] => [tax_enabled] => 1 [portal_url] => https://app.surecart.com/portal_redirect/customers/118337bd-2b02-4fa7-ad35-33207baeb9a4 [affiliation] => [billing_address] => stdClass Object ( ) [default_payment_method] => 28742610-cd8d-4ad7-925d-5c83559c034b [shipping_address] => stdClass Object ( [id] => c8e386d0-29d5-40c4-a3c8-17160de21473 [object] => address [city] => xx [country] => GB [line_1] => xxxx [line_2] => [name] => [postal_code] => ccccc [state] => ANN [created_at] => 1747120023 [updated_at] => 1747120023 ) [tax_identifier] => [created_at] => 1745477541 [updated_at] => 1747120023 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => customers [object_name:protected] => customer [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) [id] => a3bb731a-abfb-433f-8d06-bf1c4418c59a [object] => checkout [abandoned_checkout_enabled] => 1 [amount_due] => 100 [applied_balance_amount] => 0 [available_countries] => Array ( ) [billing_matches_shipping] => 1 [credited_balance_amount] => 0 [currency] => usd [discount_amount] => 0 [external_url] => https://wpautomation.dev/surecart/redirect [first_name] => TD-Support [free_shipping_choice_shortage_amount] => [full_amount] => 100 [group_key] => sc-checkout-96 [inherited_email] => automation@wpcode.dev [inherited_name] => TD-Support [inherited_phone] => [ip_address] => 2a02:c7c:dd62:3100:4d23:a78e:f0c0:3d6e [last_name] => [live_mode] => [manual_payment] => [metadata] => stdClass Object ( [page_id] => 97 [page_url] => https://wpautomation.dev/checkout-2/ [wp_created_by] => 1 ) [name] => TD-Support [net_paid_amount] => 100 [paid_amount] => 100 [g_weight] => 0 [paid_at] => 1747327426 [payment_method_required] => [portal_url] => https://app.surecart.com/portal_redirect/checkouts/a3bb731a-abfb-433f-8d06-bf1c4418c59a [phone] => [proration_amount] => 0 [refunded_amount] => 0 [remaining_amount_due] => 0 [reusable_payment_method_required] => [selected_shipping_choice_required] => [shipping_address_accuracy_requirement] => none [shipping_amount] => 0 [shipping_enabled] => [shipping_tax_amount] => 0 [shipping_tax_rate] => 0 [status] => paid [subtotal_amount] => 100 [tax_amount] => 0 [tax_behavior] => exclusive [tax_breakdown] => Array ( ) [tax_enabled] => [tax_label] => [tax_status] => disabled [total_amount] => 100 [total_savings_amount] => 0 [trial_amount] => 0 [upsells_expire_at] => 1747329226 [billing_address] => stdClass Object ( ) [current_payment_intent] => da8a8306-beec-434a-b20c-4d51bcabfdc6 [last_click] => [discount] => [line_items] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 1 [limit] => 50 [page] => 1 [url] => /v1/line_items?checkout_ids%5B%5D=a3bb731a-abfb-433f-8d06-bf1c4418c59a ) [data] => Array ( [0] => SureCart\Models\LineItem Object ( [attributes:protected] => Array ( [id] => 13caf78c-bbdf-4af9-96b4-42a760d8aaf8 [object] => line_item [ad_hoc_amount] => [discount_amount] => 0 [fees_amount] => 0 [full_amount] => 100 [fulfilled_quantity] => 1 [locked] => [purchasable_status] => purchasable [quantity] => 1 [g_weight] => 0 [unit_g_weight] => 0 [scratch_amount] => 100 [stock_held] => 1 [subtotal_amount] => 100 [tax_amount] => 0 [tax_rate] => 0 [total_amount] => 100 [total_savings_amount] => 0 [trial] => [trial_amount] => 0 [variant_options] => [variant_option_names] => [bump] => [checkout] => a3bb731a-abfb-433f-8d06-bf1c4418c59a [fees] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 20 [page] => 1 [url] => /v1/fees?line_item_ids%5B%5D=13caf78c-bbdf-4af9-96b4-42a760d8aaf8 ) [data] => Array ( ) ) [price] => SureCart\Models\Price Object ( [attributes:protected] => Array ( [id] => 5fd6a72e-83de-48dd-95ef-f704124d2b74 [object] => price [ad_hoc] => [ad_hoc_max_amount] => [ad_hoc_min_amount] => 0 [amount] => 100 [archived] => [archived_at] => [currency] => usd [current_version] => 1 [full_amount] => 100 [license_activation_limit] => [metadata] => stdClass Object ( ) [name] => Standard [position] => 0 [portal_subscription_update_enabled] => 1 [revoke_after_days] => [revoke_purchases_on_completed] => [recurring_interval] => [recurring_interval_count] => [recurring_period_count] => [scratch_amount] => [setup_fee_amount] => 0 [setup_fee_enabled] => [setup_fee_trial_enabled] => 1 [setup_fee_name] => [trial_duration_days] => [product] => SureCart\Models\Product Object ( [attributes:protected] => Array ( [id] => f5ac67b2-6c03-433e-ac14-701ef8675e01 [object] => product [allow_out_of_stock_purchases] => [archived] => [archived_at] => [auto_fulfill_enabled] => 1 [available_stock] => 32 [description] =>
These are event tickets

[held_stock] => 0 [featured] => [licensing_enabled] => [license_activation_limit] => [metadata] => stdClass Object ( ) [purchase_limit] => [metrics] => stdClass Object ( [currency] => usd [max_price_amount] => 100 [min_price_amount] => 100 [prices_count] => 1 ) [name] => Event Tickets [recurring] => [shipping_enabled] => [sku] => [slug] => event-tickets [status] => published [stock] => 32 [stock_enabled] => 1 [tax_enabled] => 1 [tax_category] => tangible [weight] => 0 [weight_unit] => lb [commission_structure] => SureCart\Models\CommissionStructure Object ( [attributes:protected] => Array ( ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => commission_structures [object_name:protected] => commission_structure [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) [product_group] => [current_release_download] => [product_medias] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 20 [page] => 1 [url] => /v1/product_medias?product_ids%5B%5D=f5ac67b2-6c03-433e-ac14-701ef8675e01 ) [data] => Array ( ) ) [shipping_profile] => fb5c4f97-0da5-46a4-addc-746954380d9a [cataloged_at] => 1739808384 [discarded_at] => [product_collections] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 20 [page] => 1 [url] => /v1/product_collections?product_ids%5B%5D=f5ac67b2-6c03-433e-ac14-701ef8675e01 ) [data] => Array ( ) ) [variants] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 250 [page] => 1 [url] => /v1/variants?product_ids%5B%5D=f5ac67b2-6c03-433e-ac14-701ef8675e01 ) [data] => Array ( ) ) [image_url] => [created_at] => 1739808384 [updated_at] => 1747327426 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => products [object_name:protected] => product [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => 1 [cache_key:protected] => products [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => [sync_expands:protected] => Array ( [0] => prices [1] => product_medias [2] => product_media.media [3] => variants [4] => variant_options [5] => product_collections [6] => featured_product_media ) [image_sizes:protected] => Array ( [0] => 320 [1] => 640 [2] => 960 [3] => 1280 [4] => 1920 ) [resize_options:protected] => Array ( [0] => fit=scale-down [1] => format=auto ) ) [renewal_price] => [discarded_at] => [recurring_end_behavior] => complete [created_at] => 1739808407 [updated_at] => 1739808407 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => prices [object_name:protected] => price [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => 1 [cache_key:protected] => products [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) [upsell] => [bump_amount] => [created_at] => 1747327421 [updated_at] => 1747327426 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => line_items [object_name:protected] => line_item [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) ) ) [manual_payment_method] => [order] => d4875880-7883-4acc-b897-e783119f9c8c [payment_method] => 28742610-cd8d-4ad7-925d-5c83559c034b [inherited_billing_address] => c8e386d0-29d5-40c4-a3c8-17160de21473 [inherited_shipping_address] => c8e386d0-29d5-40c4-a3c8-17160de21473 [inherited_tax_identifier] => [purchases] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 1 [limit] => 20 [page] => 1 [url] => /v1/purchases?checkout_ids%5B%5D=a3bb731a-abfb-433f-8d06-bf1c4418c59a ) [data] => Array ( [0] => SureCart\Models\Purchase Object ( [attributes:protected] => Array ( [id] => ccc38fa8-de8e-4c09-a026-6d121361a806 [object] => purchase [live_mode] => [quantity] => 1 [revoked] => [revoked_at] => [revoke_at] => [customer] => 118337bd-2b02-4fa7-ad35-33207baeb9a4 [initial_order] => d4875880-7883-4acc-b897-e783119f9c8c [price] => 5fd6a72e-83de-48dd-95ef-f704124d2b74 [product] => f5ac67b2-6c03-433e-ac14-701ef8675e01 [variant] => [created_at] => 1747327426 [updated_at] => 1747327426 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => purchases [object_name:protected] => purchase [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) ) ) [recommended_bumps] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 10 [page] => 1 [url] => /v1/bumps?checkout_ids%5B%5D=a3bb731a-abfb-433f-8d06-bf1c4418c59a ) [data] => Array ( ) ) [referral] => [shipping_address] => stdClass Object ( ) [tax_identifier] => [selected_shipping_choice] => [shipping_choices] => stdClass Object ( [object] => list [pagination] => stdClass Object ( [count] => 0 [limit] => 20 [page] => 1 [url] => /v1/shipping_choices?checkout_ids%5B%5D=a3bb731a-abfb-433f-8d06-bf1c4418c59a ) [data] => Array ( ) ) [bump_amount] => 0 [number] => TEST-0222 [pdf_url] => https://app.surecart.com/statements/orders/d4875880-7883-4acc-b897-e783119f9c8c [payment_intent] => SureCart\Models\PaymentIntent Object ( [attributes:protected] => Array ( [id] => da8a8306-beec-434a-b20c-4d51bcabfdc6 [object] => payment_intent [amount] => 100 [currency] => usd [external_intent_id] => [live_mode] => [off_session] => [processor_data] => stdClass Object ( [mock] => stdClass Object ( ) ) [processor_type] => mock [reusable] => [status] => succeeded [checkout] => a3bb731a-abfb-433f-8d06-bf1c4418c59a [customer] => 118337bd-2b02-4fa7-ad35-33207baeb9a4 [payment_method] => 28742610-cd8d-4ad7-925d-5c83559c034b [service_fee] => [created_at] => 1747327426 [updated_at] => 1747327426 ) [defaults:protected] => Array ( ) [original:protected] => Array ( ) [endpoint:protected] => payment_intents [object_name:protected] => payment_intent [query:protected] => Array ( ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => [clears_account_cache:protected] => ) [charge] => fbf5ceb7-f181-495a-89b5-284a84d51fff [shipping_address_required] => [tax_rate] => 0 [tax_percent] => 0 [tax_exclusive_amount] => 0 [tax_inclusive_amount] => 0 [return_url] => https://wpautomation.dev/surecart/redirect [created_at] => 1747327421 [updated_at] => 1747327426 ) [defaults:protected] => Array ( ) [original:protected] => Array ( [email] => automation@wpcode.dev [customer] => 118337bd-2b02-4fa7-ad35-33207baeb9a4 ) [endpoint:protected] => checkouts [object_name:protected] => checkout [query:protected] => Array ( [expand] => Array ( [0] => purchases [1] => customer [2] => manual_payment_method [3] => line_items [4] => line_item.price [5] => line_item.fees [6] => line_item.variant [7] => line_item.swap [8] => variant.image [9] => price.product [10] => price.current_swap [11] => swap.swap_price [12] => product.product_medias [13] => product.featured_product_media [14] => product.product_collections [15] => product_media.media [16] => customer [17] => customer.shipping_address [18] => payment_intent [19] => discount [20] => discount.promotion [21] => recommended_bumps [22] => bump.price [23] => current_upsell [24] => product.variants [25] => discount.coupon [26] => shipping_address [27] => billing_address [28] => tax_identifier [29] => manual_payment_method [30] => shipping_choices [31] => shipping_choice.shipping_method [32] => invoice ) [t] => 1747327426848 [_locale] => user [refresh_status] => 1 ) [relations:protected] => Array ( ) [fillable:protected] => Array ( [0] => * ) [guarded:protected] => Array ( ) [limit:protected] => 20 [offset:protected] => 0 [cachable:protected] => [cache_key:protected] => [optimized_caching:protected] => [cache_status:protected] => none [clears_account_cache:protected] => [processor_type:protected] => )

That is a full payload, and in that payload, you will see in bold and underlined price] => 5fd6a72e-83de-48dd-95ef-f704124d2b74 This is actually our price ID, and this is what we now want to target.

Lets put it all together

So now we need to look fr our price, id match it and if its there output a message and do the same if its not from here we can expand and add if its there or not there actions such as triggering our webhooks.

<?php
add_action( 'surecart/checkout_confirmed', 'sc_log_checkout_and_check_price', 10, 1 );

function sc_log_checkout_and_check_price( $checkout_payload ) {
    // 1) Log the full payload
    if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
        error_log( 'SureCart Checkout Payload: ' . print_r( $checkout_payload, true ) );
    }

    // 2) Set your target Price ID
    $target_price_id = '';

    // 3) Pull out the purchases list:
    $found = false;
    if ( isset( $checkout_payload->purchases )
      && isset( $checkout_payload->purchases->data )
      && is_array( $checkout_payload->purchases->data )
    ) {
        foreach ( $checkout_payload->purchases->data as $purchase ) {
            // Each $purchase is a SureCart\Models\Purchase object
            // It has a 'price' attribute containing the purchased price ID
            if ( isset( $purchase->price )
              && $purchase->price === $target_price_id
            ) {
                $found = true;
                break;
            }
        }
    }

    // 4) Log the result
    if ( $found ) {
        error_log( "Price ID {$target_price_id} was successfully purchased." );
    } else {
        error_log( "Price ID {$target_price_id} was NOT purchased in this checkout." );
    }
}

PHP

when that runs we get the following if we purchase the correct product

Surecart checkout confirmed priceid

Support the Author

buy me a coffee
Really Useful Plugin Logo
Wpvideobank temp
Appoligies for any spelling and grammer issue. As a dyslexic i need to rely on tools for this they like me are not perfect but I do try my best