MoonClerk

Recurring Payments and One Time Payments Online.

Integration with MoonClerk works only if you use MoonClerk with Stripe and only if you use a link to their checkout or embedded checkout.

1.

Linked Checkout integration

In case you are using the links to MoonClerk checkout, so called Linked Checkout, please follow this step and the last one about plugin and webhook setup.
Essentially what you need to do with this type of set up is to add the following code below all your MoonClerk links so the best is to add it somewhere to your website's footer template so it is on all your website's pages and it integrates all the MoonClerk links on all pages of your website.

<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
var MoonClerkLinks = document.querySelectorAll('a[href*="moonclerk.com/pay/"]');
for (i=0; i < MoonClerkLinks.length; i++) {
    MoonClerkLinks[i].id = 'appendTrackingCookie';
}
PostAffTracker.setAccountId('Account_ID');
try {
PostAffTracker.track();
} catch (err) { }
PostAffTracker.writeCookieToLink('appendTrackingCookie', 'cid');
</script>

2.

Embedded Checkout

In case you are using the MoonClerk's Embedded Checkout the integration is a bit complicated because their code needs to be heavily amended. Below is how the integrated code would look like. In the code you need to make sure to add your own checkoutToken and moonclerk URLs:

<script type="text/javascript" src="https://d2l7e0y6ygya2s.cloudfront.net/assets/embed.js"></script>
<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<div id="mc5hj004gabje1">
    <a id="appendTrackingCookie" href="https://app.moonclerk.com/pay/5hj004gabje1">Easy Time</a>
</div>
<script type="text/javascript">
var papCookieId = '',
    mc5hj004gabje1;
if (typeof PostAffTracker !== 'undefined') {
    PostAffTracker.setAccountId('Account_ID');
    try {
        PostAffTracker.track();
    } catch (err) { }
    PostAffTracker.writeCookieToLink('appendTrackingCookie', 'cid');
    PostAffTracker.executeOnResponceFinished.push(function() {
        papCookieId = PostAffTracker._getAccountId() + PostAffTracker._cmanager.getVisitorIdOrSaleCookieValue();
        renderMoonClerkCheckout();
    });
} else {
    renderMoonClerkCheckout();
}

function renderMoonClerkCheckout() {
    var opts = {
        "checkoutToken": "5hj004gabje1",
        "width": "100%",
        "cid": papCookieId
    };
    mc5hj004gabje1 = new MoonclerkEmbed(opts);
    mc5hj004gabje1.display();
}
</script>

3.

Plugin and Stripe setup

Log in to your Stripe account and go to Webhooks settings section of the Stripe Dashboard. Clicking Add endpoint reveals a form to add a new URL for receiving webhooks. Enter this URL there for a live notifications:
http://URL_TO_PostAffiliatePro/plugins/Moonclerk/moonclerk.php?accountid=Account_ID
Once the webhook is set up go grab your Stripe's secret API key and copy it. Now navigate to your Post Affiliate Pro merchant panel and to Configuration -> Plugins where you want to activate the Moonclerk webhook handling (Stripe). Once the plugin is activated click on Configure next to it and enter your Stripe's secret API key. Save the plugin configuration and the integration is done.