addie-js 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -3
  2. package/addie.js +52 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,9 +10,7 @@ import addie from 'addie-js';
10
10
  const saveKeys = (keys) => { /* handle persisting keys here */ };
11
11
  const getKeys = () => { /* return keys here. Can be async */ };
12
12
 
13
- const stateHash = 'add a hash of the current state';
14
-
15
- const uuid = await addie.createUser(stateHash, saveKeys, getKeys);
13
+ const uuid = await addie.createUser(saveKeys, getKeys);
16
14
 
17
15
  // unimplemented const updatedUser = await addie.addProcessorAccount(uuid, /* processorInfo - there is a reference stripe implementation in the repo, but not quite ready for public release yet */);
18
16
 
package/addie.js CHANGED
@@ -33,7 +33,8 @@ const addie = {
33
33
  baseURL: 'https://dev.addie.allyabase.com/',
34
34
 
35
35
  createUser: async (saveKeys, getKeys) => {
36
- const keys = await sessionless.generateKeys(saveKeys, getKeys);
36
+ const keys = (await getKeys()) || (await sessionless.generateKeys(saveKeys, getKeys))
37
+ sessionless.getKeys = getKeys;
37
38
 
38
39
  const payload = {
39
40
  timestamp: new Date().getTime() + '',
@@ -49,12 +50,60 @@ const addie = {
49
50
  return uuid;
50
51
  },
51
52
 
53
+ getUserByUUID: async (uuid) => {
54
+ const timestamp = new Date().getTime() + '';
55
+
56
+ const message = timestamp + uuid;
57
+
58
+ const signature = await sessionless.sign(message);
59
+
60
+ const res = await get(`${addie.baseURL}user/${uuid}?signature=${signature}&timestamp=${timestamp}`);
61
+ const user = res.json();
62
+
63
+ return user;
64
+ },
65
+
52
66
  addProcessorAccount: async (uuid, processorPayload) => {
53
67
  return 'unimplemented';
54
68
  },
55
69
 
56
- getPaymentIntent: async (uuid, processor, processorPayload) => {
57
- return 'unimplemented';
70
+ getPaymentIntent: async (uuid, processor, amount, currency, payees) => {
71
+ const timestamp = new Date().getTime() + '';
72
+ const message = timestamp + uuid + amount + currency;
73
+ const signature = await sessionless.sign(message);
74
+
75
+ const payload = {
76
+ timestamp,
77
+ amount,
78
+ currency,
79
+ "payees": payees,
80
+ "signature": signature
81
+ };
82
+
83
+ const url = `${baseURL}user/${uuid}/processor/${processor}/intent`;
84
+ const res = post(url, payload); // Start here
85
+ const intent = await res.json();
86
+
87
+ return intent;
88
+ },
89
+
90
+ getPaymentIntentWithoutSplits: async (uuid, processor, amount, currency) => {
91
+ const timestamp = new Date().getTime() + '';
92
+ const message = timestamp + uuid + amount + currency;
93
+ const signature = await sessionless.sign(message);
94
+
95
+ const payload = {
96
+ timestamp,
97
+ amount,
98
+ currency,
99
+ "signature": signature
100
+ };
101
+
102
+ const url = `${baseURL}user/${uuid}/processor/${processor}/intent-without-splits`;
103
+ const res = post(url, payload); // Start here
104
+ const intent = await res.json();
105
+
106
+ return intent;
58
107
  },
59
108
 
60
109
  deleteUser: async (uuid) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "addie-js",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Addie JavaScript client",
5
5
  "main": "addie.js",
6
6
  "scripts": {