Need to integrate SamCart with your own application or create a custom integration with your website? SamCart's Notify URL gives you the ability to do exactly that.

Below, we'll break down how to use the Notify URL in tandem with SamCart's Integration Engine to create rules allowing you to automate the management of your SamCart customers with your desired endpoint. 

Connecting Your Notify URL to the Integration Engine

Start by clicking over to your Marketplace Settings and, on the left-hand side of your screen, selecting Integrations

Here, under the Integration Setup tab, you'll see a list of all your active integrations that are connected via the Integration Engine. To add a new Notify URL integration, click the New Integration button: 

Clicking New Integration will prompt a box to appear which will walk you through the steps required to complete the integration. Select Notify URL (1) and click Next Step (2):

SamCart will ask you to name the integration (1). This is just an internal label, and can be anything you'd like as long as it doesn't already appear in your Integrations list. 

Next, enter the Notify URL (endpoint) that would like SamCart to send an HTTP POST. Make sure you include "https://" (2). 

Lastly, click Save Changes (3):

Once the Notify URL is successfully integrated, it will appear in the Integration Setup tab. 

Now we're ready to create some Integration Rules to dictate what to send to your Notify URL and when! Below, we'll go over the two types of Integration Rules in SamCart. 

Creating Integration Rules at the Product Level: 

Now that SamCart is "connected" to your Notify URL, you'll need to establish simple rules that tell the Integration Engine to send an HTTP POST to your Notify URL when certain actions takes place in your SamCart Marketplace. 

Head over to your Product and click into the Integrations tab (1), then click New Rule (2)

First, you'll need to select a trigger. A trigger is the event inside of your SamCart Marketplace that tells the Integration Engine it's time to send an HTTP POST to your Notify URL. In this example, we'll use the Product Purchased trigger as it's the most common. 

Select Product Purchased (1) from the drop-down menu and click Next Step (2):

In the following window, we'll establish the specific action we want the rule to perform. First, select the desired Integration (1) in the first drop-down menu. Your integrations will be sorted using the internal label you chose when you connected the application. 

Next, choose an Action (2) you'd like the integration to perform. In this example, we're choosing Send Notify URL POST, which sends an HTTP POST to your Notify URL. When you're done, click Next Step (3).

And that's it! Click Submit and SamCart will send an HTTP POST to your Notify URL each time your Product is purchased. 

Available Integration Triggers: 

Product Purchased isn't the only SamCart event that can trigger an HTTP POST. Here's the full list: 

  • Product Purchased
  • Product Refunded
  • Subscription Canceled
  • Subscription Delinquent
  • Subscription Recovered
  • Subscription Recovered
  • Subscription Restarted
  • Subscription Charged
  • Subscription Charge Failed
  • Order Completed
  • Upsell Purchased

Creating Global Integration Rules:

Global Rules aren't too different from Product-Level Integration Rules, except for the fact that they're triggered by every Product in your Marketplace. For example, if you'd like to send an HTTP POST to your Notify URL whenever a customer purchases any of your SamCart Products, you'd want to create a Global Product Purchased Rule.

To create a Global Rule in SamCart, head back to your Marketplace's Integration Settings

Here, click on the Global Rules tab (1) and select New Rule (2):

Once you've done that, the steps to creating a Global Rule are identical to that of a Product-Level Integration Rule. Reference the "Creating Integration Rules at the Product Level:" section above for a detailed breakdown on how to proceed. 

After your Global Rule is created, it will appear under the Global Rules tab: 

Data Payload

Here's a sample JSON sent to the notification URL looks like:

{   
"type":"Order",
    "api_key":null,

    "product": {
          "id": 10,
          "name": "Test",
          "price": 25
    },

    "customer": {
          "first_name": "Brian",
          "last_name": "Moran",
          "email": "bri@samcart.com",
          "phone_number": "5551235555",
          "billing_address": "10000 Maple Lawn Blvd",
          "billing_city": "Fulton",
          "billing_state": "Maryland",
          "billing_zip": "21044",
          "billing_country": "USA"
    },

    "order": {
          "id": 12412041,
          "total": 25,
          "shipping_address": null,
          "shipping_city": null,
          "shipping_state": null,
          "shipping_zip": null,
          "shipping_country": null,
          "ip_address": "192.168.56.1",
          "stripe_id": 66,
          "subscription_id": 55,
          "custom_fields": {
               "name": "shirt size",
               "slug": "shirt-size",
               "value": "medium"
    },

    "affiliate": {
          "id": null,
          "token": null
    }

}

Values that don’t exist (in this case, shipping address) are represented as NULL values.

Additional event payloads

Less information is passed for the following events:

  • Refund
  • Cancel
  • RecurringPaymentFailed
  • RecurringPaymentRecovered
  • RecurringPaymentSucceeded
  • Custom Field Data
{   
"type":"<eventType>",
    "api_key":"<key>",

    "product": {
          "id": 10,
          "name": "Test",
          "price": 25
    },

    "customer": {
          "first_name": "Brian",
          "last_name": “Moran",
          "email": "bri@samcart.com",
          "phone_number": "5551235555",
    },

    "order": {
          "id": 12412041,
          "total": 25,
          "ip_address": "192.168.56.1"
    }

}

Example PHP code for using this would be:

<?php 
  $inputData = json_decode(file_get_contents('php://input'));
  $firstName = $inputData->{'customer'}->{'first_name'};
  $lastName = $inputData->{'customer'}->{'last_name'};
  $customerName = $firstName . ' ' . $lastName; echo $customerName;
?>

FAQ: 

Q: My integration seems to be functioning properly, but HTTP POST isn't firing seemingly at random. What happened? 

A: If an integration rule fails to fire, there's always a reason. The Integration Engine keeps a record of the last 1,000 integration events that took place in your Marketplace, and they can be viewed by heading to Marketplace Settings > Integrations > Logs.

Here, you can search for the event in question and check if anything went wrong. 99% of the time the Logs can provide insight into exactly what might've went wrong with that action. 

Q: How can I delete, re-name, or refresh my integration if I made some changes to my Notify URL? 

A: Head to Marketplace Settings > Integrations and click the Edit, Refresh, or Delete buttons to make these changes to your integration: 

Q: Can I have multiple Notify URL's for my Marketplace/Product?

A: You can indeed! 

Did this answer your question?