-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrz_CreateOrder.ts
24 lines (23 loc) · 934 Bytes
/
rz_CreateOrder.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import fetch from "node-fetch";
import { Review, User } from "../models";
import { response } from "../utils/helper";
export const handler = async (event: any) => {
let body: any = event.body;
let { amount } = JSON.parse(body);
let order = {};
let receiptId = 'MA_' + (new Date()).getTime().toString(36) + Math.random().toString(36).slice(2).toString()
await fetch("https://api.razorpay.com/v1/orders", {
method: 'POST',
body: JSON.stringify({ amount, currency: "INR", receipt: receiptId }),
headers: {
'Authorization': 'Basic ' + new Buffer('rzp_test_JLOs2SaWEERrUz' + ":" + '4z8H9aF4GTFnUgQvsXuViifK').toString('base64'),
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
}
})
.then((res: any) => res.json())
.then((res: any) => {
order = res;
});
return response(200, order);
}