https://github.com/karser/affiliates-api
Rest API for Itthinx Affiliate WordPress Plugin
https://github.com/karser/affiliates-api
affiliate affiliate-program referral referral-program wordpress-plugin
Last synced: about 1 year ago
JSON representation
Rest API for Itthinx Affiliate WordPress Plugin
- Host: GitHub
- URL: https://github.com/karser/affiliates-api
- Owner: karser
- Created: 2020-10-22T13:41:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-22T14:05:39.000Z (over 5 years ago)
- Last Synced: 2025-02-14T04:47:57.839Z (over 1 year ago)
- Topics: affiliate, affiliate-program, referral, referral-program, wordpress-plugin
- Language: PHP
- Homepage:
- Size: 1.95 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rest API for Itthinx Affiliate WordPress Plugin
## How it works:
### 1. Define the api key in wp-config.php
```
if ( !defined('AFFILIATE_WP_API_KEY') ) {
define('AFFILIATE_WP_API_KEY', 'define-your-api-key-here');
}
```
### 2. Save the hit hash and referrer id from cookie during registration
This may happen when the user submits the registration form so this code checks for the affiliate cookies and sends them back to the server along with the registration data
```
function getRefTrackingId(): string {
const affId = CookieStorage.getItem('wp_affiliates');
const hit = CookieStorage.getItem('_h_affiliates');
if (isDefined(affId) && isDefined(hit)) {
return `${affId}|${hit}`;
}
return null;
}
```
### 3. Submit a purchase back to the plugin
```
POST /wp-json/affiliates-api/referrals HTTP/1.1
Host: your-host.com
Content-Type: application/json
X-Api-Key: your-key
{
"email":"joe@email.com",
"baseAmount":"100",
"currency":"USD",
"refId":"5",
"date":"2012-01-01T10:01:01Z",
"hit":"c096876aa6517e2c6d5198efa6a4037532dc1f97959963689c8b6bf3bba17c2f",
"reference":"txn_16A3XQSE2ez0wdde",
"ip":"158.217.93.151"
}
```
## Troubleshooting
### Share cookie between subdomain and domain
if the wordpress and your app are on different subdomains
(e.g your-domain.com and app.your-domain.com)
try adding a leading dot to the cookie settings:
```
define( 'COOKIE_DOMAIN', '.your-domain.com' );
```