Partner
A suite of APIs that powers commerce for businesses of all sizes.
Stripe makes it easy to start accepting credit cards on the web today. The integration method uses our built in plugin for notification handling.
The integration handles orders, recurring orders and refunds as well. It also supports lifetime commissions and coupon handling.
Cookie data – order form
Each customer account in stripe has an extra field called ‘description‘. In this integration method, we are using it. The task is to add the (tracking) cookie value into the description field found in your order form. The easiest way is to add this code to your payment form:
<input type="hidden" name="pap_custom" value="" id="pap_tdx8v2s5a" />
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
PostAffTracker.writeCookieToCustomField('pap_tdx8v2s5a');
</script>
When the form is submitted (customer is ordering), you can process the form data the standard way and before creating a charge and a customer account (with Stripe_Customer::create), you have to use the pap_custom data from the submitted form and set the value as a customer description – “description” => $_POST[‘pap_custom’].
Cookie data – Stripe Checkout
If you are using the Stripe Checkout then instead of the step above you need to do this one. Essentially, what needs to be done is to add a tracking cookie value into the client-reference-id variable of Stripe’s session object. Take a look here on how to get the tracking cookie value (visitor ID).
Here is an example of a Stripe Checkout button:
<script async src="https://js.stripe.com/v3/buy-button.js">
</script>
<stripe-buy-button
buy-button-id="buy_btn_BBBBBBBBBBBBBB"
publishable-key="pk_test_XXXXXXXXXXXXXXXXXXX"
>
</stripe-buy-button>
This is how an integrated buttons would look like (the stripe button code gets added using JavaScript now):
<script async src="https://js.stripe.com/v3/buy-button.js">
</script>
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
var papCookie = '';
PostAffTracker.setAccountId('Account_ID');
try {
PostAffTracker.track();
} catch (err) { }
papCookie = PostAffTracker._getAccountId() + PostAffTracker._cmanager.getVisitorIdOrSaleCookieValue();
document.write('<stripe-buy-button buy-button-id="buy_btn_BBBBBBBBBBBBBB" publishable-key="pk_test_XXXXXXXXXXXXXXXXXXX" client-reference-id="' + papCookie + '"></stripe-buy-button>');
</script>
Cookie data – Stripe payment links
If you are using Stripe payment links then you need to pass the tracking cookie value as client_reference_id
query string parameter to the link. To be able to do that you need to assign an ID to the <a> link element, so for example you’d assign “papCookie” as the link ID so it would be:
<a id="papCookie" href="https://buy.stripe.com/2wM8yP31J6vF6wodQZ">Pay now</a>
Once you have the ID you need to execute the PostAffTracker.writeCookieToLink(‘papCookie‘, ‘client_reference_id
‘); function of the click tracking code with the link’s ID (in our example papCookie) and the name of the query string parameter which should be added (client_reference_id
), so for example like this:
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
try {
PostAffTracker.setAccountId('Account_ID');
PostAffTracker.track();
PostAffTracker.writeCookieToLink('papCookie', 'client_reference_id');
} catch (err) { }
</script>
Another category of Stripe payment tools are Stripe pricing tables. It supports the use of client-reference-id so the integration of it is possible as well.
Sale tracking
The sale tracking will happen automatically, both for standard and for recurring charges. The last step is to set your Stripe to inform your Post Affiliate Pro about each charge. This is done by Stripe webhooks.
To set a webhook navigate to Developers menu section (top right) and then navigate to Webhooks. Clicking Add endpoint reveals a form to add a new URL for receiving webhooks. Enter this URL there for live notifications:
https://URL_TO_PostAffiliatePro/plugins/Stripe/stripe.php?AccountId=Account_ID
In case of events to listen to you can add invoice.payment_succeeded, charge.succeeded and charge.refunded. If you are using Stripe Checkout or Stripe payment links then you will also need checkout.session.completed event.
If you wish to track test payments as well set up the same webhook in the test mode too.
Plugin activation
The last step is to activate the built-in plugin in your Post Affiliate Pro. Do not forget to configure it after activation by adding the Secret API key or a Restricted API key. In case you’d like to use a Restricted API key you need to allow read access for these resources: Charges, Subscriptions, Checkout Sessions, Customers and Invoices.
That’s it, you are done. All the transactions will now be tracked.
Do not forget to integrate your site with the click tracking code to make it all working.
Set up the PayWhirl integration with Post Affiliate Pro by installing the Custom Tracking Scripts app and creating a webhook for account events charge.succeeded and charge.refunded. Activate the PayWhirl webhook handling plugin in your Post Affiliate Pro account and configure it according to your preferences. Integrate your site with the click tracking code for complete functionality.
You can integrate Netsuite's business software suite for better management or start with one module and add functionality as needed. Use tracking codes and custom scripts to track sales and orders. Different integration methods and codes are provided based on the version and features you want to use.