Cratejoy is home to 1000s of monthly subscription boxes and crate clubs for all passions. Find curated gift boxes for all occasions and recipients, or learn how to start your own subscription box!

Cratejoy integration consists of adding integration code to thank you page and setting up API connection with Post Affiliate Pro (Network) to track the subscription payments.


Insert integration code to thank you page

Log in to your Cratejoy admin panel and navigate to the Design section and click on the Code button under your currently published design.
Select the option to edit the live store and navigate to components -> customer -> thank_you -> Customer Thank You Content and component.html.
Insert the following code at the end of this file:

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
  var papDiscountMultiplier = {{order.total_price}} / ({{order.sub_total}} - {{order.total_shipping}});
  {% for product in order.products %}
    var sale{{ loop.index }} = PostAffTracker.createSale();
    var papProductPrice = {{product.price}} * papDiscountMultiplier;
    sale{{ loop.index }}.setTotalCost((papProductPrice)/ 100);
   	if('{{product.subscription_id}}' != 'None') {
      sale{{ loop.index }}.setOrderID('{{product.subscription_id}}');
    } else {
      sale{{ loop.index }}.setOrderID('{{}}({{ loop.index }})');
    sale{{ loop.index }}.setProductID('{{product.instance.sku}}');
  {% endfor %}

Save your changes.


Set up API credentials and configure PAP plugin

In your Cratejoy admin panel navigate to Settings -> API and select the option to Generate a new Key.
This will open a new window with Client ID and Client Secret Key, copy both and navigate to your Post Affiliate Pro (Network) merchant panel to Configuration -> Plugins and activate the Cratejoy webhook handling plugin.
Once the plugin is activated click Configure and enter your API details. Save the plugin to start tracking the recurring payments.

Note: The plugin requires either the Recurring Commissions feature or Lifetime Commissions plugin to be able to track the recurring payments.