Skip to content

Payment Api

Enclo edited this page Jan 19, 2019 · 13 revisions

GET /api/v1/loginGetCode/:username

Example: /api/v1/loginGetCode/enclotester

OnSuccess: json object => {"authCode": "string-containing-authcode-to-comment-on-mattcoin-verification-project"}

OnFail: json object => {"Error": "error-produced"}

POST /api/v1/login/

RUN /api/v1/loginGetCode first

Accepts: json object => {"username": "username being logged in"}

Will return the api key for a user if the user posted the code returned by /api/v1/loginGetCode/:username on the project correctly. If api is called and the code doesnt exist or nobody commented, it will return a json object with an object named newCode containing a new code for the user to post on the project, otherwise if successful it will return an apiKey object containing a string with the apiKey for mattcoin

OnSuccess: json object => {"username": "your-username", "apiKey": "your-api-key"}

OnFail: json object => {"Error": "error-produced", "newCode": "new-code-for-mattcoin-verification-project"}

GET /api/v1/getUserHistory/

**Example: ** /api/v1/loginGetCode/EncloTester/myapikey/200

Will return a json object containing a list of a users payment history. For example, if you provide lid with a number like 100, it will get message 100 to message 90 in the json object.

Returns: json object => {"obj": "the-array-with-the-user-payment-history", "dipped": "boolean-that-returns-true-or-false-based-on-if-the-lid-dipped-below-0", "lid": "new-lid"}

GET /api/v1/getUserData/:username/:apikey

**Example: ** /api/v1/loginGetCode/EncloTester/myapikey

Will get basic user data, including balance among other things

Returns: json object => {

"apiKey": "your-api-key",

"balance": "your-balance",

"banned": "boolean-stating-if-youre-banned-or-not",

"chargeBacks": "the-amount-of-times-support-has-taking-money-from-you-for-commiting-a-scam",

"iconLink": "a-link-to-your-user-icon-on-scrath",

"scratchVerified": "boolean-that-returns-if-user-has-used-mattcoin", "securityAnswer": "answer-to-security-question",

"securityQuestion": "a-question-only-you-know-the-answer-to-to-recover-your-mattcoin-account-with-support",

"strikes":"the-amount-of-warnings-given-to-an-account-for-fradulent-activity (3 equals a ban)"

}

POST /api/v1/act/pay/

Accepts: json object => {"username": "your-username", "topay":"the-user-you-are-paying", "amount": "the-amount-you-are-paying", "message": "the-message-the-payment-will-contain"}

Pays a user, returns an error if the payment is unsuccessful

OnSuccess: json object => {"response": true}

OnFail: json object => {"Error": "error-produced"}

POST /api/v1/act/clearPaymentHistory/

Accepts: json object => {"username": "your-username", "apiKey": "your-api-key"}

Clears a user's payment history.

OnSuccess: json object => {"response": true}

OnFail: json object => {"Error": "error-produced"}

GET /api/v1/verifyLoginIntegrity/:username/:apiKey

Example: /api/v1/verifyLoginIntegrity/EncloTester/myapikey

Boolean that checks if the api key corresponds with a username

OnSuccess: json object => {"response": true}

OnFail: json object => {"Error": "error-produced"}

Whats this?

This api is for making payments on Mattcoin programatically, you will need to know how to make HTTP requests. These functions might come to use:

function post(url, jsonObject){
	return new Promise(function(resolve, reject){
		var options = {
			
			uri: url,

			method: 'POST',

			json: jsonObject
		};

		request(options, function (error, response, body) {
			
			if (!error) {
			
				resolve(response.body);
			}else{

				reject(error)
			}
		});
	})
}

function get(url){
	return new Promise(function(resolve, reject){
		let object = {};
		request(
		    { uri: url },
		    
			    function(error, response, body) {

	       			if (!error) {
	
						resolve(JSON.parse(response.body))
					}else{

						reject(error)
					}
				}
			);
	})
}

You will need this NPM library aswell: https://www.npmjs.com/package/request

Example:

async function getAuthCode(){
    const authCode = await get("https://mattcoin.now.sh/api/v1/loginGetCode/enclotester")
    console.log(authCode)

}
Clone this wiki locally