cards
This commit is contained in:
parent
2ccfcb5751
commit
76f1dbb16a
|
@ -66,7 +66,7 @@
|
||||||
preserve_host: true
|
preserve_host: true
|
||||||
url: "http://accounts:3000"
|
url: "http://accounts:3000"
|
||||||
match:
|
match:
|
||||||
url: "http://oathkeeper<{,:4455}>/<{user,user/**,login,logout}>"
|
url: "http://oathkeeper<{,:4455}>/<{user,user/**,square/**,login,logout}>"
|
||||||
methods:
|
methods:
|
||||||
- GET
|
- GET
|
||||||
- POST
|
- POST
|
||||||
|
@ -76,6 +76,10 @@
|
||||||
handler: allow
|
handler: allow
|
||||||
mutators:
|
mutators:
|
||||||
- handler: id_token
|
- handler: id_token
|
||||||
|
- handler: header
|
||||||
|
config:
|
||||||
|
headers:
|
||||||
|
X-User: "{{ print .Subject }}"
|
||||||
errors:
|
errors:
|
||||||
- handler: redirect
|
- handler: redirect
|
||||||
config:
|
config:
|
||||||
|
|
|
@ -76,18 +76,11 @@ mutators:
|
||||||
noop:
|
noop:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
# hydrator:
|
header:
|
||||||
# enabled: true
|
enabled: true
|
||||||
# config:
|
config:
|
||||||
# api:
|
headers:
|
||||||
# url: http://dashboard:3000/api/hydrator
|
X-User: "{{ print .Subject }}"
|
||||||
|
|
||||||
# cookie:
|
|
||||||
# enabled: true
|
|
||||||
# config:
|
|
||||||
# cookies:
|
|
||||||
# user: "{{ print .Subject }}"
|
|
||||||
# some-arbitrary-data: "{{ print .Extra.foo }}"
|
|
||||||
|
|
||||||
id_token:
|
id_token:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"dayjs": "^1.10.4",
|
"dayjs": "^1.10.4",
|
||||||
"express-jwt": "^6.0.0",
|
"express-jwt": "^6.0.0",
|
||||||
"formik": "^2.2.6",
|
"formik": "^2.2.6",
|
||||||
|
"http-status-codes": "^2.1.4",
|
||||||
"jwks-rsa": "^1.12.2",
|
"jwks-rsa": "^1.12.2",
|
||||||
"ky": "0.25.1",
|
"ky": "0.25.1",
|
||||||
"next": "^10.0.6",
|
"next": "^10.0.6",
|
||||||
|
@ -25,6 +26,7 @@
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
"skynet-js": "^3.0.0",
|
"skynet-js": "^3.0.0",
|
||||||
|
"square": "^8.1.1",
|
||||||
"superagent": "^6.1.0",
|
"superagent": "^6.1.0",
|
||||||
"swr": "^0.4.1",
|
"swr": "^0.4.1",
|
||||||
"tailwindcss": "^2.0.3",
|
"tailwindcss": "^2.0.3",
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { Client, Environment } from "square";
|
||||||
|
import { StatusCodes } from "http-status-codes";
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
environment: Environment.Sandbox,
|
||||||
|
accessToken: process.env.SQUARE_ACCESS_TOKEN,
|
||||||
|
});
|
||||||
|
|
||||||
|
const api = {
|
||||||
|
GET: async (req, res) => {
|
||||||
|
console.log(req.headers);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { result } = await client.customersApi.retrieveCustomer("R7R0NY1Z8WT11D43564EEFKTYR");
|
||||||
|
|
||||||
|
res.json(result?.customer?.cards ?? []);
|
||||||
|
} catch (error) {
|
||||||
|
// console.log(error);
|
||||||
|
res.json([]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default (req, res) => {
|
||||||
|
if (req.method in api) {
|
||||||
|
api[req.method](req, res);
|
||||||
|
} else {
|
||||||
|
res.status(StatusCodes.NOT_FOUND);
|
||||||
|
}
|
||||||
|
};
|
Reference in New Issue