Comment on page
Sales API
In case you are driving traffic from external sources via Single Sign on, here you will whitelist external traffic URLs.

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:
- 1.Endpoint for registration is
https://kyc.enercom.ag/sales/user?origin=https://kyc.enercom.ag
(?origin=https://kyc.enercom.ag is also needed, for our routing purposes) Please change the host name (kyc.enercom.ag) and origin (https://kyc.enercom.ag) 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": "[email protected]","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.enercom.ag/salesLogin?first_auth_token=eoexIAhx3wH”}
- 2.Login auth1. Generate auth_token: - Post request to
https://dev-kyc.enercom.ag/sales/generate-user-auth-token?origin=https://dev-kyc.enercom.ag
with body params with email & password (password format like the Endpoint for registration) example:{"email": "[email protected]", "password": "$2b$13$YeGFwoZ3KMaL7AmS/Dl/peXXdf7bOAkcp0FFriAjFoYJG0iMOrgpe"}
CURL example:curl --location --request POST 'https://dev-kyc.enercom.ag/sales/generate-user-auth-token?origin=https://dev-kyc.enercom.ag' \--header 'Content-Type: application/json' \--header 'Cookie: __cfduid=dda0b0fed26c194b28ed84793e3ef93611602681187' \--data-raw '{ "email": "[email protected]", "password": "$2b$13$YeGFwoZ3KMaL7AmS/Dl/peXXdf7bOAkcp0FFriAjFoYJG0iMOrgpe"}'
Then you will receive a response withauth_token
, and theredirect_url
link, this link when you access, it will automatically login into KYC platform.{"success": true, "auth_token": "xben1ikulllpud9xq7twxizy4dajb7jg", "redirect_url": "https://dev-kyc.enercom.ag/salesAuthTokenLogin?auth_token=xben1ikulllpud9xq7twxizy4dajb7jg"}
- 3.When your session end, you can call this api to destroy auth_token: - Post request to
https://dev-kyc.enercom.ag/sales/destroy-user-auth-token?origin=https://dev-kyc.enercom.ag
with body params withemail
& theauth_token
(in this case it will be"xben1ikulllpud9xq7twxizy4dajb7jg"
) CURL example:curl --location --request POST 'https://dev-kyc.enercom.ag/sales/destroy-user-auth-token?origin=https://dev-kyc.enercom.ag' \--header 'Content-Type: application/json' \--header 'Cookie: __cfduid=dda0b0fed26c194b28ed84793e3ef93611602681187' \--data-raw '{"email": "[email protected]", "auth_token": "xben1ikulllpud9xq7twxizy4dajb7jg"}'
then It should return the status of success true. Then the previousredirect_url
link will be expired. Just tested. It's working. My reproduce steps: - First create new user by post to registrationAfter 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 - 4.If KYC has been submitted - then we will send a request to https://www.sales.enercom.ag/api/first-token-submissions (https://www.sales.enercom.ag/api/ is a config API URL, we can change it in Admin -> Settings -> Internal Sales API Settings) With this data:
{"success": true, "user_email": "
[email protected]
", "amount": 1, "context": "first_token_submissions"}
- 5.Endpoint for purchase of tokens
https://kyc.enercom.ag/sales/buy-amount-contribution?origin=https://kyc.enercom.ag
(?origin=https://kyc.enercom.ag is also needed, for our routing purposes) Please change the host name (kyc.enercom.ag) and origin to your tenant https://yourname-dev.investhub.io 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”: “[email protected]”,“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.enercom.ag 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.enercom.ag/auth?auth_token=c4knp7sknqaqayn018dwry3o9kfzrcvx&redirect_url=contribute
"}
- 6.Endpoint for sending payment confirmationsThe endpoint is: www.sales.enercom.ag/api/payment-notification We will send the POST request to the sale api with this endpoint. The data have this keys:
success
,user_email
andamount
Example of data:{"success": true,"user_email": "[email protected]","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
Last modified 9mo ago