Added RAAS api and tracking
Improvements on paypal UI
This commit is contained in:
@@ -20,7 +20,9 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const accessToken = await getAccessToken();
|
||||
if (!accessToken) return res.status(401).json({ok: false, reason: "Authorization failed!"});
|
||||
|
||||
const {currencyCode, price} = req.body as {currencyCode: string; price: number};
|
||||
const {currencyCode, price, trackingId} = req.body as {currencyCode: string; price: number, trackingId: string};
|
||||
|
||||
if(!trackingId) return res.status(401).json({ok: false, reason: "Missing tracking id!"});
|
||||
|
||||
const request = await axios.post<OrderResponseBody>(
|
||||
`${process.env.PAYPAL_ACCESS_TOKEN_URL}/v2/checkout/orders`,
|
||||
@@ -34,11 +36,24 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
reference_id: v4(),
|
||||
},
|
||||
],
|
||||
payment_source: {
|
||||
paypal: {
|
||||
email_address: req.session.user.email || "",
|
||||
experience_context: {
|
||||
payment_method_preference: "IMMEDIATE_PAYMENT_REQUIRED",
|
||||
locale: "en-US",
|
||||
landing_page: "LOGIN",
|
||||
shipping_preference: "NO_SHIPPING",
|
||||
user_action: "PAY_NOW",
|
||||
},
|
||||
},
|
||||
},
|
||||
intent: "CAPTURE",
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
'PayPal-Client-Metadata-Id': trackingId,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user