Referral API
Last updated
Last updated
This API enables you, to send traffic to investhub.io and receive a commission for each subscription done via your referrals.
Each of our Tenants need to whitelist your Domain, this is important so that each Tenant can decide which Referral Partners they want to work with.
API Endpoints (ONLY AVAILABLE IF referral source is activated)
All available endpoints for referrals, make sure to whitelist URL first in Settings
Following endpoints are available:
Endpoint for registration is https://kyc.yourdomain.com/sales/user?origin=https://kyc.yourdomain.com
(?origin=https://kyc.yourdomain.com
is also needed, for our routing purposes)
Please change the host name (kyc.yourdomain.com
) and origin (https://kyc.yourdomain.com
) to your tenant like:
https://yourname-dev.investhub.io/sales/user?origin=https://yourname-dev.investhub.io/
You need to send a POST request with content type of application/json containing the following fields:
{"firstName": [first name],"lastName": [last name],"email: [email],"password": [password, hashed with bcrypt],"token_invest_amount": [number],"middleName": [middle name]}
Example:
{"firstName": "test","lastName": "test","token_invest_amount": 500,"middleName": "test","email": "test@gmail.com","password": "$2b$13$HDRwk3FfnKLiPoV8SlEpoeoexIAhx3wH.rzDMlstenBnFaWfa1wmy"}
The response will be also in JSON format, with the following fields:
{"success": [boolean], "redirect_url": [string]}
redirect_url
is url to redirect the user. after the redirect, the user will be automatically authenticated at KYC tenant
in case of error: {“success”: false,“error”: [description of the error]}
Example of successful registration: {“success”: true,“redirect_url”: “https://kyc.yourdomain.com/salesLogin?first_auth_token=eoexIAhx3wH”}
Login auth1. Generate auth_token:
- Post request to
https://kyc.yourdomain.com/sales/generate-user-auth-token?origin=https://kyc.yourdomain.com
with body params with email & password (password format like the Endpoint for registration)
example: {"email": "aaa.test.4@investhub.io", "password": "$2b$13$YeGFwoZ3KMaL7AmS/Dl/peXXdf7bOAkcp0FFriAjFoYJG0iMOrgpe"}
CURL example:
curl --location --request POST 'https://kyc.yourdomain.com/sales/generate-user-auth-token?origin=https://kyc.yourdomain.com' \--header 'Content-Type: application/json' \--header 'Cookie: __cfduid=dda0b0fed26c194b28ed84793e3ef93611602681187' \--data-raw '{ "email": "aaa.test.4@investhub.io", "password": "$2b$13$YeGFwoZ3KMaL7AmS/Dl/peXXdf7bOAkcp0FFriAjFoYJG0iMOrgpe"}'
Then you will receive a response with auth_token
, and the redirect_url
link, this link when you access, it will automatically login into KYC platform.
{"success": true, "auth_token": "xben1ikulllpud9xq7twxizy4dajb7jg", "redirect_url": "https://kyc.yourdomain.com/salesAuthTokenLogin?auth_token=xben1ikulllpud9xq7twxizy4dajb7jg"}
When your session end, you can call this api to destroy auth_token:
- Post request to https://kyc.yourdomain.com/sales/destroy-user-auth-token?origin=https://dev-kyc.yourdomain.com
with body params with email
& the auth_token
(in this case it will be "xben1ikulllpud9xq7twxizy4dajb7jg"
)
CURL example:
curl --location --request POST 'https://kyc.yourdomain.com/sales/destroy-user-auth-token?origin=https://kyc.yourdomain.com' \--header 'Content-Type: application/json' \--header 'Cookie: __cfduid=dda0b0fed26c194b28ed84793e3ef93611602681187' \--data-raw '{"email": "aaa.test.4@investhub.io", "auth_token": "xben1ikulllpud9xq7twxizy4dajb7jg"}'
then It should return the status of success true. Then the previous redirect_url
link will be expired.
Just tested. It's working.
My reproduce steps:
- First create new user by post to registration
After click to first login in -> then I signed out ( like normal user does )
- Post to generating the auth token:
When you click on the redirect_url => It will auto login our system.
- And when session end, post destroy auth token
If KYC has been submitted - then we will send a request to
https://www.yourdomain.com
/api/first-token-submissions
(https://www.yourdomain.com
/api/ is a config API URL, we can change it in Admin -> Settings -> Internal Sales API Settings)
With this data:
{"success": true, "user_email": "
test@test.it
", "amount": 1, "context": "first_token_submissions"}
Endpoint for purchase of tokens
https://kyc.yourdomain.com/sales/buy-amount-contribution?origin=https://kyc.yourdomain.com
(?origin=https://kyc.yourdomain.com
is also needed, for our routing purposes)
Please change the host name (kyc.yourdomain.com
) and origin to your tenant URL if you use dev, please use dev, if production use production.
You need to send a POST request with a content type of application/JSON containing the following fields:
{“email”: [email],“amount_contribution”: [Int of tokens purchased]}Example:{“email”: “test@gmail.com”,“amount_contribution”: 1000}
The response will be also in JSON format, with the following fields:
{"success": [boolean], "redirect_url": [string]}
redirect_url
is url to redirect the user. after the redirect, the user will be automatically authenticated at kyc.yourdomain.com
and open contribute page
In case of error: {“success”: false,“error”: ‘User not found!' or 'amount_contribution must be an integer!’}
Example of successful:
{"success": true,"redirect_url": "https://kyc.yourdomain.com/auth?auth_token=c4knp7sknqaqayn018dwry3o9kfzrcvx&redirect_url=contribute"}
Endpoint for sending payment confirmations
The endpoint is: www.sales.yourdomain.com
/api/payment-notification
We will send the POST request to the sale api with this endpoint.
The data have this keys: success
, user_email
and amount
Example of data:
{"success": true,"user_email": "test@test.it","amount": 2}
Possible outcomes:
{"success": false,"msg": "User not found"}
{"success": false,"msg": "Package not found"}
{"success": false,"msg": "Transaction denied"}
{"success": false,"msg": "Data inside json are missing"}
{"success": false,"msg": "Data json is missing"}
{"success": false,"msg": "PHP error, contact and administrator"}
{"success": true,"msg": "Package purchased succesfully"}
Also, the call method is POST, and data must be inside the body in JSON format