-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd-pay.js
More file actions
64 lines (51 loc) · 1.99 KB
/
Copy pathadd-pay.js
File metadata and controls
64 lines (51 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const axios = require('axios');
module.exports = function (params) {
const config = {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Token :' + params.token
}
};
const BASE_URL = params.base_url || 'https://secure-test.addpay.co.za/v2';
async function getTransaction(transactionId) {
const FIND_TRANSACTION_URL = BASE_URL + `/transactions/${transactionId}`;
return await axios
.post(FIND_TRANSACTION_URL, transactionData, config);
}
async function getTransactionTypes() {
const URL = BASE_URL + '/services?type=transaction';
return await axios.get(URL, config)
}
async function createTransaction(transactionData) {
const CREATE_TRANSACTION_URL = BASE_URL + "/transactions/";
return await axios
.post(CREATE_TRANSACTION_URL, transactionData, config);
}
async function createCustomer(customerData) {
const CREATE_CUSTOMER_URL = BASE_URL + "/customers/";
return axios
.post(CREATE_CUSTOMER_URL, customerData, config);
}
async function associateTransactionWithCustomer(transationId, customerId) {
const associateURL = BASE_URL + `/transactions/${transationId}/customers/${customerId}`;
return axios.put(associateURL, {}, config)
}
async function createContract(contractData) {
const CREATE_CONTRACT_URL = BASE_URL + "/contracts/";
return axios
.post(CREATE_CONTRACT_URL, contractData, config);
}
async function associateContractWithTransaction(contractId, transationId) {
const associateURL = BASE_URL + `/contracts/${contractId}/transactions/${transationId}`;
return axios.put(associateURL, {}, config)
}
return {
getTransaction,
getTransactionTypes,
createTransaction,
createCustomer,
associateTransactionWithCustomer,
createContract,
associateContractWithTransaction
}
}