From dcffe7f6e478afb050daefaebbdee4e6e1d69e80 Mon Sep 17 00:00:00 2001 From: Jesse Shawl Date: Thu, 2 Nov 2023 13:13:27 -0500 Subject: [PATCH] Update save-payment-method/server/server.js Co-authored-by: Greg Jopa <534034+gregjopa@users.noreply.github.com> --- save-payment-method/server/server.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/save-payment-method/server/server.js b/save-payment-method/server/server.js index dd5ad373..bffb522d 100644 --- a/save-payment-method/server/server.js +++ b/save-payment-method/server/server.js @@ -19,7 +19,15 @@ app.use(express.json()); * Generate an OAuth 2.0 access token for authenticating with PayPal REST APIs. * @see https://developer.paypal.com/api/rest/authentication/ */ -const authenticate = async (targetCustomerId) => { +const authenticate = async (bodyParams) => { + const params = { + grant_type: "client_credentials", + response_type: "id_token", + ...bodyParams + }; + + // pass the url encoded value as the body of the post call + const urlEncodedParams = new URLSearchParams(params).toString(); try { if (!PAYPAL_CLIENT_ID || !PAYPAL_CLIENT_SECRET) { throw new Error("MISSING_API_CREDENTIALS");